1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-07-15 07:04:14 +02:00

[Issue #226] fix tests

This commit is contained in:
Grigory Smolkin
2020-06-12 02:07:29 +03:00
parent 5d904b62e3
commit 4fd6ba14d0
5 changed files with 33 additions and 96 deletions

View File

@ -765,10 +765,6 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
before = master.safe_psql("postgres", "SELECT * FROM t_heap") before = master.safe_psql("postgres", "SELECT * FROM t_heap")
master.safe_psql(
"postgres",
"CHECKPOINT")
self.wait_until_replica_catch_with_master(master, replica) self.wait_until_replica_catch_with_master(master, replica)
backup_id = self.backup_node( backup_id = self.backup_node(
@ -864,10 +860,6 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
"md5(repeat(i::text,10))::tsvector as tsvector " "md5(repeat(i::text,10))::tsvector as tsvector "
"from generate_series(0, 60000) i") "from generate_series(0, 60000) i")
master.psql(
"postgres",
"CHECKPOINT")
backup_id = self.backup_node( backup_id = self.backup_node(
backup_dir, 'replica', replica, backup_dir, 'replica', replica,
options=[ options=[
@ -977,10 +969,6 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
replica.promote() replica.promote()
replica.safe_psql(
'postgres',
'CHECKPOINT')
master.pgbench_init(scale=10) master.pgbench_init(scale=10)
replica.pgbench_init(scale=10) replica.pgbench_init(scale=10)
@ -1221,11 +1209,6 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
# create timeline t2 # create timeline t2
replica.promote() replica.promote()
# do checkpoint to increment timeline ID in pg_control
replica.safe_psql(
'postgres',
'CHECKPOINT')
# FULL backup replica # FULL backup replica
A1 = self.backup_node( A1 = self.backup_node(
backup_dir, 'replica', replica) backup_dir, 'replica', replica)
@ -1959,7 +1942,8 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
replica.slow_start(replica=True) replica.slow_start(replica=True)
node.safe_psql('postgres', 'CHECKPOINT') # FULL
self.backup_node(backup_dir, 'replica', replica, options=['--stream'])
if self.get_version(replica) < 100000: if self.get_version(replica) < 100000:
pg_receivexlog_path = self.get_bin_path('pg_receivexlog') pg_receivexlog_path = self.get_bin_path('pg_receivexlog')
@ -1981,14 +1965,18 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
'Failed to start pg_receivexlog: {0}'.format( 'Failed to start pg_receivexlog: {0}'.format(
pg_receivexlog.communicate()[1])) pg_receivexlog.communicate()[1]))
replica.safe_psql(
'postgres',
'CHECKPOINT')
node.safe_psql( node.safe_psql(
"postgres", "postgres",
"create table t_heap as select i as id, md5(i::text) as text, " "create table t_heap as select i as id, md5(i::text) as text, "
"md5(repeat(i::text,10))::tsvector as tsvector " "md5(repeat(i::text,10))::tsvector as tsvector "
"from generate_series(0,1000000) i") "from generate_series(0,1000000) i")
# FULL # PAGE
self.backup_node(backup_dir, 'replica', replica, options=['--stream']) self.backup_node(backup_dir, 'replica', replica, backup_type='page')
node.safe_psql( node.safe_psql(
"postgres", "postgres",
@ -2027,6 +2015,7 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
pg_receivexlog.kill() pg_receivexlog.kill()
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)
@unittest.skip("skip")
def test_multi_timeline_recovery_prefetching(self): def test_multi_timeline_recovery_prefetching(self):
"""""" """"""
fname = self.id().split('.')[3] fname = self.id().split('.')[3]

View File

@ -324,6 +324,7 @@ class BackupTest(ProbackupTest, unittest.TestCase):
node = self.make_simple_node( node = self.make_simple_node(
base_dir=os.path.join(module_name, fname, 'node'), base_dir=os.path.join(module_name, fname, 'node'),
set_replication=True, set_replication=True,
ptrack_enable=True,
initdb_params=['--data-checksums']) initdb_params=['--data-checksums'])
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@ -663,12 +664,10 @@ class BackupTest(ProbackupTest, unittest.TestCase):
"\n Output: {0} \n CMD: {1}".format( "\n Output: {0} \n CMD: {1}".format(
repr(self.output), self.cmd)) repr(self.output), self.cmd))
except ProbackupException as e: except ProbackupException as e:
self.assertTrue( self.assertIn(
'WARNING: page verification failed, ' 'ERROR: Corruption detected in file "{0}", block 1: '
'calculated checksum' in e.message and 'page header invalid, pd_lower'.format(heap_fullpath),
'ERROR: query failed: ERROR: ' e.message,
'invalid page in block 1 of relation' in e.message and
'ERROR: Data files transferring failed' in e.message,
'\n Unexpected Error Message: {0}\n CMD: {1}'.format( '\n Unexpected Error Message: {0}\n CMD: {1}'.format(
repr(e.message), self.cmd)) repr(e.message), self.cmd))
@ -806,12 +805,10 @@ class BackupTest(ProbackupTest, unittest.TestCase):
"\n Output: {0} \n CMD: {1}".format( "\n Output: {0} \n CMD: {1}".format(
repr(self.output), self.cmd)) repr(self.output), self.cmd))
except ProbackupException as e: except ProbackupException as e:
self.assertTrue( self.assertIn(
'WARNING: page verification failed, ' 'ERROR: Corruption detected in file "{0}", block 1: '
'calculated checksum' in e.message and 'page header invalid, pd_lower'.format(heap_fullpath),
'ERROR: query failed: ERROR: ' e.message,
'invalid page in block 1 of relation' in e.message and
'ERROR: Data files transferring failed' in e.message,
'\n Unexpected Error Message: {0}\n CMD: {1}'.format( '\n Unexpected Error Message: {0}\n CMD: {1}'.format(
repr(e.message), self.cmd)) repr(e.message), self.cmd))
@ -1480,7 +1477,7 @@ class BackupTest(ProbackupTest, unittest.TestCase):
node = self.make_simple_node( node = self.make_simple_node(
base_dir=os.path.join(module_name, fname, 'node'), base_dir=os.path.join(module_name, fname, 'node'),
set_replication=True, set_replication=True,
ptrack_enable=True, ptrack_enable=self.ptrack,
initdb_params=['--data-checksums']) initdb_params=['--data-checksums'])
self.init_pb(backup_dir) self.init_pb(backup_dir)
@ -1927,7 +1924,7 @@ class BackupTest(ProbackupTest, unittest.TestCase):
repr(self.output), self.cmd)) repr(self.output), self.cmd))
except ProbackupException as e: except ProbackupException as e:
self.assertIn( self.assertIn(
'ERROR: Cannot open source file', 'ERROR: Cannot open file',
e.message, e.message,
'\n Unexpected Error Message: {0}\n CMD: {1}'.format( '\n Unexpected Error Message: {0}\n CMD: {1}'.format(
repr(e.message), self.cmd)) repr(e.message), self.cmd))
@ -2131,9 +2128,8 @@ class BackupTest(ProbackupTest, unittest.TestCase):
"TO backup".format(fname)) "TO backup".format(fname))
else: else:
fnames = [ fnames = [
'pg_catalog.pg_ptrack_get_pagemapset(pg_lsn)', 'pg_catalog.ptrack_get_pagemapset(pg_lsn)',
'pg_catalog.pg_ptrack_control_lsn()', 'pg_catalog.ptrack_init_lsn()'
'pg_catalog.pg_ptrack_get_block(oid, oid, oid, bigint)'
] ]
for fname in fnames: for fname in fnames:

