Skip to content

Commit 4fd6ba1

Browse files
committed
[Issue #226] fix tests
1 parent 5d904b6 commit 4fd6ba1

File tree

5 files changed

+33
-96
lines changed

5 files changed

+33
-96
lines changed

tests/archive.py

+9-20
Original file line numberDiff line numberDiff line change
@@ -765,10 +765,6 @@ def test_replica_archive(self):
765765

766766
before = master.safe_psql("postgres", "SELECT * FROM t_heap")
767767

768-
master.safe_psql(
769-
"postgres",
770-
"CHECKPOINT")
771-
772768
self.wait_until_replica_catch_with_master(master, replica)
773769

774770
backup_id = self.backup_node(
@@ -864,10 +860,6 @@ def test_master_and_replica_parallel_archiving(self):
864860
"md5(repeat(i::text,10))::tsvector as tsvector "
865861
"from generate_series(0, 60000) i")
866862

867-
master.psql(
868-
"postgres",
869-
"CHECKPOINT")
870-
871863
backup_id = self.backup_node(
872864
backup_dir, 'replica', replica,
873865
options=[
@@ -977,10 +969,6 @@ def test_basic_master_and_replica_concurrent_archiving(self):
977969

978970
replica.promote()
979971

980-
replica.safe_psql(
981-
'postgres',
982-
'CHECKPOINT')
983-
984972
master.pgbench_init(scale=10)
985973
replica.pgbench_init(scale=10)
986974

@@ -1221,11 +1209,6 @@ def test_archive_catalog(self):
12211209
# create timeline t2
12221210
replica.promote()
12231211

1224-
# do checkpoint to increment timeline ID in pg_control
1225-
replica.safe_psql(
1226-
'postgres',
1227-
'CHECKPOINT')
1228-
12291212
# FULL backup replica
12301213
A1 = self.backup_node(
12311214
backup_dir, 'replica', replica)
@@ -1959,7 +1942,8 @@ def test_archive_pg_receivexlog_partial_handling(self):
19591942

19601943
replica.slow_start(replica=True)
19611944

1962-
node.safe_psql('postgres', 'CHECKPOINT')
1945+
# FULL
1946+
self.backup_node(backup_dir, 'replica', replica, options=['--stream'])
19631947

19641948
if self.get_version(replica) < 100000:
19651949
pg_receivexlog_path = self.get_bin_path('pg_receivexlog')
@@ -1981,14 +1965,18 @@ def test_archive_pg_receivexlog_partial_handling(self):
19811965
'Failed to start pg_receivexlog: {0}'.format(
19821966
pg_receivexlog.communicate()[1]))
19831967

1968+
replica.safe_psql(
1969+
'postgres',
1970+
'CHECKPOINT')
1971+
19841972
node.safe_psql(
19851973
"postgres",
19861974
"create table t_heap as select i as id, md5(i::text) as text, "
19871975
"md5(repeat(i::text,10))::tsvector as tsvector "
19881976
"from generate_series(0,1000000) i")
19891977

1990-
# FULL
1991-
self.backup_node(backup_dir, 'replica', replica, options=['--stream'])
1978+
# PAGE
1979+
self.backup_node(backup_dir, 'replica', replica, backup_type='page')
19921980

19931981
node.safe_psql(
19941982
"postgres",
@@ -2027,6 +2015,7 @@ def test_archive_pg_receivexlog_partial_handling(self):
20272015
pg_receivexlog.kill()
20282016
self.del_test_dir(module_name, fname)
20292017

2018+
@unittest.skip("skip")
20302019
def test_multi_timeline_recovery_prefetching(self):
20312020
""""""
20322021
fname = self.id().split('.')[3]

tests/backup.py

+13-17
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ def test_page_detect_corruption(self):
324324
node = self.make_simple_node(
325325
base_dir=os.path.join(module_name, fname, 'node'),
326326
set_replication=True,
327+
ptrack_enable=True,
327328
initdb_params=['--data-checksums'])
328329

329330
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@@ -663,12 +664,10 @@ def test_backup_detect_invalid_block_header(self):
663664
"\n Output: {0} \n CMD: {1}".format(
664665
repr(self.output), self.cmd))
665666
except ProbackupException as e:
666-
self.assertTrue(
667-
'WARNING: page verification failed, '
668-
'calculated checksum' in e.message and
669-
'ERROR: query failed: ERROR: '
670-
'invalid page in block 1 of relation' in e.message and
671-
'ERROR: Data files transferring failed' in e.message,
667+
self.assertIn(
668+
'ERROR: Corruption detected in file "{0}", block 1: '
669+
'page header invalid, pd_lower'.format(heap_fullpath),
670+
e.message,
672671
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
673672
repr(e.message), self.cmd))
674673

@@ -806,12 +805,10 @@ def test_backup_detect_missing_permissions(self):
806805
"\n Output: {0} \n CMD: {1}".format(
807806
repr(self.output), self.cmd))
808807
except ProbackupException as e:
809-
self.assertTrue(
810-
'WARNING: page verification failed, '
811-
'calculated checksum' in e.message and
812-
'ERROR: query failed: ERROR: '
813-
'invalid page in block 1 of relation' in e.message and
814-
'ERROR: Data files transferring failed' in e.message,
808+
self.assertIn(
809+
'ERROR: Corruption detected in file "{0}", block 1: '
810+
'page header invalid, pd_lower'.format(heap_fullpath),
811+
e.message,
815812
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
816813
repr(e.message), self.cmd))
817814

@@ -1480,7 +1477,7 @@ def test_drop_rel_during_backup_ptrack(self):
14801477
node = self.make_simple_node(
14811478
base_dir=os.path.join(module_name, fname, 'node'),
14821479
set_replication=True,
1483-
ptrack_enable=True,
1480+
ptrack_enable=self.ptrack,
14841481
initdb_params=['--data-checksums'])
14851482

14861483
self.init_pb(backup_dir)
@@ -1927,7 +1924,7 @@ def test_basic_missing_file_permissions(self):
19271924
repr(self.output), self.cmd))
19281925
except ProbackupException as e:
19291926
self.assertIn(
1930-
'ERROR: Cannot open source file',
1927+
'ERROR: Cannot open file',
19311928
e.message,
19321929
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
19331930
repr(e.message), self.cmd))
@@ -2131,9 +2128,8 @@ def test_backup_with_least_privileges_role(self):
21312128
"TO backup".format(fname))
21322129
else:
21332130
fnames = [
2134-
'pg_catalog.pg_ptrack_get_pagemapset(pg_lsn)',
2135-
'pg_catalog.pg_ptrack_control_lsn()',
2136-
'pg_catalog.pg_ptrack_get_block(oid, oid, oid, bigint)'
2131+
'pg_catalog.ptrack_get_pagemapset(pg_lsn)',
2132+
'pg_catalog.ptrack_init_lsn()'
21372133
]
21382134

