From 9235027bcfca33f781e8de3c4f680903ca46d9df Mon Sep 17 00:00:00 2001
From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Date: Tue, 31 Dec 2024 16:58:52 +0530
Subject: [PATCH 2/2] Don't run the test when testing cross-version setup

... per suggestion by Daniel Gustafsson. To be squashed into the first commit
before committing to head.
---
 src/bin/pg_upgrade/t/002_pg_upgrade.pl | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index a817ed0d00b..2ba325f0598 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -545,6 +545,17 @@ sub test_regression_dump_restore
 	my $dst_node = PostgreSQL::Test::Cluster->new('dst_node');
 	my %dump_formats = ('plain' => 'p', 'tar' => 't', 'directory' => 'd', 'custom' => 'c');
 
+	# Make sure that the source and destination nodes have same version and do
+	# not use custom install paths. In both the cases, the dump and restore test
+	# will mostly fail after utilizing the time and resources unnecessarily.
+	# Don't run the test in such a case.
+	if ($src_node->pg_version != $dst_node->pg_version or
+		defined $src_node->{_install_path})
+	{
+		fail("same version dump and restore test using default installation");
+		return;
+	}
+
 	# Dump the original database for comparison later.
 	my $src_dump = get_dump_for_comparison($src_node->connstr('regression'),
 		'src_dump', 1);
-- 
2.34.1

