@@ -1455,3 +1455,101 @@ def test_config_exclusion(self):
1455
1455
dst_pg .stop ()
1456
1456
#self.assertEqual(1, 0, 'Stop test')
1457
1457
self .del_test_dir (module_name , self .fname )
1458
+
1459
+ def test_dry_run_catchup_full (self ):
1460
+ """
1461
+ Test dry-run option for full catchup
1462
+ """
1463
+ # preparation 1: source
1464
+ src_pg = self .make_simple_node (
1465
+ base_dir = os .path .join (module_name , self .fname , 'src' ),
1466
+ set_replication = True ,
1467
+ pg_options = { 'wal_log_hints' : 'on' }
1468
+ )
1469
+ src_pg .slow_start ()
1470
+ src_pg .safe_psql (
1471
+ "postgres" ,
1472
+ "CREATE TABLE ultimate_question(answer int)" )
1473
+
1474
+ # preparation 2: make clean shutdowned lagging behind replica
1475
+ dst_pg = self .make_empty_node (os .path .join (module_name , self .fname , 'dst' ))
1476
+
1477
+ # save the condition before dry-run
1478
+ dst_before = dst_pg .data_dir
1479
+
1480
+ # do full catchup
1481
+ self .catchup_node (
1482
+ backup_mode = 'FULL' ,
1483
+ source_pgdata = src_pg .data_dir ,
1484
+ destination_node = dst_pg ,
1485
+ options = ['-d' , 'postgres' , '-p' , str (src_pg .port ), '--stream' , '--dry-run' ]
1486
+ )
1487
+
1488
+ # compare data dirs before and after cathup
1489
+ self .compare_pgdata (
1490
+ self .pgdata_content (dst_before ),
1491
+ self .pgdata_content (dst_pg .data_dir )
1492
+ )
1493
+
1494
+ # compare data dirs before and after cathup
1495
+ # self.compare_pgdata(
1496
+ # self.pgdata_content(dst_before),
1497
+ # self.pgdata_content(dst_pg.data_dir)
1498
+ # )
1499
+
1500
+ # Cleanup
1501
+ src_pg .stop ()
1502
+
1503
+ def test_dry_run_catchup_ptrack (self ):
1504
+ """
1505
+ Test dry-run option for catchup in incremental mode
1506
+ """
1507
+ if not self .ptrack :
1508
+ return unittest .skip ('Skipped because ptrack support is disabled' )
1509
+
1510
+ # preparation 1: source
1511
+ src_pg = self .make_simple_node (
1512
+ base_dir = os .path .join (module_name , self .fname , 'src' ),
1513
+ set_replication = True ,
1514
+ pg_options = { 'wal_log_hints' : 'on' }
1515
+ )
1516
+ src_pg .slow_start ()
1517
+ src_pg .safe_psql (
1518
+ "postgres" ,
1519
+ "CREATE TABLE ultimate_question(answer int)" )
1520
+
1521
+ # preparation 2: make clean shutdowned lagging behind replica
1522
+ dst_pg = self .make_empty_node (os .path .join (module_name , self .fname , 'dst' ))
1523
+ self .catchup_node (
1524
+ backup_mode = 'FULL' ,
1525
+ source_pgdata = src_pg .data_dir ,
1526
+ destination_node = dst_pg ,
1527
+ options = ['-d' , 'postgres' , '-p' , str (src_pg .port ), '--stream' ]
1528
+ )
1529
+ self .set_replica (src_pg , dst_pg )
1530
+ dst_options = {}
1531
+ dst_options ['port' ] = str (dst_pg .port )
1532
+ self .set_auto_conf (dst_pg , dst_options )
1533
+ dst_pg .slow_start (replica = True )
1534
+ dst_pg .stop ()
1535
+
1536
+ # save the condition before dry-run
1537
+ dst_before = dst_pg .data_dir
1538
+
1539
+ # do incremental catchup
1540
+ self .catchup_node (
1541
+ backup_mode = 'PTRACK' ,
1542
+ source_pgdata = src_pg .data_dir ,
1543
+ destination_node = dst_pg ,
1544
+ options = ['-d' , 'postgres' , '-p' , str (src_pg .port ), '--stream' , '--dry-run' ]
1545
+ )
1546
+
1547
+ # compare data dirs before and after cathup
1548
+ self .compare_pgdata (
1549
+ self .pgdata_content (dst_before ),
1550
+ self .pgdata_content (dst_pg .data_dir )
1551
+ )
1552
+
1553
+ # Cleanup
1554
+ src_pg .stop ()
1555
+
0 commit comments