@@ -33,9 +33,14 @@ def test_restore_to_latest_1(self):
33
33
node .stop ({"-m" :"immediate" })
34
34
node .cleanup ()
35
35
36
+ # 1 - Test recovery from latest
36
37
self .assertIn (six .b ("INFO: restore complete" ),
37
38
self .restore_pb (node ,options = ["-j" ,"4" ,"--verbose" ]))
38
39
40
+ # 2 - Test that recovery.conf was created
41
+ recovery_conf = path .join (node .data_dir ,"recovery.conf" )
42
+ self .assertEqual (path .isfile (recovery_conf ),True )
43
+
39
44
node .start ({"-t" :"600" })
40
45
41
46
after = node .execute ("postgres" ,"SELECT * FROM pgbench_branches" )
@@ -556,3 +561,60 @@ def test_restore_with_tablespace_mapping_12(self):
556
561
self .assertEqual (id [0 ][0 ],2 )
557
562
558
563
node .stop ()
564
+
565
+ def test_restore_with_tablespace_mapping_13 (self ):
566
+ """recovery using tablespace-mapping option and page backup"""
567
+ node = self .make_bnode ('restore_with_tablespace_mapping_13' ,
568
+ base_dir = "tmp_dirs/restore/restore_with_tablespace_mapping_13" )
569
+ node .start ()
570
+ self .assertEqual (self .init_pb (node ),six .b ("" ))
571
+
572
+ # Full backup
573
+ self .backup_pb (node )
574
+ self .assertEqual (self .show_pb (node )[0 ].status ,six .b ("OK" ))
575
+
576
+ # Create tablespace
577
+ tblspc_path = path .join (node .base_dir ,"tblspc" )
578
+ os .makedirs (tblspc_path )
579
+ with node .connect ("postgres" )as con :
580
+ con .connection .autocommit = True
581
+ con .execute ("CREATE TABLESPACE tblspc LOCATION '%s'" % tblspc_path )
582
+ con .connection .autocommit = False
583
+ con .execute ("CREATE TABLE tbl AS SELECT * FROM generate_series(0,3) AS integer" )
584
+ con .commit ()
585
+
586
+ # First page backup
587
+ self .backup_pb (node ,backup_type = "page" )
588
+ self .assertEqual (self .show_pb (node )[1 ].status ,six .b ("OK" ))
589
+
590
+ # Create tablespace table
591
+ with node .connect ("postgres" )as con :
592
+ con .connection .autocommit = True
593
+ con .execute ("CHECKPOINT" )
594
+ con .connection .autocommit = False
595
+ con .execute ("CREATE TABLE tbl1 (a int) TABLESPACE tblspc" )
596
+ con .execute ("INSERT INTO tbl1 SELECT * FROM generate_series(0,3) AS integer" )
597
+ con .commit ()
598
+
599
+ # Second page backup
600
+ self .backup_pb (node ,backup_type = "page" )
601
+ self .assertEqual (self .show_pb (node )[2 ].status ,six .b ("OK" ))
602
+
603
+ node .stop ()
604
+ node .cleanup ()
605
+
606
+ tblspc_path_new = path .join (node .base_dir ,"tblspc_new" )
607
+ self .assertIn (six .b ("INFO: restore complete." ),
608
+ self .restore_pb (node ,
609
+ options = ["-T" ,"%s=%s" % (tblspc_path ,tblspc_path_new )]))
610
+
611
+ # Check tables
612
+ node .start ()
613
+
614
+ count = node .execute ("postgres" ,"SELECT count(*) FROM tbl" )
615
+ self .assertEqual (count [0 ][0 ],4 )
616
+
617
+ count = node .execute ("postgres" ,"SELECT count(*) FROM tbl1" )
618
+ self .assertEqual (count [0 ][0 ],4 )
619
+
620
+ node .stop ()