@@ -529,13 +529,13 @@ def test_incr_lsn_restore(self):
529529 self .del_test_dir (module_name , fname )
530530
531531 # @unittest.skip("skip")
532- def test_incr_shift_sanity (self ):
532+ def test_incr_lsn_sanity (self ):
533533 """
534534 /----A-----B
535535 F------*--------X
536536
537537 X - is instance, we want to return it to state B.
538- fail is expected behaviour in case of shift restore.
538+ fail is expected behaviour in case of lsn restore.
539539 """
540540 fname = self .id ().split ('.' )[3 ]
541541 node = self .make_simple_node (
@@ -583,7 +583,7 @@ def test_incr_shift_sanity(self):
583583 # we should die here because exception is what we expect to happen
584584 self .assertEqual (
585585 1 , 0 ,
586- "Expecting Error because incremental restore in shift mode is impossible\n "
586+ "Expecting Error because incremental restore in lsn mode is impossible\n "
587587 "Output: {0} \n CMD: {1}" .format (
588588 repr (self .output ), self .cmd ))
589589 except ProbackupException as e :
@@ -716,7 +716,7 @@ def test_incr_checksum_corruption_detection(self):
716716 self .del_test_dir (module_name , fname )
717717
718718 # @unittest.skip("skip")
719- def test_incr_shift_corruption_detection (self ):
719+ def test_incr_lsn_corruption_detection (self ):
720720 """
721721 check that corrupted page got detected and replaced
722722 """
@@ -846,7 +846,7 @@ def test_incr_restore_multiple_external(self):
846846
847847 # @unittest.skip("skip")
848848 # @unittest.expectedFailure
849- def test_incr_shift_restore_multiple_external (self ):
849+ def test_incr_lsn_restore_multiple_external (self ):
850850 """check that cmdline has priority over config"""
851851 fname = self .id ().split ('.' )[3 ]
852852 node = self .make_simple_node (
@@ -915,5 +915,196 @@ def test_incr_shift_restore_multiple_external(self):
915915 # Clean after yourself
916916 self .del_test_dir (module_name , fname )
917917
918+ # @unittest.skip("skip")
919+ # @unittest.expectedFailure
920+ def test_incr_lsn_restore_backward (self ):
921+ """
922+ """
923+ fname = self .id ().split ('.' )[3 ]
924+ node = self .make_simple_node (
925+ base_dir = os .path .join (module_name , fname , 'node' ),
926+ set_replication = True ,
927+ initdb_params = ['--data-checksums' ],
928+ pg_options = {'autovacuum' : 'off' , 'wal_log_hints' : 'on' , 'hot_standby' : 'on' })
929+
930+ backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
931+ self .init_pb (backup_dir )
932+ self .add_instance (backup_dir , 'node' , node )
933+ self .set_archiving (backup_dir , 'node' , node )
934+ node .slow_start ()
935+
936+ # FULL backup
937+ node .pgbench_init (scale = 2 )
938+ full_id = self .backup_node (
939+ backup_dir , 'node' , node ,
940+ backup_type = "full" , options = ["-j" , "4" ])
941+
942+ full_pgdata = self .pgdata_content (node .data_dir )
943+
944+ pgbench = node .pgbench (options = ['-T' , '10' , '-c' , '1' ])
945+ pgbench .wait ()
946+
947+ page_id = self .backup_node (
948+ backup_dir , 'node' , node ,
949+ backup_type = 'page' , options = ["-j" , "4" ])
950+
951+ page_pgdata = self .pgdata_content (node .data_dir )
952+
953+ pgbench = node .pgbench (options = ['-T' , '10' , '-c' , '1' ])
954+ pgbench .wait ()
955+
956+ delta_id = self .backup_node (
957+ backup_dir , 'node' , node ,
958+ backup_type = 'delta' , options = ["-j" , "4" ])
959+
960+ delta_pgdata = self .pgdata_content (node .data_dir )
961+
962+ pgbench = node .pgbench (options = ['-T' , '10' , '-c' , '1' ])
963+ pgbench .wait ()
964+
965+ node .stop ()
966+
967+ print (self .restore_node (
968+ backup_dir , 'node' , node , backup_id = full_id ,
969+ options = [
970+ "-j" , "4" , '--incremental-mode=lsn' ,
971+ '--recovery-target=immediate' , '--recovery-target-action=pause' ]))
972+
973+ pgdata_restored = self .pgdata_content (node .data_dir )
974+ self .compare_pgdata (full_pgdata , pgdata_restored )
975+
976+ node .slow_start (replica = True )
977+ node .stop ()
978+
979+ try :
980+ self .restore_node (
981+ backup_dir , 'node' , node , backup_id = page_id ,
982+ options = [
983+ "-j" , "4" , '--incremental-mode=lsn' ,
984+ '--recovery-target=immediate' , '--recovery-target-action=pause' ])
985+ # we should die here because exception is what we expect to happen
986+ self .assertEqual (
987+ 1 , 0 ,
988+ "Expecting Error because incremental restore in lsn mode is impossible\n "
989+ "Output: {0} \n CMD: {1}" .format (
990+ repr (self .output ), self .cmd ))
991+ except ProbackupException as e :
992+ self .assertIn (
993+ "Cannot perform incremental restore of backup chain" ,
994+ e .message ,
995+ '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
996+ repr (e .message ), self .cmd ))
997+
998+ self .restore_node (
999+ backup_dir , 'node' , node , backup_id = page_id ,
1000+ options = [
1001+ "-j" , "4" , '--incremental-mode=checksum' ,
1002+ '--recovery-target=immediate' , '--recovery-target-action=pause' ])
1003+
1004+ pgdata_restored = self .pgdata_content (node .data_dir )
1005+ self .compare_pgdata (page_pgdata , pgdata_restored )
1006+
1007+ node .slow_start (replica = True )
1008+ node .stop ()
1009+
1010+ print (self .restore_node (
1011+ backup_dir , 'node' , node , backup_id = delta_id ,
1012+ options = [
1013+ "-j" , "4" , '--incremental-mode=lsn' ,
1014+ '--recovery-target=immediate' , '--recovery-target-action=pause' ]))
1015+
1016+ pgdata_restored = self .pgdata_content (node .data_dir )
1017+ self .compare_pgdata (delta_pgdata , pgdata_restored )
1018+
1019+ # Clean after yourself
1020+ self .del_test_dir (module_name , fname )
1021+
1022+ # @unittest.skip("skip")
1023+ # @unittest.expectedFailure
1024+ def test_incr_checksum_restore_backward (self ):
1025+ """
1026+ """
1027+ fname = self .id ().split ('.' )[3 ]
1028+ node = self .make_simple_node (
1029+ base_dir = os .path .join (module_name , fname , 'node' ),
1030+ set_replication = True ,
1031+ initdb_params = ['--data-checksums' ],
1032+ pg_options = {
1033+ 'autovacuum' : 'off' ,
1034+ 'hot_standby' : 'on' })
1035+
1036+ backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
1037+ self .init_pb (backup_dir )
1038+ self .add_instance (backup_dir , 'node' , node )
1039+ self .set_archiving (backup_dir , 'node' , node )
1040+ node .slow_start ()
1041+
1042+ # FULL backup
1043+ node .pgbench_init (scale = 20 )
1044+ full_id = self .backup_node (
1045+ backup_dir , 'node' , node ,
1046+ backup_type = "full" , options = ["-j" , "4" ])
1047+
1048+ full_pgdata = self .pgdata_content (node .data_dir )
1049+
1050+ pgbench = node .pgbench (options = ['-T' , '10' , '-c' , '1' ])
1051+ pgbench .wait ()
1052+
1053+ page_id = self .backup_node (
1054+ backup_dir , 'node' , node ,
1055+ backup_type = 'page' , options = ["-j" , "4" ])
1056+
1057+ page_pgdata = self .pgdata_content (node .data_dir )
1058+
1059+ pgbench = node .pgbench (options = ['-T' , '10' , '-c' , '1' ])
1060+ pgbench .wait ()
1061+
1062+ delta_id = self .backup_node (
1063+ backup_dir , 'node' , node ,
1064+ backup_type = 'delta' , options = ["-j" , "4" ])
1065+
1066+ delta_pgdata = self .pgdata_content (node .data_dir )
1067+
1068+ pgbench = node .pgbench (options = ['-T' , '10' , '-c' , '1' ])
1069+ pgbench .wait ()
1070+
1071+ node .stop ()
1072+
1073+ print (self .restore_node (
1074+ backup_dir , 'node' , node , backup_id = full_id ,
1075+ options = [
1076+ "-j" , "4" , '--incremental-mode=checksum' ,
1077+ '--recovery-target=immediate' , '--recovery-target-action=pause' ]))
1078+
1079+ pgdata_restored = self .pgdata_content (node .data_dir )
1080+ self .compare_pgdata (full_pgdata , pgdata_restored )
1081+
1082+ node .slow_start (replica = True )
1083+ node .stop ()
1084+
1085+ print (self .restore_node (
1086+ backup_dir , 'node' , node , backup_id = page_id ,
1087+ options = [
1088+ "-j" , "4" , '--incremental-mode=checksum' ,
1089+ '--recovery-target=immediate' , '--recovery-target-action=pause' ]))
1090+
1091+ pgdata_restored = self .pgdata_content (node .data_dir )
1092+ self .compare_pgdata (page_pgdata , pgdata_restored )
1093+
1094+ node .slow_start (replica = True )
1095+ node .stop ()
1096+
1097+ print (self .restore_node (
1098+ backup_dir , 'node' , node , backup_id = delta_id ,
1099+ options = [
1100+ "-j" , "4" , '--incremental-mode=checksum' ,
1101+ '--recovery-target=immediate' , '--recovery-target-action=pause' ]))
1102+
1103+ pgdata_restored = self .pgdata_content (node .data_dir )
1104+ self .compare_pgdata (delta_pgdata , pgdata_restored )
1105+
1106+ # Clean after yourself
1107+ self .del_test_dir (module_name , fname )
1108+
9181109# check that MinRecPoint and BackupStartLsn are correctly used in case of --incrementa-lsn
9191110# incremental restore + partial restore.
0 commit comments