Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite3f9d59

Browse files
author
Artur Zakirov
committed
Remove name argument of make_bnode()
1 parentcc1d1ed commite3f9d59

File tree

9 files changed

+81
-43
lines changed

9 files changed

+81
-43
lines changed

‎tests/backup_test.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def tearDownClass(cls):
1616

1717
deftest_backup_modes_1(self):
1818
"""standart backup modes"""
19-
node=self.make_bnode('backup_modes_',base_dir="tmp_dirs/backup/backup_modes_1")
19+
node=self.make_bnode(base_dir="tmp_dirs/backup/backup_modes_1")
2020
node.start()
2121
self.assertEqual(self.init_pb(node),six.b(""))
2222

@@ -73,7 +73,7 @@ def test_backup_modes_1(self):
7373

7474
deftest_smooth_checkpoint_2(self):
7575
"""full backup with smooth checkpoint"""
76-
node=self.make_bnode('smooth_checkpoint_2',base_dir="tmp_dirs/backup/smooth_checkpoint_2")
76+
node=self.make_bnode(base_dir="tmp_dirs/backup/smooth_checkpoint_2")
7777
node.start()
7878
self.assertEqual(self.init_pb(node),six.b(""))
7979

@@ -86,7 +86,7 @@ def test_smooth_checkpoint_2(self):
8686

8787
deftest_page_backup_without_full_3(self):
8888
"""page-level backup without validated full backup"""
89-
node=self.make_bnode('without_full_3',base_dir="tmp_dirs/backup/without_full_3")
89+
node=self.make_bnode(base_dir="tmp_dirs/backup/without_full_3")
9090
node.start()
9191
self.assertEqual(self.init_pb(node),six.b(""))
9292

