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

Commitebf7144

Browse files
oleg gurevViktoria Shepard
oleg gurev
authored and
Viktoria Shepard
committed
[PBCKP-2775] Test test_incr_lsn_long_xact_1 fix
1 parent19f5033 commitebf7144

File tree

11 files changed

+91
-49
lines changed

11 files changed

+91
-49
lines changed

‎src/pg_probackup.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ main(int argc, char *argv[])
687687
if (instance_config.pgdata!=NULL&&
688688
(backup_subcmd!=ARCHIVE_GET_CMD&&backup_subcmd!=CATCHUP_CMD)&&
689689
!is_absolute_path(instance_config.pgdata))
690-
elog(ERROR,"-D, --pgdata must be an absolute path");
690+
elog(ERROR,"-D, --pgdata must be an absolute path: %s",instance_config.pgdata);
691691

692692
#ifPG_VERSION_NUM >=110000
693693
/* Check xlog-seg-size option */

‎tests/archive_test.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,6 +2437,9 @@ def test_archive_get_prefetch_corruption(self):
24372437

24382438
prefetch_line='Prefetched WAL segment {0} is invalid, cannot use it'.format(filename)
24392439
restored_line='LOG: restored log file "{0}" from archive'.format(filename)
2440+
2441+
self.wait_server_wal_exists(replica.data_dir,wal_dir,filename)
2442+
24402443
tailer=tail_file(os.path.join(replica.logs_dir,'postgresql.log'))
24412444
tailer.wait(contains=prefetch_line)
24422445
tailer.wait(contains=restored_line)
@@ -2483,6 +2486,9 @@ def test_archive_show_partial_files_handling(self):
24832486

24842487
self.switch_wal_segment(node)
24852488

2489+
self.wait_instance_wal_exists(backup_dir,'node',
2490+
f"{filename}.gz")
2491+
24862492
os.rename(
24872493
os.path.join(wals_dir,filename),
24882494
os.path.join(wals_dir,'{0}.part'.format(filename)))

‎tests/backup_test.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3218,6 +3218,10 @@ def test_missing_replication_permission_1(self):
32183218

32193219
replica.promote()
32203220

