From 54976b5f5f838ccaaea5835afe78987267685e64 Mon Sep 17 00:00:00 2001
From: Maksim Michkov <m.michkov@arenadata.io>
Date: Tue, 2 Sep 2025 14:08:14 +0000
Subject: [PATCH] Tap test for minRecoveryPoint matching switchpoint

---
 src/bin/pg_rewind/t/010_target_is_ancestor.pl | 22 +++++--------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/src/bin/pg_rewind/t/010_target_is_ancestor.pl b/src/bin/pg_rewind/t/010_target_is_ancestor.pl
index 5f3940cb027..4bc1510305b 100644
--- a/src/bin/pg_rewind/t/010_target_is_ancestor.pl
+++ b/src/bin/pg_rewind/t/010_target_is_ancestor.pl
@@ -52,17 +52,8 @@ $orig_node->backup_fs_cold('backup_B');
 
 # Restore backup B to create Timeline 2
 my $node_2 = PostgreSQL::Test::Cluster->new('node_2');
-$node_2->init_from_backup($orig_node, 'backup_B', has_streaming => 1);
+$node_2->init_from_backup($orig_node, 'backup_B', has_restoring => 1, standby => 0);
 $node_2->start;
-$node_2->promote;
-$node_2->safe_psql('postgres', "INSERT INTO test_tab VALUES ('in node_2')");
-$node_2->stop;
-
-$orig_node->start;
-$orig_node->safe_psql('postgres',
-	"INSERT INTO test_tab VALUES ('this will be lost on rewind')");
-$orig_node->stop;
-$orig_node->backup_fs_cold('backup_C');
 
 my $source_node = $node_2;
 my $source_pgdata = $source_node->data_dir;
@@ -80,12 +71,14 @@ sub rewind_from_backup
 	# Keep a temporary postgresql.conf or it would be overwritten during the rewind.
 	copy("$target_pgdata/postgresql.conf", "$tmp_folder/postgresql.conf.tmp");
 
+	my $source_connstr = $source_node->connstr();
+
 	command_checks_all(
 		[
 			'pg_rewind',
 			"--debug",
 			"--no-sync",
-			"--source-pgdata=$source_pgdata",
+			"--source-server=$source_connstr",
 			"--target-pgdata=$target_pgdata"
 		],
 		0,
@@ -109,7 +102,6 @@ sub rewind_from_backup
 		'postgresql.conf', qq(
 primary_conninfo = '$node_2_connstr'
 ));
-	$node_2->start;
 	$target_node->set_standby_mode();
 	$target_node->start;
 
@@ -117,17 +109,13 @@ primary_conninfo = '$node_2_connstr'
 	my $result =
 	  $target_node->safe_psql('postgres', "SELECT * FROM test_tab");
 	is( $result, qq(at the beginning
-after backup A
-in node_2),
+after backup A),
 		"check query after rewind from $backup");
 	$target_node->stop;
 
 	$node_2->stop;
 }
 
-rewind_from_backup('backup_C',
-	[qr/pg_rewind: rewinding from last common checkpoint at .* on timeline 1/]);
-rewind_from_backup('backup_B', [qr/pg_rewind: no rewind required/]);
 rewind_from_backup('backup_A', [qr/pg_rewind: no rewind required/]);
 
 done_testing();
-- 
2.34.1

