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

Commit2b02bd4

Browse files
committed
pgpro589 added
1 parentff03146 commit2b02bd4

File tree

9 files changed

+227
-123
lines changed

9 files changed

+227
-123
lines changed

‎tests/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
retention_test,ptrack_clean,ptrack_cluster, \
66
ptrack_move_to_tablespace,ptrack_recovery,ptrack_vacuum, \
77
ptrack_vacuum_bits_frozen,ptrack_vacuum_bits_visibility, \
8-
ptrack_vacuum_full,ptrack_vacuum_truncate,pgpro561,pgpro668
8+
ptrack_vacuum_full,ptrack_vacuum_truncate,common_archive_test, \
9+
pgpro561,pgpro688,pgpro702,pgpro589
910

1011

1112
defload_tests(loader,tests,pattern):
1213
suite=unittest.TestSuite()
1314
suite.addTests(loader.loadTestsFromModule(pgpro561))
14-
suite.addTests(loader.loadTestsFromModule(pgpro668))
15+
suite.addTests(loader.loadTestsFromModule(pgpro589))
16+
suite.addTests(loader.loadTestsFromModule(pgpro688))
17+
suite.addTests(loader.loadTestsFromModule(pgpro702))
1518
suite.addTests(loader.loadTestsFromModule(init_test))
1619
suite.addTests(loader.loadTestsFromModule(option_test))
1720
suite.addTests(loader.loadTestsFromModule(show_test))

‎tests/pgpro561.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,6 @@ def test_pgpro561(self):
5757

5858
res=node1.safe_psql("postgres","select last_failed_wal from pg_stat_get_archiver() where last_failed_wal is not NULL")
5959
self.assertEqual(res,six.b(""),'Restored Node1 failed to archive segment {0} due to having the same archive command as Master'.format(res.rstrip()))
60+
61+
master.stop()
62+
node1.stop()

‎tests/pgpro589.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
importunittest
2+
importos
3+
importsix
4+
from .ptrack_helpersimportProbackupTest,ProbackupException,idx_ptrack
5+
fromdatetimeimportdatetime,timedelta
6+
fromtestgresimportstop_all
7+
importsubprocess
8+
fromsysimportexit
9+
10+
11+
classLsnCheck(ProbackupTest,unittest.TestCase):
12+
13+
def__init__(self,*args,**kwargs):
14+
super(LsnCheck,self).__init__(*args,**kwargs)
15+
16+
# @classmethod
17+
# def tearDownClass(cls):
18+
# stop_all()
19+
# @unittest.expectedFailure
20+
deftest_pgpro589(self):
21+
"""
22+
https://jira.postgrespro.ru/browse/PGPRO-589
23+
make node without archive support, make backup which should fail
24+
check that no files where copied to backup catalogue
25+
EXPECTED TO FAIL
26+
"""
27+
fname=self.id().split('.')[3]
28+
node=self.make_simple_node(base_dir="tmp_dirs/pgpro589/{0}/node".format(fname),
29+
initdb_params=['--data-checksums'],
30+
pg_options={'wal_level':'replica'}
31+
)
32+
node.start()
33+
34+
node.pgbench_init(scale=5)
35+
pgbench=node.pgbench(
36+
stdout=subprocess.PIPE,
37+
stderr=subprocess.STDOUT,
38+
options=["-c","4","-T","10"]
39+
)
40+
pgbench.wait()
41+
pgbench.stdout.close()
42+
43+
path=node.safe_psql("postgres","select pg_relation_filepath('pgbench_accounts')").rstrip()
44+
45+
self.assertEqual(self.init_pb(node),six.b(""))
46+
proc=self.backup_pb(
47+
node,backup_type='full',options=['--archive-timeout=1'],async=True)
48+
49+
content=proc.stderr.read()
50+
self.assertEqual(True,'wait for LSN'inrepr(content),
51+
'No Wait for LSN')
52+
self.assertEqual(True,'could not be archived'inrepr(content),
53+
'No Fail Archiving Message')
54+
55+
id=self.show_pb(node)[0]['ID']
56+
self.assertEqual('ERROR',self.show_pb(node,id=id)['status'],'Backup should have ERROR status')
57+
#print self.backup_dir(node)
58+
file=os.path.join(self.backup_dir(node),'backups',id,'database',path)
59+
self.assertEqual(False,os.path.isfile(file),
60+
'\n Start LSN was not found in archive but datafiles where copied to backup catalogue.\n For example: {0}\n It is not optimal'.format(file))

‎tests/pgpro668.py

Lines changed: 0 additions & 110 deletions
This file was deleted.