3221+
# Wait for replica to catch up with master before promoting
3222+
# to ensure 'backup' role is replicated
3223+
self.wait_until_replica_catch_with_master(node,replica)
3224+
32213225
# PAGE
32223226
output=self.backup_node(
32233227
backup_dir,'node',replica,backup_type='page',

‎tests/catchup_test.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,18 +1586,22 @@ def test_dry_run_catchup_delta(self):
15861586
# Cleanup
15871587
src_pg.stop()
15881588

1589+
# Skip test, because it's PGDATA is global variable and has impact for other tests
1590+
# e.g. test_checkdb_amcheck_only_sanity
1591+
@unittest.skip("skip")
15891592
deftest_pgdata_is_ignored(self):
15901593
""" In catchup we still allow PGDATA to be set either from command line
15911594
or from the env var. This test that PGDATA is actually ignored and
15921595
--source-pgadta is used instead
15931596
"""
1594-
node=self.make_simple_node('node',
1597+
node=self.make_simple_node(
1598+
base_dir=os.path.join(self.module_name,self.fname,'node'),
15951599
set_replication=True
15961600
)
15971601
node.slow_start()
15981602

15991603
# do full catchup
1600-
dest=self.make_empty_node('dst')
1604+
dest=self.make_empty_node(base_dir=os.path.join(self.module_name,self.fname,'dst'))
16011605
self.catchup_node(
16021606
backup_mode='FULL',
16031607
source_pgdata=node.data_dir,
@@ -1612,7 +1616,7 @@ def test_pgdata_is_ignored(self):
16121616

16131617
os.environ['PGDATA']='xxx'
16141618

1615-
dest2=self.make_empty_node('dst')
1619+
dest2=self.make_empty_node(base_dir=os.path.join(self.module_name,self.fname,'dst'))
16161620
self.catchup_node(
16171621
backup_mode='FULL',
16181622
source_pgdata=node.data_dir,

‎tests/checkdb_test.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_checkdb_amcheck_only_sanity(self):
1818

1919
backup_dir=os.path.join(self.tmp_path,self.module_name,self.fname,'backup')
2020
node=self.make_simple_node(
21-
base_dir="{0}/{1}/node".format(self.module_name,self.fname),
21+
base_dir=os.path.join(self.module_name,self.fname,'node'),
2222
set_replication=True,
2323
initdb_params=['--data-checksums'])
2424

@@ -227,7 +227,7 @@ def test_basic_checkdb_amcheck_only_sanity(self):
227227
""""""
228228
backup_dir=os.path.join(self.tmp_path,self.module_name,self.fname,'backup')
229229
node=self.make_simple_node(
230-
base_dir="{0}/{1}/node".format(self.module_name,self.fname),
230+
base_dir=os.path.join(self.module_name,self.fname,'node'),
231231
set_replication=True,
232232
initdb_params=['--data-checksums'])
233233

‎tests/helpers/ptrack_helpers.py‎

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
importsignal
77
importsubprocess
88
importshutil
9+
fromtimeimportsleep
910
importsix
1011
importtestgres
1112
importhashlib
1213
importre
1314
importgetpass
1415
importselect
15-
fromtimeimportsleep
16+
importtime
1617
importre
1718
importjson
1819
importrandom
@@ -150,8 +151,9 @@ def __str__(self):
150151

151152
classPostgresNodeExtended(testgres.PostgresNode):
152153

153-
def__init__(self,base_dir=None,*args,**kwargs):
154-
super(PostgresNodeExtended,self).__init__(name='test',base_dir=base_dir,*args,**kwargs)
154+
def__init__(self,base_dir=None,port=None,bin_dir=None,*args,**kwargs):
155+
assertportisNoneortype(port)==int
156+
super(PostgresNodeExtended,self).__init__(name='test',base_dir=base_dir,port=port,bin_dir=bin_dir,*args,**kwargs)
155157
self.is_started=False
156158

157159
defslow_start(self,replica=False):
@@ -414,25 +416,28 @@ def is_test_result_ok(test_case):
414416
#
415417
# 2. python versions 3.11+ mixin, verified on 3.11, taken from: https://stackoverflow.com/a/39606065
416418

417-
ifnotisinstance(test_case,unittest.TestCase):
418-
raiseAssertionError("test_case is not instance of unittest.TestCase")
419-
420-
ifhasattr(test_case,'_outcome'):# Python 3.4+
421-
ifhasattr(test_case._outcome,'errors'):
422-
# Python 3.4 - 3.10 (These two methods have no side effects)
423-
result=test_case.defaultTestResult()# These two methods have no side effects
424-
test_case._feedErrorsToResult(result,test_case._outcome.errors)
425-
else:
426-
# Python 3.11+ and pytest 5.3.5+
427-
result=test_case._outcome.result
428-
ifnothasattr(result,'errors'):
429-
result.errors= []
430-
ifnothasattr(result,'failures'):
431-
result.failures= []
432-
else:# Python 2.7, 3.0-3.3
433-
result=getattr(test_case,'_outcomeForDoCleanups',test_case._resultForDoCleanups)
419+
ifhasattr(test_case._outcome,'errors'):
420+
# Python 3.4 - 3.10 (These two methods have no side effects)
421+
result=test_case.defaultTestResult()# These two methods have no side effects
422+
test_case._feedErrorsToResult(result,test_case._outcome.errors)
423+
else:
424+
# Python 3.11+ and pytest 5.3.5+
425+
result=test_case._outcome.result
426+
ifnothasattr(result,'errors'):
427+
result.errors= []
428+
ifnothasattr(result,'failures'):
429+
result.failures= []
434430

435431
ok=all(test!=test_casefortest,textinresult.errors+result.failures)
432+
# check subtests as well
433+
ok=okandall(getattr(test,'test_case',None)!=test_case
434+
fortest,textinresult.errors+result.failures)
435+
436+
# for pytest 8+
437+
ifhasattr(result,'_excinfo'):
438+
ifresult._excinfoisnotNoneandlen(result._excinfo)>0:
439+
# if test was successful, _excinfo will be None, else it will be non-empty list
440+
ok=False
436441

437442
returnok
438443

@@ -475,12 +480,14 @@ def pg_config_version(self):
475480

476481
defmake_empty_node(
477482
self,
478-
base_dir=None):
483+
base_dir=None,
484+
port=None,
485+
bin_dir=None):
479486
real_base_dir=os.path.join(self.tmp_path,base_dir)
480487
shutil.rmtree(real_base_dir,ignore_errors=True)
481488
os.makedirs(real_base_dir)
482489

483-
node=PostgresNodeExtended(base_dir=real_base_dir)
490+
node=PostgresNodeExtended(base_dir=real_base_dir,port=port,bin_dir=bin_dir)
484491
node.should_rm_dirs=True
485492
self.nodes_to_cleanup.append(node)
486493

@@ -489,12 +496,14 @@ def make_empty_node(
489496
defmake_simple_node(
490497
self,
491498
base_dir=None,
499+
port=None,
500+
bin_dir=None,
492501
set_replication=False,
493502
ptrack_enable=False,
494503
initdb_params=[],
495504
pg_options={}):
496505

497-
node=self.make_empty_node(base_dir)
506+
node=self.make_empty_node(base_dir,port=port,bin_dir=bin_dir)
498507
node.init(
499508
initdb_params=initdb_params,allow_streaming=set_replication)
500509

@@ -910,6 +919,24 @@ def get_backup_filelist_diff(self, filelist_A, filelist_B):
910919

911920
returnfilelist_diff
912921

922+
defwait_instance_wal_exists(self,backup_dir,instance,file,timeout=300):
923+
"""Wait for WAL segment appeared in the WAL archive"""
924+
start=time.time()
925+
fl=f'wal/{instance}/{file}'
926+
whiletime.time()-start<timeout:
927+
ifos.path.exists(fl):
928+
break
929+
time.sleep(0.25)
930+
931+
defwait_server_wal_exists(self,data_dir,wal_dir,file,timeout=300):
932+
"""Wait for WAL segment appeared in the server WAL dir"""
933+
start=time.time()
934+
fl=f'{data_dir}/{wal_dir}/{file}'
935+
whiletime.time()-start<timeout:
936+
ifos.path.exists(fl):
937+
return
938+
time.sleep(0.25)
939+
913940
# used for partial restore
914941
deftruncate_every_file_in_dir(self,path):
915942
forfileinos.listdir(path):

‎tests/incr_restore_test.py‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,17 +1592,12 @@ def test_incr_checksum_long_xact(self):
15921592
'select count(*) from t1').decode('utf-8').rstrip(),
15931593
'1')
15941594

1595-
# @unittest.skip("skip")
1596-
# @unittest.expectedFailure
1597-
# This test will pass with Enterprise
1598-
# because it has checksums enabled by default
1599-
@unittest.skipIf(ProbackupTest.enterprise,'skip')
16001595
deftest_incr_lsn_long_xact_1(self):
16011596
"""
16021597
"""
16031598
node=self.make_simple_node(
16041599
base_dir=os.path.join(self.module_name,self.fname,'node'),
1605-
set_replication=True)
1600+
set_replication=True,initdb_params=['--no-data-checksums'])
16061601

16071602
backup_dir=os.path.join(self.tmp_path,self.module_name,self.fname,'backup')
16081603
self.init_pb(backup_dir)
@@ -2046,8 +2041,9 @@ def test_incremental_partial_restore_exclude_lsn(self):
20462041
base_dir=os.path.join(self.module_name,self.fname,'node1'))
20472042
node1.cleanup()
20482043