@@ -100,7 +100,6 @@ def test_page_backup_without_full_3(self):
100100
deftest_ptrack_threads_4(self):
101101
"""ptrack multi thread backup mode"""
102102
node=self.make_bnode(
103-
'ptrack_threads_4',
104103
base_dir="tmp_dirs/backup/ptrack_threads_4",
105104
options={"ptrack_enable":"on"}
106105
)
@@ -122,7 +121,6 @@ def test_ptrack_threads_4(self):
122121
deftest_ptrack_threads_stream_5(self):
123122
"""ptrack multi thread backup mode and stream"""
124123
node=self.make_bnode(
125-
'ptrack_threads_stream_5',
126124
base_dir="tmp_dirs/backup/ptrack_threads_stream_5",
127125
options={
128126
"ptrack_enable":"on",

‎tests/delete_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def tearDownClass(cls):
1717

1818
deftest_delete_full_backups_1(self):
1919
"""delete full backups"""
20-
node=self.make_bnode('delete_full_backups_1',base_dir="tmp_dirs/delete/delete_full_backups_1")
20+
node=self.make_bnode(base_dir="tmp_dirs/delete/delete_full_backups_1")
2121
node.start()
2222
self.assertEqual(self.init_pb(node),six.b(""))
2323
node.pgbench_init()
@@ -52,7 +52,7 @@ def test_delete_full_backups_1(self):
5252

5353
deftest_delete_increment_2(self):
5454
"""delete increment and all after him"""
55-
node=self.make_bnode('delete_increment_2',base_dir="tmp_dirs/delete/delete_increment_2")
55+
node=self.make_bnode(base_dir="tmp_dirs/delete/delete_increment_2")
5656
node.start()
5757
self.assertEqual(self.init_pb(node),six.b(""))
5858

‎tests/init_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, *args, **kwargs):
1212

1313
deftest_success_1(self):
1414
"""Success normal init"""
15-
node=self.make_bnode('test_success_1',base_dir="tmp_dirs/init/success_1")
15+
node=self.make_bnode(base_dir="tmp_dirs/init/success_1")
1616
self.assertEqual(self.init_pb(node),six.b(""))
1717
self.assertEqual(
1818
dir_files(self.backup_dir(node)),
@@ -21,7 +21,7 @@ def test_success_1(self):
2121

2222
deftest_already_exist_2(self):
2323
"""Failure with backup catalog already existed"""
24-
node=self.make_bnode('test_already_exist_2',base_dir="tmp_dirs/init/already_exist_2")
24+
node=self.make_bnode(base_dir="tmp_dirs/init/already_exist_2")
2525
self.init_pb(node)
2626
self.assertEqual(
2727
self.init_pb(node),
@@ -30,7 +30,7 @@ def test_already_exist_2(self):
3030

3131
deftest_abs_path_3(self):
3232
"""failure with backup catalog should be given as absolute path"""
33-
node=self.make_bnode('test_abs_path_3',base_dir="tmp_dirs/init/abs_path_3")
33+
node=self.make_bnode(base_dir="tmp_dirs/init/abs_path_3")
3434
self.assertEqual(
3535
self.run_pb(["init","-B",path.relpath("%s/backup"%node.base_dir,self.dir_path)]),
3636
six.b("ERROR: -B, --backup-path must be an absolute path\n")

‎tests/option_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_without_backup_path_3(self):
3838
)
3939

4040
deftest_options_4(self):
41-
node=self.make_bnode('test_options_4',base_dir="tmp_dirs/option/option_common")
41+
node=self.make_bnode(base_dir="tmp_dirs/option/option_common")
4242
try:
4343
node.stop()
4444
except:

‎tests/pb_lib.py

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,15 @@ def arcwal_dir(self, node):
9191
defbackup_dir(self,node):
9292
returnos.path.abspath("%s/backup"%node.base_dir)
9393

94-
defmake_bnode(self,name,base_dir=None,options={}):
94+
defmake_bnode(self,base_dir=None,allows_streaming=False,options={}):
9595
real_base_dir=path.join(self.dir_path,base_dir)
9696
shutil.rmtree(real_base_dir,ignore_errors=True)
97+
9798
node=get_new_node('test',base_dir=real_base_dir)
98-
node.init()
99-
# node.init(initdb_params=[
100-
# "-x", "0x123456789ABCDEF0",
101-
# "-m", "0x23456789ABCDEF01",
102-
# "-o", "0x3456789ABCDEF012"
103-
# ])
104-
105-
node.append_conf("postgresql.conf","wal_level = hot_standby")
99+
node.init(allows_streaming=allows_streaming)
100+
101+
ifnotallows_streaming:
102+
node.append_conf("postgresql.conf","wal_level = hot_standby")
106103
node.append_conf("postgresql.conf","archive_mode = on")
107104
node.append_conf(
108105
"postgresql.conf",
@@ -114,6 +111,33 @@ def make_bnode(self, name, base_dir=None, options={}):
114111

115112
returnnode
116113

114+
defmake_bnode_replica(self,root_node,base_dir=None,options={}):
115+
real_base_dir=path.join(self.dir_path,base_dir)
116+
shutil.rmtree(real_base_dir,ignore_errors=True)
117+
118+
root_node.backup("basebackup")
119+
120+
replica=get_new_node("replica",base_dir=real_base_dir)
121+
# replica.init_from_backup(root_node, "data_replica", has_streaming=True)
122+
123+
# Move data from backup
124+
backup_path=os.path.join(root_node.base_dir,"basebackup")
125+
shutil.move(backup_path,replica.data_dir)
126+
os.chmod(replica.data_dir,0o0700)
127+
128+
# Change port in config file
129+
replica.append_conf(
130+
"postgresql.conf",
131+
"port = {}".format(replica.port)
132+
)
133+
# Enable streaming
134+
replica.enable_streaming(root_node)
135+
136+
forkey,valueinsix.iteritems(options):
137+
replica.append_conf("postgresql.conf","%s = %s"% (key,value))
138+
139+
returnreplica
140+
117141
defrun_pb(self,command):
118142
try:
119143
returnsubprocess.check_output(
@@ -145,9 +169,29 @@ def backup_pb(self, node, backup_type="full", options=[]):
145169
ifbackup_type:
146170
cmd_list+= ["-b",backup_type]
147171

148-
# print(cmd_list)
149172
returnself.run_pb(cmd_list+options)
150173

174+
defbackup_pb_proc(self,node,backup_dir,backup_type="full",
175+
stdout=None,stderr=None,options=[]):
176+
cmd_list= [
177+
self.probackup_path,
178+
"backup",
179+
"-D",node.data_dir,
180+
"-B",backup_dir,
181+
"-p","%i"% (node.port),
182+
"-d","postgres"
183+
]
184+
ifbackup_type:
185+
cmd_list+= ["-b",backup_type]
186+
187+
proc=subprocess.Popen(
188+
cmd_list+options,
189+
stdout=stdout,
190+
stderr=stderr
191+
)
192+
193+
returnproc
194+
151195
defrestore_pb(self,node,id=None,options=[]):
152196
cmd_list= [
153197
"-D",node.data_dir,

‎tests/restore_test.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def tearDownClass(cls):
1919

2020
deftest_restore_to_latest_1(self):
2121
"""recovery to latest from full backup"""
22-
node=self.make_bnode('restore_to_latest_1',base_dir="tmp_dirs/restore/restore_to_latest_1")
22+
node=self.make_bnode(base_dir="tmp_dirs/restore/restore_to_latest_1")
2323
node.start()
2424
self.assertEqual(self.init_pb(node),six.b(""))
2525
node.pgbench_init(scale=2)
@@ -50,7 +50,7 @@ def test_restore_to_latest_1(self):
5050

5151
deftest_restore_to_latest_2(self):
5252
"""recovery to latest from full + page backups"""
53-
node=self.make_bnode('restore_to_latest_2',base_dir="tmp_dirs/restore/restore_to_latest_2")
53+
node=self.make_bnode(base_dir="tmp_dirs/restore/restore_to_latest_2")
5454
node.start()
5555
self.assertEqual(self.init_pb(node),six.b(""))
5656
node.pgbench_init(scale=2)
@@ -82,7 +82,7 @@ def test_restore_to_latest_2(self):
8282

8383
deftest_restore_to_timeline_3(self):
8484
"""recovery to target timeline"""
85-
node=self.make_bnode('restore_to_timeline_3',base_dir="tmp_dirs/restore/restore_to_timeline_3")
85+
node=self.make_bnode(base_dir="tmp_dirs/restore/restore_to_timeline_3")
8686
node.start()
8787
self.assertEqual(self.init_pb(node),six.b(""))
8888
node.pgbench_init(scale=2)
@@ -127,7 +127,7 @@ def test_restore_to_timeline_3(self):
127127

128128
deftest_restore_to_time_4(self):
129129
"""recovery to target timeline"""
130-
node=self.make_bnode('restore_to_time_4',base_dir="tmp_dirs/restore/restore_to_time_4")
130+
node=self.make_bnode(base_dir="tmp_dirs/restore/restore_to_time_4")
131131
node.start()
132132
self.assertEqual(self.init_pb(node),six.b(""))
133133
node.pgbench_init(scale=2)
@@ -158,7 +158,7 @@ def test_restore_to_time_4(self):
158158

159159
deftest_restore_to_xid_5(self):
160160
"""recovery to target xid"""
161-
node=self.make_bnode('restore_to_xid_5',base_dir="tmp_dirs/restore/restore_to_xid_5")
161+
node=self.make_bnode(base_dir="tmp_dirs/restore/restore_to_xid_5")
162162
node.start()
163163
self.assertEqual(self.init_pb(node),six.b(""))
164164
node.pgbench_init(scale=2)
@@ -204,7 +204,7 @@ def test_restore_to_xid_5(self):
204204

205205
deftest_restore_full_ptrack_6(self):
206206
"""recovery to latest from full + ptrack backups"""
207-
node=self.make_bnode('restore_full_ptrack_6',base_dir="tmp_dirs/restore/full_ptrack_6")
207+
node=self.make_bnode(base_dir="tmp_dirs/restore/full_ptrack_6")
208208
node.start()
209209
self.assertEqual(self.init_pb(node),six.b(""))
210210
node.pgbench_init(scale=2)
@@ -244,7 +244,7 @@ def test_restore_full_ptrack_6(self):
244244

245245
deftest_restore_full_ptrack_ptrack_7(self):
246246
"""recovery to latest from full + ptrack + ptrack backups"""
247-
node=self.make_bnode('restore_full_ptrack_ptrack_7',base_dir="tmp_dirs/restore/full_ptrack_ptrack_7")
247+
node=self.make_bnode(base_dir="tmp_dirs/restore/full_ptrack_ptrack_7")
248248
node.start()
249249
self.assertEqual(self.init_pb(node),six.b(""))
250250
node.pgbench_init(scale=2)
@@ -291,7 +291,7 @@ def test_restore_full_ptrack_ptrack_7(self):
291291

292292
deftest_restore_full_ptrack_stream_8(self):
293293
"""recovery in stream mode to latest from full + ptrack backups"""
294-
node=self.make_bnode('restore_full_ptrack_stream_8',base_dir="tmp_dirs/restore/full_ptrack_stream_8")
294+
node=self.make_bnode(base_dir="tmp_dirs/restore/full_ptrack_stream_8")
295295
node.start()
296296
self.assertEqual(self.init_pb(node),six.b(""))
297297
node.pgbench_init(scale=2)
@@ -334,7 +334,7 @@ def test_restore_full_ptrack_stream_8(self):
334334

335335
deftest_restore_full_ptrack_under_load_9(self):
336336
"""recovery to latest from full + page backups with loads when ptrack backup do"""
337-
node=self.make_bnode('restore_full_ptrack_under_load_9',base_dir="tmp_dirs/restore/full_ptrack_under_load_9")
337+
node=self.make_bnode(base_dir="tmp_dirs/restore/full_ptrack_under_load_9")
338338
node.start()
339339
self.assertEqual(self.init_pb(node),six.b(""))
340340
wal_segment_size=self.guc_wal_segment_size(node)
@@ -391,7 +391,7 @@ def test_restore_full_ptrack_under_load_9(self):
391391

392392
deftest_restore_full_under_load_ptrack_10(self):
393393
"""recovery to latest from full + page backups with loads when full backup do"""
394-
node=self.make_bnode('restore_full_under_load_ptrack_10',base_dir="tmp_dirs/restore/full_under_load_ptrack_10")
394+
node=self.make_bnode(base_dir="tmp_dirs/restore/full_under_load_ptrack_10")
395395
node.start()
396396
self.assertEqual(self.init_pb(node),six.b(""))
397397
wal_segment_size=self.guc_wal_segment_size(node)
@@ -448,7 +448,7 @@ def test_restore_full_under_load_ptrack_10(self):
448448

449449
deftest_restore_to_xid_inclusive_11(self):
450450
"""recovery with target inclusive false"""
451-
node=self.make_bnode('restore_to_xid_inclusive_11',base_dir="tmp_dirs/restore/restore_to_xid_inclusive_11")
451+
node=self.make_bnode(base_dir="tmp_dirs/restore/restore_to_xid_inclusive_11")
452452
node.start()
453453
self.assertEqual(self.init_pb(node),six.b(""))
454454
node.pgbench_init(scale=2)
@@ -499,8 +499,7 @@ def test_restore_to_xid_inclusive_11(self):
499499

500500
deftest_restore_with_tablespace_mapping_12(self):
501501
"""recovery using tablespace-mapping option"""
502-
node=self.make_bnode('restore_with_tablespace_mapping_12',
503-
base_dir="tmp_dirs/restore/restore_with_tablespace_mapping_12")
502+
node=self.make_bnode(base_dir="tmp_dirs/restore/restore_with_tablespace_mapping_12")
504503
node.start()
505504
self.assertEqual(self.init_pb(node),six.b(""))
506505

@@ -564,8 +563,7 @@ def test_restore_with_tablespace_mapping_12(self):
564563

565564
deftest_restore_with_tablespace_mapping_13(self):
566565
"""recovery using tablespace-mapping option and page backup"""
567-
node=self.make_bnode('restore_with_tablespace_mapping_13',
568-
base_dir="tmp_dirs/restore/restore_with_tablespace_mapping_13")
566+
node=self.make_bnode(base_dir="tmp_dirs/restore/restore_with_tablespace_mapping_13")
569567
node.start()
570568
self.assertEqual(self.init_pb(node),six.b(""))
571569

‎tests/retention_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ def tearDownClass(cls):
1717

1818
deftest_retention_redundancy_1(self):
1919
"""purge backups using redundancy-based retention policy"""
20-
node=self.make_bnode('retention_redundancy_1',
21-
base_dir="tmp_dirs/retention/retention_redundancy_1")
20+
node=self.make_bnode(base_dir="tmp_dirs/retention/retention_redundancy_1")
2221
node.start()
2322

2423
self.init_pb(node)
@@ -56,8 +55,7 @@ def test_retention_redundancy_1(self):
5655

5756
deftest_retention_window_2(self):
5857
"""purge backups using window-based retention policy"""
59-
node=self.make_bnode('retention_window_2',
60-
base_dir="tmp_dirs/retention/retention_window_2")
58+
node=self.make_bnode(base_dir="tmp_dirs/retention/retention_window_2")
6159
node.start()
6260

6361
self.init_pb(node)

‎tests/show_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def tearDownClass(cls):
1717

1818
deftest_ok_1(self):
1919
"""Status DONE and OK"""
20-
node=self.make_bnode('done_ok',base_dir="tmp_dirs/show/ok_1")
20+
node=self.make_bnode(base_dir="tmp_dirs/show/ok_1")
2121
node.start()
2222
self.assertEqual(self.init_pb(node),six.b(""))
2323

@@ -31,7 +31,7 @@ def test_ok_1(self):
3131

3232
deftest_corrupt_2(self):
3333
"""Status DONE and OK"""
34-
node=self.make_bnode('corrupt',base_dir="tmp_dirs/show/corrupt_2")
34+
node=self.make_bnode(base_dir="tmp_dirs/show/corrupt_2")
3535
node.start()
3636
self.assertEqual(self.init_pb(node),six.b(""))
3737

‎tests/validate_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def tearDownClass(cls):
2121

2222
deftest_validate_wal_1(self):
2323
"""recovery to latest from full backup"""
24-
node=self.make_bnode('test_validate_wal_1',base_dir="tmp_dirs/validate/wal_1")
24+
node=self.make_bnode(base_dir="tmp_dirs/validate/wal_1")
2525
node.start()
2626
self.assertEqual(self.init_pb(node),six.b(""))
2727
node.pgbench_init(scale=2)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp