From cd985dd1da8fb15223accad8978a6e1cf1989625 Mon Sep 17 00:00:00 2001
From: Khanna <Shubham.Khanna@fujitsu.com>
Date: Thu, 20 Mar 2025 09:39:07 +0530
Subject: [PATCH v16 2/2] Additional test cases

This patch contains the additional test cases related to the --all option.
---
 .../t/040_pg_createsubscriber.pl              | 45 ++++++++-----------
 1 file changed, 18 insertions(+), 27 deletions(-)

diff --git a/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl b/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl
index 1fe158995ab..b92e6d34727 100644
--- a/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl
+++ b/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl
@@ -371,41 +371,41 @@ command_ok(
 	],
 	'run pg_createsubscriber without --databases');
 
-# run pg_createsubscriber with '--database' and '--all' without '--dry-run'
-# and verify the failure
+# run pg_createsubscriber with '--all' and '--database' and verify the
+# failure
 command_fails_like(
 	[
 		'pg_createsubscriber',
 		'--verbose',
+		'--dry-run',
 		'--pgdata' => $node_s->data_dir,
 		'--publisher-server' => $node_p->connstr($db1),
 		'--socketdir' => $node_s->host,
 		'--subscriber-port' => $node_s->port,
-		'--database' => $db1,
 		'--all',
+		'--database' => $db1,
 	],
 	qr/--database cannot be used with --all/,
 	'fail if --database is used with --all');
 
-# run pg_createsubscriber with '--publication' and '--all' and verify
-# the failure
+# run pg_createsubscriber with '--database' and '--all' without '--dry-run'
+# and verify the failure
 command_fails_like(
 	[
 		'pg_createsubscriber',
 		'--verbose',
-		'--dry-run',
 		'--pgdata' => $node_s->data_dir,
 		'--publisher-server' => $node_p->connstr($db1),
 		'--socketdir' => $node_s->host,
 		'--subscriber-port' => $node_s->port,
+		'--database' => $db1,
 		'--all',
-		'--publication' => 'pub1',
 	],
-	qr/--publication cannot be used with --all/,
-	'fail if --publication is used with --all');
+	qr/--database cannot be used with --all/,
+	'fail if --database is used with --all');
 
-# run pg_createsubscriber with '--replication-slot' and '--all' and
-# verify the failure
+# run pg_createsubscriber with '--publication' and '--all' and verify
+# the failure
 command_fails_like(
 	[
 		'pg_createsubscriber',
@@ -415,28 +415,26 @@ command_fails_like(
 		'--publisher-server' => $node_p->connstr($db1),
 		'--socketdir' => $node_s->host,
 		'--subscriber-port' => $node_s->port,
-		'--replication-slot' => 'replslot1',
 		'--all',
+		'--publication' => 'pub1',
 	],
-	qr/--replication-slot cannot be used with --all/,
-	'fail if --replication-slot is used with --all');
+	qr/--publication cannot be used with --all/,
+	'fail if --publication is used with --all');
 
-# run pg_createsubscriber with '--subscription' and '--all' and
-# verify the failure
-command_fails_like(
+# run pg_createsubscriber with '--all' option
+command_ok(
 	[
 		'pg_createsubscriber',
 		'--verbose',
+		'--recovery-timeout' => $PostgreSQL::Test::Utils::timeout_default,
 		'--dry-run',
 		'--pgdata' => $node_s->data_dir,
 		'--publisher-server' => $node_p->connstr($db1),
 		'--socketdir' => $node_s->host,
 		'--subscriber-port' => $node_s->port,
 		'--all',
-		'--subscription' => 'sub1',
 	],
-	qr/--subscription cannot be used with --all/,
-	'fail if --subscription is used with --all');
+	'run pg_createsubscriber with --all');
 
 # Run pg_createsubscriber on node S.  --verbose is used twice
 # to show more information.
@@ -527,7 +525,6 @@ my $sysid_s = $node_s->safe_psql('postgres',
 ok($sysid_p != $sysid_s, 'system identifier was changed');
 
 # On node P create test tables
-$node_p->safe_psql('postgres', 'CREATE TABLE tbl1 (a text)');
 $node_p->safe_psql($db1, 'CREATE TABLE tbl2 (a text)');
 $node_p->safe_psql($db1, "INSERT INTO tbl2 VALUES('first row')");
 $node_p->safe_psql($db2, 'CREATE TABLE tbl3 (a text)');
@@ -578,7 +575,6 @@ is($result, '0', 'subscription is not created on template databases');
 
 # Verify logical replication works for all databases
 # Insert rows on node P
-$node_p->safe_psql('postgres', "INSERT INTO tbl1 VALUES('first row')");
 $node_p->safe_psql($db1, "INSERT INTO tbl2 VALUES('second row')");
 $node_p->safe_psql($db2, "INSERT INTO tbl3 VALUES('first row')");
 
@@ -592,11 +588,6 @@ my @subnames1 = split("\n", $result);
 # Wait subscriber to catch up
 $node_u->wait_for_subscription_sync($node_p, $subnames1[0]);
 $node_u->wait_for_subscription_sync($node_p, $subnames1[1]);
-$node_u->wait_for_subscription_sync($node_p, $subnames1[2]);
-
-# Check result in database 'postgres' of node U
-$result = $node_u->safe_psql('postgres', 'SELECT * FROM tbl1');
-is($result, qq(first row), "logical replication works in database postgres");
 
 # Check result in database $db1 of node U
 $result = $node_u->safe_psql($db1, 'SELECT * FROM tbl2');
-- 
2.41.0.windows.3