2049-
node2=self.make_simple_node(
2050-
base_dir=os.path.join(self.module_name,self.fname,'node2'))
2044+
node2=self.make_empty_node(
2045+
base_dir=os.path.join(self.module_name,self.fname,'node2'),port=node.port)
2046+
assertnode2.port==node.port
20512047
node2.cleanup()
20522048

20532049
# restore some data into node2
@@ -2063,7 +2059,7 @@ def test_incremental_partial_restore_exclude_lsn(self):
20632059
pgdata1=self.pgdata_content(node1.data_dir)
20642060

20652061
# partial incremental restore backup into node2
2066-
node2.port=node.port
2062+
#node2.port = node.port
20672063
node2.slow_start()
20682064
node2.stop()
20692065
self.restore_node(

‎tests/ptrack_test.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,9 @@ def test_alter_database_set_tablespace_ptrack(self):
17811781

17821782
# RESTORE
17831783
node_restored=self.make_simple_node(
1784-
base_dir=os.path.join(self.module_name,self.fname,'node_restored'))
1784+
base_dir=os.path.join(self.module_name,self.fname,'node_restored'),
1785+
port=node.port)
1786+
assertnode_restored.port==node.port
17851787
node_restored.cleanup()
17861788
self.restore_node(
17871789
backup_dir,'node',
@@ -1799,7 +1801,6 @@ def test_alter_database_set_tablespace_ptrack(self):
17991801
self.compare_pgdata(pgdata,pgdata_restored)
18001802

18011803
# START RESTORED NODE
1802-
node_restored.port=node.port
18031804
node_restored.slow_start()
18041805

18051806
# @unittest.skip("skip")

‎tests/requirements.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# git+https://github.com/postgrespro/testgres.git@<git-ref>
66
# 3. From a local directory
77
# /path/to/local/directory/testgres
8-
testgres==1.8.5
8+
testgres==1.12.0
99
allure-pytest
1010
deprecation
1111
pexpect

‎tests/set_backup_test.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ def test_wal_retention_and_pinning_1(self):
339339

340340
node.pgbench_init(scale=2)
341341

342+
self.wait_instance_wal_exists(backup_dir,'node',
343+
"000000010000000000000004")
344+
342345
# Purge backups
343346
out=self.delete_expired(
344347
backup_dir,'node',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp