@@ -3920,3 +3920,59 @@ def test_restore_issue_313(self):
3920
3920
3921
3921
# Clean after yourself
3922
3922
self .del_test_dir (module_name , fname )
3923
+
3924
+ # @unittest.skip("skip")
3925
+ def test_restore_with_waldir (self ):
3926
+ """recovery using tablespace-mapping option and page backup"""
3927
+ fname = self .id ().split ('.' )[3 ]
3928
+ node = self .make_simple_node (
3929
+ base_dir = os .path .join (module_name , fname , 'node' ),
3930
+ initdb_params = ['--data-checksums' ])
3931
+
3932
+ backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
3933
+ self .init_pb (backup_dir )
3934
+ self .add_instance (backup_dir , 'node' , node )
3935
+ self .set_archiving (backup_dir , 'node' , node )
3936
+ node .slow_start ()
3937
+
3938
+
3939
+ with node .connect ("postgres" ) as con :
3940
+ con .execute (
3941
+ "CREATE TABLE tbl AS SELECT * "
3942
+ "FROM generate_series(0,3) AS integer" )
3943
+ con .commit ()
3944
+
3945
+ # Full backup
3946
+ backup_id = self .backup_node (backup_dir , 'node' , node )
3947
+
3948
+ node .stop ()
3949
+ node .cleanup ()
3950
+
3951
+ # Create waldir
3952
+ waldir_path = os .path .join (node .base_dir , "waldir" )
3953
+ os .makedirs (waldir_path )
3954
+
3955
+ # Test recovery from latest
3956
+ self .assertIn (
3957
+ "INFO: Restore of backup {0} completed." .format (backup_id ),
3958
+ self .restore_node (
3959
+ backup_dir , 'node' , node ,
3960
+ options = [
3961
+ "-X" , "%s" % (waldir_path )]),
3962
+ '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
3963
+ repr (self .output ), self .cmd ))
3964
+ node .slow_start ()
3965
+
3966
+ count = node .execute ("postgres" , "SELECT count(*) FROM tbl" )
3967
+ self .assertEqual (count [0 ][0 ], 4 )
3968
+
3969
+ # check pg_wal is symlink
3970
+ if node .major_version >= 10 :
3971
+ wal_path = os .path .join (node .data_dir , "pg_wal" )
3972
+ else :
3973
+ wal_path = os .path .join (node .data_dir , "pg_xlog" )
3974
+
3975
+ self .assertEqual (os .path .islink (wal_path ), True )
3976
+
3977
+ # Clean after yourself
3978
+ self .del_test_dir (module_name , fname )
0 commit comments