Skip to content

Commit 48528cf

Browse files
committed
[PGPRO-5691] added test_corrupt_ptrack_map test compatibility with both version 2.2 and version 2.3 of ptrack
1 parent 75a221c commit 48528cf

File tree

1 file changed

+36
-8
lines changed

1 file changed

+36
-8
lines changed

tests/ptrack.py

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4314,6 +4314,8 @@ def test_corrupt_ptrack_map(self):
43144314
"postgres",
43154315
"CREATE EXTENSION ptrack")
43164316

4317+
ptrack_version = self.get_ptrack_version(node)
4318+
43174319
# Create table
43184320
node.safe_psql(
43194321
"postgres",
@@ -4348,17 +4350,43 @@ def test_corrupt_ptrack_map(self):
43484350

43494351
# os.remove(os.path.join(node.logs_dir, node.pg_log_name))
43504352

4351-
node.slow_start()
4353+
if self.verbose:
4354+
print('Ptrack version:', ptrack_version)
4355+
if ptrack_version >= self.version_to_num("2.3"):
4356+
node.slow_start()
43524357

4353-
log_file = os.path.join(node.logs_dir, 'postgresql.log')
4354-
with open(log_file, 'r') as f:
4355-
log_content = f.read()
4358+
log_file = os.path.join(node.logs_dir, 'postgresql.log')
4359+
with open(log_file, 'r') as f:
4360+
log_content = f.read()
43564361

4357-
self.assertIn(
4358-
'WARNING: ptrack read map: incorrect checksum of file "{0}"'.format(ptrack_map),
4359-
log_content)
4362+
self.assertIn(
4363+
'WARNING: ptrack read map: incorrect checksum of file "{0}"'.format(ptrack_map),
4364+
log_content)
43604365

4361-
node.stop(['-D', node.data_dir])
4366+
node.stop(['-D', node.data_dir])
4367+
else:
4368+
try:
4369+
node.slow_start()
4370+
# we should die here because exception is what we expect to happen
4371+
self.assertEqual(
4372+
1, 0,
4373+
"Expecting Error because ptrack.map is corrupted"
4374+
"\n Output: {0} \n CMD: {1}".format(
4375+
repr(self.output), self.cmd))
4376+
except StartNodeException as e:
4377+
self.assertIn(
4378+
'Cannot start node',
4379+
e.message,
4380+
'\n Unexpected Error Message: {0}\n'
4381+
' CMD: {1}'.format(repr(e.message), self.cmd))
4382+
4383+
log_file = os.path.join(node.logs_dir, 'postgresql.log')
4384+
with open(log_file, 'r') as f:
4385+
log_content = f.read()
4386+
4387+
self.assertIn(
4388+
'FATAL: ptrack init: incorrect checksum of file "{0}"'.format(ptrack_map),
4389+
log_content)
43624390

43634391
self.set_auto_conf(node, {'ptrack.map_size': '0'})
43644392
node.slow_start()

0 commit comments

Comments
 (0)