View File

@ -3946,9 +3946,9 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
repr(self.output), self.cmd) repr(self.output), self.cmd)
) )
except ProbackupException as e: except ProbackupException as e:
self.assertIn( self.assertTrue(
'ERROR: LSN from ptrack_control 0/0 differs from Start LSN of previous backup', 'ERROR: LSN from ptrack_control ' in e.message and
e.message, 'differs from Start LSN of previous backup' in e.message,
'\n Unexpected Error Message: {0}\n' '\n Unexpected Error Message: {0}\n'
' CMD: {1}'.format(repr(e.message), self.cmd)) ' CMD: {1}'.format(repr(e.message), self.cmd))

View File

@ -207,10 +207,6 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
before = master.safe_psql("postgres", "SELECT * FROM t_heap") before = master.safe_psql("postgres", "SELECT * FROM t_heap")
master.psql(
"postgres",
"CHECKPOINT")
self.wait_until_replica_catch_with_master(master, replica) self.wait_until_replica_catch_with_master(master, replica)
backup_id = self.backup_node( backup_id = self.backup_node(
@ -383,10 +379,6 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
"md5(repeat(i::text,10))::tsvector as tsvector " "md5(repeat(i::text,10))::tsvector as tsvector "
"from generate_series(0,165000) i") "from generate_series(0,165000) i")
master.psql(
"postgres",
"CHECKPOINT")
master.psql( master.psql(
"postgres", "postgres",
"create table t_heap_1 as select i as id, md5(i::text) as text, " "create table t_heap_1 as select i as id, md5(i::text) as text, "
@ -726,9 +718,11 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
log_content) log_content)
self.assertIn( self.assertIn(
'LOG: stop_lsn: 0/4000028', 'LOG: stop_lsn: 0/4000000',
log_content) log_content)
self.assertTrue(self.show_pb(backup_dir, 'replica')[0]['status'] == 'DONE')
# Clean after yourself # Clean after yourself
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)
@ -1118,18 +1112,6 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
replica.promote() replica.promote()
replica.safe_psql(
'postgres',
'CHECKPOINT')
# replica.safe_psql(
# 'postgres',
# 'create table t2()')
#
# replica.safe_psql(
# 'postgres',
# 'CHECKPOINT')
self.backup_node( self.backup_node(
backup_dir, 'master', replica, data_dir=replica.data_dir, backup_dir, 'master', replica, data_dir=replica.data_dir,
backup_type='page') backup_type='page')
@ -1176,10 +1158,6 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
self.add_instance(backup_dir, 'replica', replica) self.add_instance(backup_dir, 'replica', replica)
replica.safe_psql(
'postgres',
'CHECKPOINT')
full_id = self.backup_node( full_id = self.backup_node(
backup_dir, 'replica', backup_dir, 'replica',
replica, options=['--stream']) replica, options=['--stream'])
@ -1191,20 +1169,12 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
'FROM generate_series(0,20) i') 'FROM generate_series(0,20) i')
self.wait_until_replica_catch_with_master(master, replica) self.wait_until_replica_catch_with_master(master, replica)
replica.safe_psql(
'postgres',
'CHECKPOINT')
self.backup_node( self.backup_node(
backup_dir, 'replica', replica, backup_dir, 'replica', replica,
backup_type='delta', options=['--stream']) backup_type='delta', options=['--stream'])
replica.promote() replica.promote()
replica.safe_psql(
'postgres',
'CHECKPOINT')
# failing, because without archving, it is impossible to # failing, because without archving, it is impossible to
# take multi-timeline backup. # take multi-timeline backup.
try: try:
@ -1297,7 +1267,6 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
# node2 is now master # node2 is now master
node2.promote() node2.promote()
node2.safe_psql('postgres', 'CHECKPOINT')
node2.safe_psql( node2.safe_psql(
'postgres', 'postgres',
@ -1331,7 +1300,6 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
# node1 is back to be a master # node1 is back to be a master
node1.promote() node1.promote()
node1.safe_psql('postgres', 'CHECKPOINT')
sleep(5) sleep(5)
@ -1420,7 +1388,6 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
# node2 is now master # node2 is now master
node2.promote() node2.promote()
node2.safe_psql('postgres', 'CHECKPOINT')
node2.safe_psql( node2.safe_psql(
'postgres', 'postgres',
@ -1454,7 +1421,6 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
# node1 is back to be a master # node1 is back to be a master
node1.promote() node1.promote()
node1.safe_psql('postgres', 'CHECKPOINT')
self.switch_wal_segment(node1) self.switch_wal_segment(node1)
sleep(5) sleep(5)
@ -1532,7 +1498,6 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
backup_type='delta', options=['--stream']) backup_type='delta', options=['--stream'])
replica.promote() replica.promote()
replica.safe_psql('postgres', 'CHECKPOINT')
# failing, because without archving, it is impossible to # failing, because without archving, it is impossible to
# take multi-timeline backup. # take multi-timeline backup.

View File

@ -980,9 +980,9 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
# Create tablespace table # Create tablespace table
with node.connect("postgres") as con: with node.connect("postgres") as con:
con.connection.autocommit = True # con.connection.autocommit = True
con.execute("CHECKPOINT") # con.execute("CHECKPOINT")
con.connection.autocommit = False # con.connection.autocommit = False
con.execute("CREATE TABLE tbl1 (a int) TABLESPACE tblspc") con.execute("CREATE TABLE tbl1 (a int) TABLESPACE tblspc")
con.execute( con.execute(
"INSERT INTO tbl1 SELECT * " "INSERT INTO tbl1 SELECT * "
@ -1389,10 +1389,6 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
'postgres', 'postgres',
'create extension pageinspect') 'create extension pageinspect')
node.safe_psql(
'postgres',
'checkpoint')
node.safe_psql( node.safe_psql(
'postgres', 'postgres',
'insert into tbl select i from generate_series(0,100) as i') 'insert into tbl select i from generate_series(0,100) as i')
@ -3025,6 +3021,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
node = self.make_simple_node( node = self.make_simple_node(
base_dir=os.path.join(module_name, fname, 'node'), base_dir=os.path.join(module_name, fname, 'node'),
set_replication=True, set_replication=True,
ptrack_enable=self.ptrack,
initdb_params=['--data-checksums'], initdb_params=['--data-checksums'],
pg_options={'autovacuum': 'off'}) pg_options={'autovacuum': 'off'})
@ -3276,17 +3273,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
self.backup_node( self.backup_node(
backup_dir, 'node', node, options=['--stream']) backup_dir, 'node', node, options=['--stream'])
node.pgbench_init(scale=1) node.pgbench_init(scale=5)
node.safe_psql(
'postgres',
'CHECKPOINT')
node.pgbench_init(scale=1)
node.safe_psql(
'postgres',
'CHECKPOINT')
node.safe_psql( node.safe_psql(
'postgres', 'postgres',