You've already forked pg_probackup
mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-07-16 07:14:15 +02:00
[Issue #169] test coverage
This commit is contained in:
@ -85,8 +85,8 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
pgbench = node.pgbench(
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
options=["-c", "4", "-T", "20"]
|
||||
)
|
||||
options=["-c", "4", "-T", "20"])
|
||||
|
||||
pgbench.wait()
|
||||
pgbench.stdout.close()
|
||||
|
||||
@ -105,6 +105,44 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
node.safe_psql(
|
||||
'postgres',
|
||||
'create table tmp as select * from pgbench_accounts where aid < 1000')
|
||||
|
||||
node.safe_psql(
|
||||
'postgres',
|
||||
'delete from pgbench_accounts')
|
||||
|
||||
node.safe_psql(
|
||||
'postgres',
|
||||
'VACUUM')
|
||||
|
||||
self.backup_node(backup_dir, 'node', node, backup_type='page')
|
||||
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
node_restored.cleanup()
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored, options=["-j", "4"])
|
||||
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
node.safe_psql(
|
||||
'postgres',
|
||||
'insert into pgbench_accounts select * from pgbench_accounts')
|
||||
|
||||
self.backup_node(backup_dir, 'node', node, backup_type='page')
|
||||
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
node_restored.cleanup()
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored, options=["-j", "4"])
|
||||
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
@ -118,8 +156,7 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
base_dir=os.path.join(module_name, fname, 'node'),
|
||||
set_replication=True,
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={
|
||||
'autovacuum': 'off'})
|
||||
pg_options={'autovacuum': 'off'})
|
||||
|
||||
self.init_pb(backup_dir, old_binary=True)
|
||||
self.show_pb(backup_dir)
|
||||
@ -189,8 +226,7 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
pgbench.wait()
|
||||
pgbench.stdout.close()
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='delta')
|
||||
self.backup_node(backup_dir, 'node', node, backup_type='delta')
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
@ -204,6 +240,44 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
node.safe_psql(
|
||||
'postgres',
|
||||
'create table tmp as select * from pgbench_accounts where aid < 1000')
|
||||
|
||||
node.safe_psql(
|
||||
'postgres',
|
||||
'delete from pgbench_accounts')
|
||||
|
||||
node.safe_psql(
|
||||
'postgres',
|
||||
'VACUUM')
|
||||
|
||||
self.backup_node(backup_dir, 'node', node, backup_type='delta')
|
||||
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
node_restored.cleanup()
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored, options=["-j", "4"])
|
||||
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
node.safe_psql(
|
||||
'postgres',
|
||||
'insert into pgbench_accounts select * from pgbench_accounts')
|
||||
|
||||
self.backup_node(backup_dir, 'node', node, backup_type='delta')
|
||||
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
node_restored.cleanup()
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored, options=["-j", "4"])
|
||||
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
@ -530,3 +604,87 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
# @unittest.expectedFailure
|
||||
# @unittest.skip("skip")
|
||||
def test_backward_compatibility_merge_1(self):
|
||||
"""
|
||||
Create node, take FULL and PAGE backups with old binary,
|
||||
merge them with new binary.
|
||||
old binary version =< 2.2.7
|
||||
"""
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
node = self.make_simple_node(
|
||||
base_dir=os.path.join(module_name, fname, 'node'),
|
||||
set_replication=True,
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={'autovacuum': 'off'})
|
||||
|
||||
self.init_pb(backup_dir, old_binary=True)
|
||||
self.add_instance(backup_dir, 'node', node, old_binary=True)
|
||||
|
||||
self.set_archiving(backup_dir, 'node', node, old_binary=True)
|
||||
node.slow_start()
|
||||
|
||||
node.pgbench_init(scale=1)
|
||||
|
||||
# FULL backup with OLD binary
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
old_binary=True)
|
||||
|
||||
pgbench = node.pgbench(
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
options=["-c", "4", "-T", "10"])
|
||||
pgbench.wait()
|
||||
pgbench.stdout.close()
|
||||
|
||||
# PAGE1 backup with OLD binary
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='page', old_binary=True)
|
||||
|
||||
node.safe_psql(
|
||||
'postgres',
|
||||
'DELETE from pgbench_accounts')
|
||||
|
||||
node.safe_psql(
|
||||
'postgres',
|
||||
'VACUUM pgbench_accounts')
|
||||
|
||||
# PAGE2 backup with OLD binary
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='page', old_binary=True)
|
||||
|
||||
# PAGE3 backup with OLD binary
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='page', old_binary=True)
|
||||
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
# merge chain created by old binary with new binary
|
||||
output = self.merge_backup(
|
||||
backup_dir, "node", backup_id)
|
||||
|
||||
# check that in-place is disabled
|
||||
self.assertIn(
|
||||
"WARNING: In-place merge is disabled "
|
||||
"because of program versions mismatch", output)
|
||||
|
||||
# restore merged backup
|
||||
node_restored = self.make_simple_node(
|
||||
base_dir=os.path.join(module_name, fname, 'node_restored'))
|
||||
node_restored.cleanup()
|
||||
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored, options=["-j", "4"])
|
||||
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
Reference in New Issue
Block a user