aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomas Vondra <tomas.vondra@postgresql.org>2024-06-30 19:26:12 +0200
committerTomas Vondra <tomas.vondra@postgresql.org>2024-06-30 20:53:39 +0200
commit35a7b288b975f8b13084307c4b610e3bed5ca046 (patch)
treebbc856518145225c90f1115086375ecee97c4018 /src
parenta9577bae6b5c88c6865597aacd33b93d1b17e497 (diff)
downloadpostgresql-35a7b288b975f8b13084307c4b610e3bed5ca046.tar.gz
postgresql-35a7b288b975f8b13084307c4b610e3bed5ca046.zip
Add PG_TEST_PG_COMBINEBACKUP_MODE
Introduces an environment variable PG_TEST_PG_COMBINEBACKUP_MODE, that determines copy mode used by pg_combinebackup in TAP tests. Defaults to "--copy" but may be set to "--clone" or "--copy-file-range" to use the alternative stategies. Reported-by: Peter Eisentraut Discussion: https://postgr.es/m/48da4a1f-ccd9-4988-9622-24f37b1de2b4%40eisentraut.org
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_combinebackup/t/002_compare_backups.pl8
-rw-r--r--src/bin/pg_combinebackup/t/003_timeline.pl8
-rw-r--r--src/bin/pg_combinebackup/t/004_manifest.pl9
-rw-r--r--src/bin/pg_combinebackup/t/005_integrity.pl25
-rw-r--r--src/bin/pg_combinebackup/t/006_db_file_copy.pl8
-rw-r--r--src/test/perl/PostgreSQL/Test/Cluster.pm5
6 files changed, 48 insertions, 15 deletions
diff --git a/src/bin/pg_combinebackup/t/002_compare_backups.pl b/src/bin/pg_combinebackup/t/002_compare_backups.pl
index f032959ef5c..63a0255de15 100644
--- a/src/bin/pg_combinebackup/t/002_compare_backups.pl
+++ b/src/bin/pg_combinebackup/t/002_compare_backups.pl
@@ -9,6 +9,11 @@ use Test::More;
my $tempdir = PostgreSQL::Test::Utils::tempdir_short();
+# Can be changed to test the other modes.
+my $mode = $ENV{PG_TEST_PG_COMBINEBACKUP_MODE} || '--copy';
+
+note "testing using mode $mode";
+
# Set up a new database instance.
my $primary = PostgreSQL::Test::Cluster->new('primary');
$primary->init(has_archiving => 1, allows_streaming => 1);
@@ -134,7 +139,8 @@ $pitr2->init_from_backup(
standby => 1,
has_restoring => 1,
combine_with_prior => ['backup1'],
- tablespace_map => { $tsbackup2path => $tspitr2path });
+ tablespace_map => { $tsbackup2path => $tspitr2path },
+ combine_mode => $mode);
$pitr2->append_conf(
'postgresql.conf', qq{
recovery_target_lsn = '$lsn'
diff --git a/src/bin/pg_combinebackup/t/003_timeline.pl b/src/bin/pg_combinebackup/t/003_timeline.pl
index 52eb642a392..83ab674a244 100644
--- a/src/bin/pg_combinebackup/t/003_timeline.pl
+++ b/src/bin/pg_combinebackup/t/003_timeline.pl
@@ -10,6 +10,11 @@ use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More;
+# Can be changed to test the other modes.
+my $mode = $ENV{PG_TEST_PG_COMBINEBACKUP_MODE} || '--copy';
+
+note "testing using mode $mode";
+
# Set up a new database instance.
my $node1 = PostgreSQL::Test::Cluster->new('node1');
$node1->init(has_archiving => 1, allows_streaming => 1);
@@ -68,7 +73,8 @@ $node2->command_ok(
# Restore the incremental backup and use it to create a new node.
my $node3 = PostgreSQL::Test::Cluster->new('node3');
$node3->init_from_backup($node1, 'backup3',
- combine_with_prior => [ 'backup1', 'backup2' ]);
+ combine_with_prior => [ 'backup1', 'backup2' ],
+ combine_mode => $mode);
$node3->start();
# Let's insert one more row.
diff --git a/src/bin/pg_combinebackup/t/004_manifest.pl b/src/bin/pg_combinebackup/t/004_manifest.pl
index 0df9fed73a8..6d475163ab9 100644
--- a/src/bin/pg_combinebackup/t/004_manifest.pl
+++ b/src/bin/pg_combinebackup/t/004_manifest.pl
@@ -12,6 +12,11 @@ use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More;
+# Can be changed to test the other modes.
+my $mode = $ENV{PG_TEST_PG_COMBINEBACKUP_MODE} || '--copy';
+
+note "testing using mode $mode";
+
# Set up a new database instance.
my $node = PostgreSQL::Test::Cluster->new('node');
$node->init(has_archiving => 1, allows_streaming => 1);
@@ -53,9 +58,9 @@ sub combine_and_test_one_backup
combine_and_test_one_backup('nomanifest',
qr/could not open file.*backup_manifest/,
'--no-manifest');
-combine_and_test_one_backup('csum_none', undef, '--manifest-checksums=NONE');
+combine_and_test_one_backup('csum_none', undef, '--manifest-checksums=NONE', $mode);
combine_and_test_one_backup('csum_sha224',
- undef, '--manifest-checksums=SHA224');
+ undef, '--manifest-checksums=SHA224', $mode);
# Verify that SHA224 is mentioned in the SHA224 manifest lots of times.
my $sha224_manifest =
diff --git a/src/bin/pg_combinebackup/t/005_integrity.pl b/src/bin/pg_combinebackup/t/005_integrity.pl
index 636c3cc1b14..3caed13f6ed 100644
--- a/src/bin/pg_combinebackup/t/005_integrity.pl
+++ b/src/bin/pg_combinebackup/t/005_integrity.pl
@@ -13,6 +13,11 @@ use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More;
+# Can be changed to test the other modes.
+my $mode = $ENV{PG_TEST_PG_COMBINEBACKUP_MODE} || '--copy';
+
+note "testing using mode $mode";
+
# Set up a new database instance.
my $node1 = PostgreSQL::Test::Cluster->new('node1');
$node1->init(has_archiving => 1, allows_streaming => 1);
@@ -79,13 +84,13 @@ my $resultpath = $node1->backup_dir . '/result';
# Can't combine 2 full backups.
$node1->command_fails_like(
- [ 'pg_combinebackup', $backup1path, $backup1path, '-o', $resultpath ],
+ [ 'pg_combinebackup', $backup1path, $backup1path, '-o', $resultpath, $mode ],
qr/is a full backup, but only the first backup should be a full backup/,
"can't combine full backups");
# Can't combine 2 incremental backups.
$node1->command_fails_like(
- [ 'pg_combinebackup', $backup2path, $backup2path, '-o', $resultpath ],
+ [ 'pg_combinebackup', $backup2path, $backup2path, '-o', $resultpath, $mode ],
qr/is an incremental backup, but the first backup should be a full backup/,
"can't combine full backups");
@@ -93,7 +98,7 @@ $node1->command_fails_like(
$node1->command_fails_like(
[
'pg_combinebackup', $backup1path, $backupother2path, '-o',
- $resultpath
+ $resultpath, $mode
],
qr/expected system identifier.*but found/,
"can't combine backups from different nodes");
@@ -106,7 +111,7 @@ copy("$backupother2path/backup_manifest", "$backup2path/backup_manifest")
$node1->command_fails_like(
[
'pg_combinebackup', $backup1path, $backup2path, $backup3path,
- '-o', $resultpath
+ '-o', $resultpath, $mode
],
qr/ manifest system identifier is .*, but control file has /,
"can't combine backups with different manifest system identifier ");
@@ -116,7 +121,7 @@ move("$backup2path/backup_manifest.orig", "$backup2path/backup_manifest")
# Can't omit a required backup.
$node1->command_fails_like(
- [ 'pg_combinebackup', $backup1path, $backup3path, '-o', $resultpath ],
+ [ 'pg_combinebackup', $backup1path, $backup3path, '-o', $resultpath, $mode ],
qr/starts at LSN.*but expected/,
"can't omit a required backup");
@@ -124,7 +129,7 @@ $node1->command_fails_like(
$node1->command_fails_like(
[
'pg_combinebackup', $backup1path, $backup3path, $backup2path,
- '-o', $resultpath
+ '-o', $resultpath, $mode
],
qr/starts at LSN.*but expected/,
"can't combine backups in the wrong order");
@@ -133,7 +138,7 @@ $node1->command_fails_like(
$node1->command_ok(
[
'pg_combinebackup', $backup1path, $backup2path, $backup3path,
- '-o', $resultpath
+ '-o', $resultpath, $mode
],
"can combine 3 matching backups");
rmtree($resultpath);
@@ -143,19 +148,19 @@ my $synthetic12path = $node1->backup_dir . '/synthetic12';
$node1->command_ok(
[
'pg_combinebackup', $backup1path, $backup2path, '-o',
- $synthetic12path
+ $synthetic12path, $mode
],
"can combine 2 matching backups");
# Can combine result of previous step with second incremental.
$node1->command_ok(
- [ 'pg_combinebackup', $synthetic12path, $backup3path, '-o', $resultpath ],
+ [ 'pg_combinebackup', $synthetic12path, $backup3path, '-o', $resultpath, $mode ],
"can combine synthetic backup with later incremental");
rmtree($resultpath);
# Can't combine result of 1+2 with 2.
$node1->command_fails_like(
- [ 'pg_combinebackup', $synthetic12path, $backup2path, '-o', $resultpath ],
+ [ 'pg_combinebackup', $synthetic12path, $backup2path, '-o', $resultpath, $mode ],
qr/starts at LSN.*but expected/,
"can't combine synthetic backup with included incremental");
diff --git a/src/bin/pg_combinebackup/t/006_db_file_copy.pl b/src/bin/pg_combinebackup/t/006_db_file_copy.pl
index d57b550af21..f44788e82bf 100644
--- a/src/bin/pg_combinebackup/t/006_db_file_copy.pl
+++ b/src/bin/pg_combinebackup/t/006_db_file_copy.pl
@@ -7,6 +7,11 @@ use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More;
+# Can be changed to test the other modes.
+my $mode = $ENV{PG_TEST_PG_COMBINEBACKUP_MODE} || '--copy';
+
+note "testing using mode $mode";
+
# Set up a new database instance.
my $primary = PostgreSQL::Test::Cluster->new('primary');
$primary->init(has_archiving => 1, allows_streaming => 1);
@@ -45,7 +50,8 @@ $primary->command_ok(
# Recover the incremental backup.
my $restore = PostgreSQL::Test::Cluster->new('restore');
$restore->init_from_backup($primary, 'backup2',
- combine_with_prior => ['backup1']);
+ combine_with_prior => ['backup1'],
+ combine_mode => $mode);
$restore->start();
# Query the DB.
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index 83f385a4870..0135c5a795c 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -856,6 +856,11 @@ sub init_from_backup
push @combineargs, "-T$olddir=$newdir";
}
}
+ # use the combine mode (clone/copy-file-range) if specified
+ if (defined $params{combine_mode})
+ {
+ push @combineargs, $params{combine_mode};
+ }
push @combineargs, @prior_backup_path, $backup_path, '-o', $data_path;
PostgreSQL::Test::Utils::system_or_bail(@combineargs);
}