v8-0001-Add-option-to-force-initdb-in-PostgreSQL-Test-Clu.patch
application/x-patch
Filename: v8-0001-Add-option-to-force-initdb-in-PostgreSQL-Test-Clu.patch
Type: application/x-patch
Part: 0
Patch
Format: format-patch
Series: patch v8-0001
Subject: Add option to force initdb in PostgreSQL::Test::Cluster:init()
| File | + | − |
|---|---|---|
| src/bin/pg_combinebackup/t/005_integrity.pl | 7 | 12 |
| src/test/perl/PostgreSQL/Test/Cluster.pm | 10 | 5 |
From 354014538b16579f005bd6f4ce771b1aa22b5e02 Mon Sep 17 00:00:00 2001
From: Amul Sul <amul.sul@enterprisedb.com>
Date: Thu, 15 Feb 2024 12:10:23 +0530
Subject: [PATCH v8 1/4] Add option to force initdb in
PostgreSQL::Test::Cluster:init()
---
src/bin/pg_combinebackup/t/005_integrity.pl | 19 +++++++------------
src/test/perl/PostgreSQL/Test/Cluster.pm | 15 ++++++++++-----
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/bin/pg_combinebackup/t/005_integrity.pl b/src/bin/pg_combinebackup/t/005_integrity.pl
index 3b445d0e30f..5d425209211 100644
--- a/src/bin/pg_combinebackup/t/005_integrity.pl
+++ b/src/bin/pg_combinebackup/t/005_integrity.pl
@@ -18,18 +18,13 @@ $node1->init(has_archiving => 1, allows_streaming => 1);
$node1->append_conf('postgresql.conf', 'summarize_wal = on');
$node1->start;
-# Set up another new database instance. We don't want to use the cached
-# INITDB_TEMPLATE for this, because we want it to be a separate cluster
-# with a different system ID.
-my $node2;
-{
- local $ENV{'INITDB_TEMPLATE'} = undef;
-
- $node2 = PostgreSQL::Test::Cluster->new('node2');
- $node2->init(has_archiving => 1, allows_streaming => 1);
- $node2->append_conf('postgresql.conf', 'summarize_wal = on');
- $node2->start;
-}
+# Set up another new database instance with force initdb option. We don't want
+# to initializing database system by copying initdb template for this, because
+# we want it to be a separate cluster with a different system ID.
+my $node2 = PostgreSQL::Test::Cluster->new('node2');
+$node2->init(force_initdb => 1, has_archiving => 1, allows_streaming => 1);
+$node2->append_conf('postgresql.conf', 'summarize_wal = on');
+$node2->start;
# Take a full backup from node1.
my $backup1path = $node1->backup_dir . '/backup1';
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index 07da74cf562..2b4f9a48365 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -495,6 +495,10 @@ a directory that's only accessible to the current user to ensure that.
On Windows, we use SSPI authentication to ensure the same (by pg_regress
--config-auth).
+force_initdb => 1 will force to initialized the cluster by initdb. Otherwise, if
+available and if there aren't any parameters, use a previously initdb'd cluster
+as a template by copying it.
+
WAL archiving can be enabled on this node by passing the keyword parameter
has_archiving => 1. This is disabled by default.
@@ -517,6 +521,7 @@ sub init
local %ENV = $self->_get_env();
+ $params{force_initdb} = 0 unless defined $params{force_initdb};
$params{allows_streaming} = 0 unless defined $params{allows_streaming};
$params{has_archiving} = 0 unless defined $params{has_archiving};
@@ -529,14 +534,14 @@ sub init
mkdir $self->backup_dir;
mkdir $self->archive_dir;
- # If available and if there aren't any parameters, use a previously
- # initdb'd cluster as a template by copying it. For a lot of tests, that's
- # substantially cheaper. Do so only if there aren't parameters, it doesn't
- # seem worth figuring out whether they affect compatibility.
+ # For a lot of tests, that's substantially cheaper to copy previously
+ # initdb'd cluster as a template. Do so only if force_initdb => 0, and there
+ # aren't parameters, it doesn't seem worth figuring out whether they affect
+ # compatibility.
#
# There's very similar code in pg_regress.c, but we can't easily
# deduplicate it until we require perl at build time.
- if (defined $params{extra} or !defined $ENV{INITDB_TEMPLATE})
+ if ($params{force_initdb} or defined $params{extra} or !defined $ENV{INITDB_TEMPLATE})
{
note("initializing database system by running initdb");
PostgreSQL::Test::Utils::system_or_bail('initdb', '-D', $pgdata, '-A',
--
2.18.0