tests: fixes

This commit is contained in:
Grigory Smolkin
2019-10-04 10:36:56 +03:00
parent d02fc64a14
commit 6062362519
3 changed files with 38 additions and 23 deletions
-1
View File
@@ -411,7 +411,6 @@ class DeleteTest(ProbackupTest, unittest.TestCase):
node.slow_start()
# Take FULL BACKUPs
backup_id_a = self.backup_node(backup_dir, 'node', node)
backup_id_b = self.backup_node(backup_dir, 'node', node)
+19 -1
View File
@@ -949,7 +949,8 @@ class ProbackupTest(object):
def show_archive(
self, backup_dir, instance=None, options=[],
as_text=False, as_json=True, old_binary=False
as_text=False, as_json=True, old_binary=False,
tli=0
):
cmd_list = [
@@ -973,6 +974,23 @@ class ProbackupTest(object):
data = self.run_pb(cmd_list + options, old_binary=old_binary)
else:
data = json.loads(self.run_pb(cmd_list + options, old_binary=old_binary))
if instance:
instance_timelines = None
for instance_name in data:
if instance_name['instance'] == instance:
instance_timelines = instance_name['timelines']
break
if tli > 0:
timeline_data = None
for timeline in instance_timelines:
if timeline['tli'] == tli:
return timeline
if instance_timelines:
return instance_timelines
return data
else:
show_splitted = self.run_pb(
+19 -21
View File
@@ -25,10 +25,8 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
self.set_archiving(backup_dir, 'node', node)
node.slow_start()
with open(os.path.join(
backup_dir, 'backups', 'node',
"pg_probackup.conf"), "a") as conf:
conf.write("retention-redundancy = 1\n")
self.set_config(
backup_dir, 'node', options=['--retention-redundancy=1'])
# Make backups to be purged
self.backup_node(backup_dir, 'node', node)
@@ -39,31 +37,31 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
self.assertEqual(len(self.show_pb(backup_dir, 'node')), 4)
output_before = self.show_archive(backup_dir, 'node', tli=1)
# Purge backups
log = self.delete_expired(
backup_dir, 'node', options=['--expired', '--wal'])
self.assertEqual(len(self.show_pb(backup_dir, 'node')), 2)
output_after = self.show_archive(backup_dir, 'node', tli=1)
self.assertEqual(
output_before['max-segno'],
output_after['max-segno'])
self.assertNotEqual(
output_before['min-segno'],
output_after['min-segno'])
# Check that WAL segments were deleted
min_wal = None
max_wal = None
for line in log.splitlines():
if line.startswith("INFO: removed min WAL segment"):
min_wal = line[31:-1]
elif line.startswith("INFO: removed max WAL segment"):
max_wal = line[31:-1]
if not min_wal:
self.assertTrue(False, "min_wal is empty")
if not max_wal:
self.assertTrue(False, "max_wal is not set")
min_wal = output_after['min-segno']
max_wal = output_after['max-segno']
for wal_name in os.listdir(os.path.join(backup_dir, 'wal', 'node')):
if not wal_name.endswith(".backup"):
# wal_name_b = wal_name.encode('ascii')
self.assertEqual(wal_name[8:] > min_wal[8:], True)
self.assertEqual(wal_name[8:] > max_wal[8:], True)
self.assertTrue(wal_name[8:] >= min_wal)
self.assertTrue(wal_name[8:] <= max_wal)
# Clean after yourself
self.del_test_dir(module_name, fname)
@@ -1353,7 +1351,7 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
gdb.set_breakpoint('pg_stop_backup')
gdb.run_until_break()
gdb._execute('signal SIGTERM')
gdb._execute('signal SIGKILL')
gdb.continue_execution_until_error()
page_id = self.show_pb(backup_dir, 'node')[1]['id']