21392135
for fname in fnames:

tests/ptrack.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3946,9 +3946,9 @@ def test_ptrack_pg_resetxlog(self):
39463946
repr(self.output), self.cmd)
39473947
)
39483948
except ProbackupException as e:
3949-
self.assertIn(
3950-
'ERROR: LSN from ptrack_control 0/0 differs from Start LSN of previous backup',
3951-
e.message,
3949+
self.assertTrue(
3950+
'ERROR: LSN from ptrack_control ' in e.message and
3951+
'differs from Start LSN of previous backup' in e.message,
39523952
'\n Unexpected Error Message: {0}\n'
39533953
' CMD: {1}'.format(repr(e.message), self.cmd))
39543954

tests/replica.py

+3-38
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,6 @@ def test_replica_archive_page_backup(self):
207207

208208
before = master.safe_psql("postgres", "SELECT * FROM t_heap")
209209

210-
master.psql(
211-
"postgres",
212-
"CHECKPOINT")
213-
214210
self.wait_until_replica_catch_with_master(master, replica)
215211

216212
backup_id = self.backup_node(
@@ -383,10 +379,6 @@ def test_take_backup_from_delayed_replica(self):
383379
"md5(repeat(i::text,10))::tsvector as tsvector "
384380
"from generate_series(0,165000) i")
385381

386-
master.psql(
387-
"postgres",
388-
"CHECKPOINT")
389-
390382
master.psql(
391383
"postgres",
392384
"create table t_heap_1 as select i as id, md5(i::text) as text, "
@@ -726,9 +718,11 @@ def test_replica_stop_lsn_null_offset_next_record(self):
726718
log_content)
727719

728720
self.assertIn(
729-
'LOG: stop_lsn: 0/4000028',
721+
'LOG: stop_lsn: 0/4000000',
730722
log_content)
731723

724+
self.assertTrue(self.show_pb(backup_dir, 'replica')[0]['status'] == 'DONE')
725+
732726
# Clean after yourself
733727
self.del_test_dir(module_name, fname)
734728

@@ -1118,18 +1112,6 @@ def test_replica_promote_2(self):
11181112

11191113
replica.promote()
11201114

1121-
replica.safe_psql(
1122-
'postgres',
1123-
'CHECKPOINT')
1124-
1125-
# replica.safe_psql(
1126-
# 'postgres',
1127-
# 'create table t2()')
1128-
#
1129-
# replica.safe_psql(
1130-
# 'postgres',
1131-
# 'CHECKPOINT')
1132-
11331115
self.backup_node(
11341116
backup_dir, 'master', replica, data_dir=replica.data_dir,
11351117
backup_type='page')
@@ -1176,10 +1158,6 @@ def test_replica_promote_3(self):
11761158

11771159
self.add_instance(backup_dir, 'replica', replica)
11781160

1179-
replica.safe_psql(
1180-
'postgres',
1181-
'CHECKPOINT')
1182-
11831161
full_id = self.backup_node(
11841162
backup_dir, 'replica',
11851163
replica, options=['--stream'])
@@ -1191,20 +1169,12 @@ def test_replica_promote_3(self):
11911169
'FROM generate_series(0,20) i')
11921170
self.wait_until_replica_catch_with_master(master, replica)
11931171

