33from .helpers .ptrack_helpers import ProbackupTest , ProbackupException
44from datetime import datetime , timedelta
55import subprocess
6+ from sys import exit
67
78
89module_name = 'validate'
@@ -114,6 +115,8 @@ def test_validate_corrupt_wal_1(self):
114115 self .set_archiving (backup_dir , 'node' , node )
115116 node .start ()
116117
118+ backup_id = self .backup_node (backup_dir , 'node' , node )
119+
117120 with node .connect ("postgres" ) as con :
118121 con .execute ("CREATE TABLE tbl0005 (a text)" )
119122 con .commit ()
@@ -137,8 +140,8 @@ def test_validate_corrupt_wal_1(self):
137140 self .assertEqual (1 , 0 , "Expecting Error because of wal segments corruption.\n Output: {0} \n CMD: {1}" .format (
138141 repr (self .output ), self .cmd ))
139142 except ProbackupException as e :
140- self .assertTrue ('Possible WAL CORRUPTION' in e .message ) ,
141- '\n Unexpected Error Message: {0}\n CMD: {1}' .format (repr (e .message ), self .cmd )
143+ self .assertTrue ('Possible WAL CORRUPTION' in e .message ,
144+ '\n Unexpected Error Message: {0}\n CMD: {1}' .format (repr (e .message ), self .cmd ))
142145
143146 self .assertEqual ('CORRUPT' , self .show_pb (backup_dir , 'node' , backup_id )['status' ], 'Backup STATUS should be "CORRUPT"' )
144147
@@ -255,7 +258,7 @@ def test_validate_wal_lost_segment_2(self):
255258 """
256259 make node with archiving
257260 make archive backup
258- delete from archive wal segment which DO NOT belong to previous backup
261+ delete from archive wal segment which DO NOT belong to this backup
259262 run validate, expecting error because of missing wal segment
260263 make sure that backup status is 'ERROR'
261264 """
@@ -285,16 +288,17 @@ def test_validate_wal_lost_segment_2(self):
285288 # delete last wal segment
286289 wals_dir = os .path .join (backup_dir , 'wal' , 'node' )
287290 wals = [f for f in os .listdir (wals_dir ) if os .path .isfile (os .path .join (wals_dir , f )) and not f .endswith ('.backup' )]
288- wals = map (int , wals )
289- file = os .path .join (wals_dir , '0000000' + str ( max (wals ) ))
291+ wals = map (str , wals )
292+ file = os .path .join (wals_dir , max (wals ))
290293 os .remove (file )
291-
294+ if self .archive_compress :
295+ file = file [:- 3 ]
292296 try :
293297 backup_id = self .backup_node (backup_dir , 'node' , node , backup_type = 'page' )
294298 self .assertEqual (1 , 0 , "Expecting Error because of wal segment disappearance.\n Output: {0} \n CMD: {1}" .format (
295299 self .output , self .cmd ))
296300 except ProbackupException as e :
297- self .assertTrue ('INFO: wait for LSN' in e .message
301+ self .assertTrue ('INFO: Wait for LSN' in e .message
298302 and 'in archived WAL segment' in e .message
299303 and 'WARNING: could not read WAL record at' in e .message
300304 and 'ERROR: WAL segment "{0}" is absent\n ' .format (file ) in e .message ,
@@ -303,7 +307,7 @@ def test_validate_wal_lost_segment_2(self):
303307 self .assertEqual ('ERROR' , self .show_pb (backup_dir , 'node' )[1 ]['Status' ], 'Backup {0} should have STATUS "ERROR"' )
304308
305309 # Clean after yourself
306- self .del_test_dir (module_name , fname )
310+ # self.del_test_dir(module_name, fname)
307311
308312 # @unittest.skip("skip")
309313 def test_pgpro702_688 (self ):
@@ -359,8 +363,7 @@ def test_pgpro688(self):
359363 # @unittest.skip("skip")
360364 # @unittest.expectedFailure
361365 def test_pgpro561 (self ):
362- """make node with archiving, make stream backup, restore it to node1, check that archiving is not successful on node1
363- """
366+ """make node with archiving, make stream backup, restore it to node1, check that archiving is not successful on node1"""
364367 fname = self .id ().split ('.' )[3 ]
365368 node1 = self .make_simple_node (base_dir = "{0}/{1}/node1" .format (module_name , fname ),
366369 set_replication = True ,
0 commit comments