@@ -1419,3 +1419,85 @@ def test_hidden_files(self):
1419
1419
1420
1420
# Clean after yourself
1421
1421
self .del_test_dir (module_name , fname )
1422
+
1423
+ # @unittest.skip("skip")
1424
+ def test_compatibility_tablespace (self ):
1425
+ """
1426
+ https://github.com/postgrespro/pg_probackup/issues/348
1427
+ """
1428
+ fname = self .id ().split ('.' )[3 ]
1429
+ node = self .make_simple_node (
1430
+ base_dir = os .path .join (module_name , fname , 'node' ),
1431
+ set_replication = True ,
1432
+ initdb_params = ['--data-checksums' ])
1433
+
1434
+ backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
1435
+
1436
+ self .init_pb (backup_dir )
1437
+ self .add_instance (backup_dir , 'node' , node , old_binary = True )
1438
+ node .slow_start ()
1439
+
1440
+ backup_id = self .backup_node (
1441
+ backup_dir , 'node' , node , backup_type = "full" ,
1442
+ options = ["-j" , "4" , "--stream" ], old_binary = True )
1443
+
1444
+ tblspace_old_path = self .get_tblspace_path (node , 'tblspace_old' )
1445
+
1446
+ self .create_tblspace_in_node (
1447
+ node , 'tblspace' ,
1448
+ tblspc_path = tblspace_old_path )
1449
+
1450
+ node .safe_psql (
1451
+ "postgres" ,
1452
+ "create table t_heap_lame tablespace tblspace "
1453
+ "as select 1 as id, md5(i::text) as text, "
1454
+ "md5(repeat(i::text,10))::tsvector as tsvector "
1455
+ "from generate_series(0,1000) i" )
1456
+
1457
+ tblspace_new_path = self .get_tblspace_path (node , 'tblspace_new' )
1458
+
1459
+ node_restored = self .make_simple_node (
1460
+ base_dir = os .path .join (module_name , fname , 'node_restored' ))
1461
+ node_restored .cleanup ()
1462
+
1463
+ try :
1464
+ self .restore_node (
1465
+ backup_dir , 'node' , node_restored ,
1466
+ options = [
1467
+ "-j" , "4" ,
1468
+ "-T" , "{0}={1}" .format (
1469
+ tblspace_old_path , tblspace_new_path )])
1470
+ # we should die here because exception is what we expect to happen
1471
+ self .assertEqual (
1472
+ 1 , 0 ,
1473
+ "Expecting Error because tablespace mapping is incorrect"
1474
+ "\n Output: {0} \n CMD: {1}" .format (
1475
+ repr (self .output ), self .cmd ))
1476
+ except ProbackupException as e :
1477
+ self .assertIn (
1478
+ 'ERROR: Backup {0} has no tablespaceses, '
1479
+ 'nothing to remap' .format (backup_id ),
1480
+ e .message ,
1481
+ '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
1482
+ repr (e .message ), self .cmd ))
1483
+
1484
+ self .backup_node (
1485
+ backup_dir , 'node' , node , backup_type = "delta" ,
1486
+ options = ["-j" , "4" , "--stream" ], old_binary = True )
1487
+
1488
+ self .restore_node (
1489
+ backup_dir , 'node' , node_restored ,
1490
+ options = [
1491
+ "-j" , "4" ,
1492
+ "-T" , "{0}={1}" .format (
1493
+ tblspace_old_path , tblspace_new_path )])
1494
+
1495
+ if self .paranoia :
1496
+ pgdata = self .pgdata_content (node .data_dir )
1497
+
1498
+ if self .paranoia :
1499
+ pgdata_restored = self .pgdata_content (node_restored .data_dir )
1500
+ self .compare_pgdata (pgdata , pgdata_restored )
1501
+
1502
+ # Clean after yourself
1503
+ self .del_test_dir (module_name , fname )
0 commit comments