‎tests/pgpro688.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
importunittest
2+
importos
3+
importsix
4+
from .ptrack_helpersimportProbackupTest,ProbackupException
5+
fromdatetimeimportdatetime,timedelta
6+
fromtestgresimportstop_all
7+
importsubprocess
8+
fromsysimportexit
9+
10+
11+
classValidateTime(ProbackupTest,unittest.TestCase):
12+
13+
def__init__(self,*args,**kwargs):
14+
super(ValidateTime,self).__init__(*args,**kwargs)
15+
16+
# @classmethod
17+
# def tearDownClass(cls):
18+
# stop_all()
19+
20+
deftest_validate_recovery_time(self):
21+
"""
22+
make node with archiving, make backup,
23+
get Recovery Time, validate to Recovery Time
24+
EXPECT VALIDATE TO FAIL
25+
Waiting PGPRO-688
26+
"""
27+
fname=self.id().split('.')[3]
28+
node=self.make_simple_node(base_dir="tmp_dirs/pgpro668/{0}".format(fname),
29+
set_archiving=True,
30+
initdb_params=['--data-checksums'],
31+
pg_options={'wal_level':'replica','max_wal_senders':'2'}
32+
)
33+
node.start()
34+
35+
self.assertEqual(self.init_pb(node),six.b(""))
36+
id=self.backup_pb(node,backup_type='full')
37+
recovery_time=self.show_pb(node,id=id)['recovery-time']
38+
39+
# Optional
40+
#node.psql("postgres", "select pg_create_restore_point('123')")
41+
#node.psql("postgres", "select txid_current()")
42+
#node.psql("postgres", "select pg_switch_xlog()")
43+
self.assertIn(six.b("INFO: backup validation completed successfully on"),
44+
self.validate_pb(node,options=["--time='{0}'".format(recovery_time)]))
45+
####

‎tests/pgpro702.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
importunittest
2+
importos
3+
importsix
4+
from .ptrack_helpersimportProbackupTest,ProbackupException
5+
fromdatetimeimportdatetime,timedelta
6+
fromtestgresimportstop_all
7+
importsubprocess
8+
fromsysimportexit
9+
10+
11+
classValidateTime(ProbackupTest,unittest.TestCase):
12+
13+
def__init__(self,*args,**kwargs):
14+
super(ValidateTime,self).__init__(*args,**kwargs)
15+
16+
# @classmethod
17+
# def tearDownClass(cls):
18+
# stop_all()
19+
20+
deftest_validate_recovery_time(self):
21+
"""
22+
make node without archiving, make stream backup,
23+
get Recovery Time, validate to Recovery Time
24+
EXPECT VALIDATE TO FAIL
25+
"""
26+
fname=self.id().split('.')[3]
27+
node=self.make_simple_node(base_dir="tmp_dirs/pgpro702/{0}".format(fname),
28+
set_replication=True,
29+
initdb_params=['--data-checksums'],
30+
pg_options={'wal_level':'replica','max_wal_senders':'2'}
31+
)
32+
node.start()
33+
34+
self.assertEqual(self.init_pb(node),six.b(""))
35+
id=self.backup_pb(node,backup_type='full',options=["--stream"])
36+
recovery_time=self.show_pb(node,id=id)['recovery-time']
37+
38+
self.assertIn(six.b("INFO: backup validation completed successfully on"),
39+
self.validate_pb(node,options=["--time='{0}'".format(recovery_time)]))

‎tests/ptrack_helpers.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,17 +292,27 @@ def check_ptrack_clean(self, idx_dict, size):
292292
success=False
293293
self.assertEqual(success,True)
294294

295-
defrun_pb(self,command):
295+
defrun_pb(self,command,async=False):
296296
try:
297297
# print [self.probackup_path] + command
298-
output=subprocess.check_output(
299-
[self.probackup_path]+command,
300-
stderr=subprocess.STDOUT,
301-
env=self.test_env
302-
)
298+
ifasyncisTrue:
299+
returnsubprocess.Popen(
300+
[self.probackup_path]+command,
301+
stdout=subprocess.PIPE,
302+
stderr=subprocess.PIPE,
303+
env=self.test_env
304+
)
305+
else:
306+
output=subprocess.check_output(
307+
[self.probackup_path]+command,
308+
stderr=subprocess.STDOUT,
309+
env=self.test_env
310+
)
303311
ifcommand[0]=='backup':
304312
if'-q'incommandor'--quiet'incommand:
305313
returnNone
314+
elif'-v'incommandor'--verbose'incommand:
315+
returnoutput
306316
else:
307317
# return backup ID
308318
returnoutput.split()[2]
@@ -322,7 +332,7 @@ def init_pb(self, node):
322332
defclean_pb(self,node):
323333
shutil.rmtree(self.backup_dir(node),ignore_errors=True)
324334

325-
defbackup_pb(self,node=None,data_dir=None,backup_dir=None,backup_type="full",options=[]):
335+
defbackup_pb(self,node=None,data_dir=None,backup_dir=None,backup_type="full",options=[],async=False):
326336
ifdata_dirisNone:
327337
data_dir=node.data_dir
328338
ifbackup_dirisNone:
@@ -338,7 +348,7 @@ def backup_pb(self, node=None, data_dir=None, backup_dir=None, backup_type="full
338348
ifbackup_type:
339349
cmd_list+= ["-b",backup_type]
340350

341-
returnself.run_pb(cmd_list+options)
351+
returnself.run_pb(cmd_list+options,async)
342352

343353
defrestore_pb(self,node=None,backup_dir=None,data_dir=None,id=None,options=[]):
344354
ifdata_dirisNone:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp