mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-02-04 14:11:31 +02:00
[Issue #155] tests fixes
This commit is contained in:
parent
2b23095c10
commit
6dc2eaf9db
@ -1413,10 +1413,18 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
self.assertEqual(timeline_1['status'], "OK")
|
||||
|
||||
self.assertEqual(len(timeline_3['lost-segments']), 2)
|
||||
self.assertEqual(timeline_3['lost-segments'][0]['begin-segno'], '0000000000000012')
|
||||
self.assertEqual(timeline_3['lost-segments'][0]['end-segno'], '0000000000000013')
|
||||
self.assertEqual(timeline_3['lost-segments'][1]['begin-segno'], '0000000000000017')
|
||||
self.assertEqual(timeline_3['lost-segments'][1]['end-segno'], '0000000000000017')
|
||||
self.assertEqual(
|
||||
timeline_3['lost-segments'][0]['begin-segno'],
|
||||
'000000030000000000000012')
|
||||
self.assertEqual(
|
||||
timeline_3['lost-segments'][0]['end-segno'],
|
||||
'000000030000000000000013')
|
||||
self.assertEqual(
|
||||
timeline_3['lost-segments'][1]['begin-segno'],
|
||||
'000000030000000000000017')
|
||||
self.assertEqual(
|
||||
timeline_3['lost-segments'][1]['end-segno'],
|
||||
'000000030000000000000017')
|
||||
|
||||
self.assertEqual(len(timeline_6['backups']), 0)
|
||||
self.assertEqual(len(timeline_5['backups']), 0)
|
||||
@ -1487,7 +1495,9 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
# sanity
|
||||
for timeline in timelines:
|
||||
self.assertEqual(timeline['min-segno'], '0000000000000001')
|
||||
self.assertEqual(
|
||||
timeline['min-segno'],
|
||||
'000000010000000000000001')
|
||||
self.assertEqual(timeline['status'], 'OK')
|
||||
|
||||
self.del_test_dir(module_name, fname)
|
||||
@ -1539,7 +1549,9 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
# sanity
|
||||
for timeline in timelines:
|
||||
self.assertEqual(timeline['min-segno'], '0000000000000002')
|
||||
self.assertEqual(
|
||||
timeline['min-segno'],
|
||||
'000000010000000000000002')
|
||||
self.assertEqual(timeline['status'], 'OK')
|
||||
|
||||
self.del_test_dir(module_name, fname)
|
||||
@ -1690,8 +1702,67 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
# @unittest.skip("skip")
|
||||
# @unittest.expectedFailure
|
||||
def test_hexadecimal_timeline(self):
|
||||
"""
|
||||
Check that timelines are correct.
|
||||
"""
|
||||
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)
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
self.set_archiving(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
backup_id = self.backup_node(backup_dir, 'node', node)
|
||||
node.pgbench_init(scale=2)
|
||||
|
||||
# create timelines
|
||||
for i in range(1, 13):
|
||||
# print(i)
|
||||
node.cleanup()
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node,
|
||||
options=['--recovery-target-timeline={0}'.format(i)])
|
||||
node.slow_start()
|
||||
node.pgbench_init(scale=2)
|
||||
|
||||
show = self.show_archive(backup_dir)
|
||||
|
||||
timelines = show[0]['timelines']
|
||||
|
||||
print(timelines[0])
|
||||
|
||||
tli13 = timelines[0]
|
||||
|
||||
self.assertEqual(
|
||||
13,
|
||||
tli13['tli'])
|
||||
|
||||
self.assertEqual(
|
||||
12,
|
||||
tli13['parent-tli'])
|
||||
|
||||
self.assertEqual(
|
||||
backup_id,
|
||||
tli13['closest-backup-id'])
|
||||
|
||||
self.assertEqual(
|
||||
'0000000D000000000000001B',
|
||||
tli13['max-segno'])
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
# important - switchpoint may be NullOffset LSN and not actually existing in archive to boot.
|
||||
# so write validation code accordingly
|
||||
# so write WAL validation code accordingly
|
||||
|
||||
# change wal-seg-size
|
||||
#
|
||||
|
@ -766,8 +766,8 @@ class DeleteTest(ProbackupTest, unittest.TestCase):
|
||||
output)
|
||||
|
||||
self.assertIn(
|
||||
'On timeline 1 WAL segments between 0000000000000001 '
|
||||
'and 0000000000000003 can be removed',
|
||||
'On timeline 1 WAL segments between 000000010000000000000001 '
|
||||
'and 000000010000000000000003 can be removed',
|
||||
output)
|
||||
|
||||
self.assertEqual(len(self.show_pb(backup_dir, 'node')), 4)
|
||||
@ -791,8 +791,8 @@ class DeleteTest(ProbackupTest, unittest.TestCase):
|
||||
output)
|
||||
|
||||
self.assertIn(
|
||||
'On timeline 1 WAL segments between 0000000000000001 '
|
||||
'and 0000000000000003 will be removed',
|
||||
'On timeline 1 WAL segments between 000000010000000000000001 '
|
||||
'and 000000010000000000000003 will be removed',
|
||||
output)
|
||||
|
||||
self.assertEqual(len(self.show_pb(backup_dir, 'node')), 1)
|
||||
|
@ -63,10 +63,10 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
|
||||
if not wal_name.endswith(".backup"):
|
||||
|
||||
if self.archive_compress:
|
||||
wal_name = wal_name[-19:]
|
||||
wal_name = wal_name[-27:]
|
||||
wal_name = wal_name[:-3]
|
||||
else:
|
||||
wal_name = wal_name[-16:]
|
||||
wal_name = wal_name[-24:]
|
||||
|
||||
self.assertTrue(wal_name >= min_wal)
|
||||
self.assertTrue(wal_name <= max_wal)
|
||||
@ -2234,8 +2234,8 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
|
||||
'--log-level-console=verbose'])
|
||||
|
||||
self.assertIn(
|
||||
'INFO: On timeline 4 WAL segments between 0000000000000002 '
|
||||
'and 0000000000000006 can be removed',
|
||||
'INFO: On timeline 4 WAL segments between 000000040000000000000002 '
|
||||
'and 000000040000000000000006 can be removed',
|
||||
output)
|
||||
|
||||
self.assertIn(
|
||||
@ -2259,8 +2259,8 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
|
||||
options=['--delete-wal', '--log-level-console=verbose'])
|
||||
|
||||
self.assertIn(
|
||||
'INFO: On timeline 4 WAL segments between 0000000000000002 '
|
||||
'and 0000000000000006 will be removed',
|
||||
'INFO: On timeline 4 WAL segments between 000000040000000000000002 '
|
||||
'and 000000040000000000000006 will be removed',
|
||||
output)
|
||||
|
||||
self.assertIn(
|
||||
@ -2281,11 +2281,11 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
self.assertEqual(
|
||||
show_tli4_before['min-segno'],
|
||||
'0000000000000002')
|
||||
'000000040000000000000002')
|
||||
|
||||
self.assertEqual(
|
||||
show_tli4_after['min-segno'],
|
||||
'0000000000000006')
|
||||
'000000040000000000000006')
|
||||
|
||||
self.assertFalse(show_tli5_after)
|
||||
|
||||
@ -2461,8 +2461,8 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
self.assertIn(
|
||||
'LOG: Archive backup {0} to stay consistent protect from '
|
||||
'purge WAL interval between 0000000000000004 and 0000000000000004 '
|
||||
'on timeline 1'.format(B1), output)
|
||||
'purge WAL interval between 000000010000000000000004 '
|
||||
'and 000000010000000000000004 on timeline 1'.format(B1), output)
|
||||
|
||||
start_lsn_B4 = self.show_pb(backup_dir, 'node', B4)['start-lsn']
|
||||
self.assertIn(
|
||||
@ -2471,13 +2471,13 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
self.assertIn(
|
||||
'LOG: Timeline 3 to stay reachable from timeline 1 protect '
|
||||
'from purge WAL interval between 0000000000000005 and '
|
||||
'0000000000000008 on timeline 2', output)
|
||||
'from purge WAL interval between 000000020000000000000005 and '
|
||||
'000000020000000000000008 on timeline 2', output)
|
||||
|
||||
self.assertIn(
|
||||
'LOG: Timeline 3 to stay reachable from timeline 1 protect '
|
||||
'from purge WAL interval between 0000000000000004 and '
|
||||
'0000000000000005 on timeline 1', output)
|
||||
'from purge WAL interval between 000000010000000000000004 and '
|
||||
'000000010000000000000005 on timeline 1', output)
|
||||
|
||||
show_tli1_before = self.show_archive(backup_dir, 'node', tli=1)
|
||||
show_tli2_before = self.show_archive(backup_dir, 'node', tli=2)
|
||||
@ -2509,11 +2509,11 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
self.assertEqual(
|
||||
show_tli4_before['min-segno'],
|
||||
'0000000000000002')
|
||||
'000000040000000000000002')
|
||||
|
||||
self.assertEqual(
|
||||
show_tli4_after['min-segno'],
|
||||
'0000000000000006')
|
||||
'000000040000000000000006')
|
||||
|
||||
self.assertFalse(show_tli5_after)
|
||||
|
||||
@ -2528,19 +2528,19 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
self.assertEqual(
|
||||
show_tli1_after['lost-segments'][0]['begin-segno'],
|
||||
'0000000000000006')
|
||||
'000000010000000000000006')
|
||||
|
||||
self.assertEqual(
|
||||
show_tli1_after['lost-segments'][0]['end-segno'],
|
||||
'0000000000000009')
|
||||
'000000010000000000000009')
|
||||
|
||||
self.assertEqual(
|
||||
show_tli2_after['lost-segments'][0]['begin-segno'],
|
||||
'0000000000000009')
|
||||
'000000020000000000000009')
|
||||
|
||||
self.assertEqual(
|
||||
show_tli2_after['lost-segments'][0]['end-segno'],
|
||||
'0000000000000009')
|
||||
'000000020000000000000009')
|
||||
|
||||
self.validate_pb(backup_dir, 'node')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user