[PGPRO-5691] added test_corrupt_ptrack_map test compatibility with both version 2.2 and version 2.3 of ptrack

This commit is contained in:
Mikhail A. Kulagin
2022-02-12 19:47:52 +03:00
parent 75a221c207
commit 48528cfd38
+36 -8
View File
@@ -4314,6 +4314,8 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
"postgres",
"CREATE EXTENSION ptrack")
ptrack_version = self.get_ptrack_version(node)
# Create table
node.safe_psql(
"postgres",
@@ -4348,17 +4350,43 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# os.remove(os.path.join(node.logs_dir, node.pg_log_name))
node.slow_start()
if self.verbose:
print('Ptrack version:', ptrack_version)
if ptrack_version >= self.version_to_num("2.3"):
node.slow_start()
log_file = os.path.join(node.logs_dir, 'postgresql.log')
with open(log_file, 'r') as f:
log_content = f.read()
log_file = os.path.join(node.logs_dir, 'postgresql.log')
with open(log_file, 'r') as f:
log_content = f.read()
self.assertIn(
'WARNING: ptrack read map: incorrect checksum of file "{0}"'.format(ptrack_map),
log_content)
self.assertIn(
'WARNING: ptrack read map: incorrect checksum of file "{0}"'.format(ptrack_map),
log_content)
node.stop(['-D', node.data_dir])
node.stop(['-D', node.data_dir])
else:
try:
node.slow_start()
# we should die here because exception is what we expect to happen
self.assertEqual(
1, 0,
"Expecting Error because ptrack.map is corrupted"
"\n Output: {0} \n CMD: {1}".format(
repr(self.output), self.cmd))
except StartNodeException as e:
self.assertIn(
'Cannot start node',
e.message,
'\n Unexpected Error Message: {0}\n'
' CMD: {1}'.format(repr(e.message), self.cmd))
log_file = os.path.join(node.logs_dir, 'postgresql.log')
with open(log_file, 'r') as f:
log_content = f.read()
self.assertIn(
'FATAL: ptrack init: incorrect checksum of file "{0}"'.format(ptrack_map),
log_content)
self.set_auto_conf(node, {'ptrack.map_size': '0'})
node.slow_start()