1194-
replica.safe_psql(
1195-
'postgres',
1196-
'CHECKPOINT')
1197-
11981172
self.backup_node(
11991173
backup_dir, 'replica', replica,
12001174
backup_type='delta', options=['--stream'])
12011175

12021176
replica.promote()
12031177

1204-
replica.safe_psql(
1205-
'postgres',
1206-
'CHECKPOINT')
1207-
12081178
# failing, because without archving, it is impossible to
12091179
# take multi-timeline backup.
12101180
try:
@@ -1297,7 +1267,6 @@ def test_replica_promote_archive_delta(self):
12971267

12981268
# node2 is now master
12991269
node2.promote()
1300-
node2.safe_psql('postgres', 'CHECKPOINT')
13011270

13021271
node2.safe_psql(
13031272
'postgres',
@@ -1331,7 +1300,6 @@ def test_replica_promote_archive_delta(self):
13311300

13321301
# node1 is back to be a master
13331302
node1.promote()
1334-
node1.safe_psql('postgres', 'CHECKPOINT')
13351303

13361304
sleep(5)
13371305

@@ -1420,7 +1388,6 @@ def test_replica_promote_archive_page(self):
14201388

14211389
# node2 is now master
14221390
node2.promote()
1423-
node2.safe_psql('postgres', 'CHECKPOINT')
14241391

14251392
node2.safe_psql(
14261393
'postgres',
@@ -1454,7 +1421,6 @@ def test_replica_promote_archive_page(self):
14541421

14551422
# node1 is back to be a master
14561423
node1.promote()
1457-
node1.safe_psql('postgres', 'CHECKPOINT')
14581424
self.switch_wal_segment(node1)
14591425

14601426
sleep(5)
@@ -1532,7 +1498,6 @@ def test_parent_choosing(self):
15321498
backup_type='delta', options=['--stream'])
15331499

15341500
replica.promote()
1535-
replica.safe_psql('postgres', 'CHECKPOINT')
15361501

15371502
# failing, because without archving, it is impossible to
15381503
# take multi-timeline backup.

tests/restore.py

+5-18
Original file line numberDiff line numberDiff line change
@@ -980,9 +980,9 @@ def test_restore_with_tablespace_mapping_2(self):
980980

981981
# Create tablespace table
982982
with node.connect("postgres") as con:
983-
con.connection.autocommit = True
984-
con.execute("CHECKPOINT")
985-
con.connection.autocommit = False
983+
# con.connection.autocommit = True
984+
# con.execute("CHECKPOINT")
985+
# con.connection.autocommit = False
986986
con.execute("CREATE TABLE tbl1 (a int) TABLESPACE tblspc")
987987
con.execute(
988988
"INSERT INTO tbl1 SELECT * "
@@ -1389,10 +1389,6 @@ def test_zags_block_corrupt_1(self):
13891389
'postgres',
13901390
'create extension pageinspect')
13911391

1392-
node.safe_psql(
1393-
'postgres',
1394-
'checkpoint')
1395-
13961392
node.safe_psql(
13971393
'postgres',
13981394
'insert into tbl select i from generate_series(0,100) as i')
@@ -3025,6 +3021,7 @@ def test_missing_database_map(self):
30253021
node = self.make_simple_node(
30263022
base_dir=os.path.join(module_name, fname, 'node'),
30273023
set_replication=True,
3024+
ptrack_enable=self.ptrack,
30283025
initdb_params=['--data-checksums'],
30293026
pg_options={'autovacuum': 'off'})
30303027

@@ -3276,17 +3273,7 @@ def test_stream_restore_command_option(self):
32763273
self.backup_node(
32773274
backup_dir, 'node', node, options=['--stream'])
32783275

3279-
node.pgbench_init(scale=1)
3280-
3281-
node.safe_psql(
3282-
'postgres',
3283-
'CHECKPOINT')
3284-
3285-
node.pgbench_init(scale=1)
3286-
3287-
node.safe_psql(
3288-
'postgres',
3289-
'CHECKPOINT')
3276+
node.pgbench_init(scale=5)
32903277

32913278
node.safe_psql(
32923279
'postgres',

0 commit comments

Comments
 (0)