@@ -4314,6 +4314,8 @@ def test_corrupt_ptrack_map(self):
4314
4314
"postgres" ,
4315
4315
"CREATE EXTENSION ptrack" )
4316
4316
4317
+ ptrack_version = self .get_ptrack_version (node )
4318
+
4317
4319
# Create table
4318
4320
node .safe_psql (
4319
4321
"postgres" ,
@@ -4338,48 +4340,55 @@ def test_corrupt_ptrack_map(self):
4338
4340
node .stop (['-m' , 'immediate' , '-D' , node .data_dir ])
4339
4341
4340
4342
ptrack_map = os .path .join (node .data_dir , 'global' , 'ptrack.map' )
4341
- ptrack_map_mmap = os .path .join (node .data_dir , 'global' , 'ptrack.map.mmap' )
4342
4343
4343
- # Let`s do index corruption. ptrack.map, ptrack.map.mmap
4344
+ # Let`s do index corruption. ptrack.map
4344
4345
with open (ptrack_map , "rb+" , 0 ) as f :
4345
4346
f .seek (42 )
4346
4347
f .write (b"blablahblahs" )
4347
4348
f .flush ()
4348
4349
f .close
4349
4350
4350
- with open (ptrack_map_mmap , "rb+" , 0 ) as f :
4351
- f .seek (42 )
4352
- f .write (b"blablahblahs" )
4353
- f .flush ()
4354
- f .close
4355
-
4356
4351
# os.remove(os.path.join(node.logs_dir, node.pg_log_name))
4357
4352
4358
- try :
4353
+ if self .verbose :
4354
+ print ('Ptrack version:' , ptrack_version )
4355
+ if ptrack_version >= self .version_to_num ("2.3" ):
4359
4356
node .slow_start ()
4360
- # we should die here because exception is what we expect to happen
4361
- self .assertEqual (
4362
- 1 , 0 ,
4363
- "Expecting Error because ptrack.map is corrupted"
4364
- "\n Output: {0} \n CMD: {1}" .format (
4365
- repr (self .output ), self .cmd ))
4366
- except StartNodeException as e :
4357
+
4358
+ log_file = os .path .join (node .logs_dir , 'postgresql.log' )
4359
+ with open (log_file , 'r' ) as f :
4360
+ log_content = f .read ()
4361
+
4367
4362
self .assertIn (
4368
- 'Cannot start node' ,
4369
- e .message ,
4370
- '\n Unexpected Error Message: {0}\n '
4371
- ' CMD: {1}' .format (repr (e .message ), self .cmd ))
4363
+ 'WARNING: ptrack read map: incorrect checksum of file "{0}"' .format (ptrack_map ),
4364
+ log_content )
4372
4365
4373
- log_file = os .path .join (node .logs_dir , 'postgresql.log' )
4374
- with open (log_file , 'r' ) as f :
4375
- log_content = f .read ()
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 ()
4376
4386
4377
- self .assertIn (
4378
- 'FATAL: ptrack init: incorrect checksum of file "{0}"' .format (ptrack_map ),
4379
- log_content )
4387
+ self .assertIn (
4388
+ 'FATAL: ptrack init: incorrect checksum of file "{0}"' .format (ptrack_map ),
4389
+ log_content )
4380
4390
4381
4391
self .set_auto_conf (node , {'ptrack.map_size' : '0' })
4382
-
4383
4392
node .slow_start ()
4384
4393
4385
4394
try :
0 commit comments