mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +03:00
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
This commit is contained in:
@ -9,6 +9,11 @@ use Test::More;
|
|||||||
|
|
||||||
my $tempdir = PostgreSQL::Test::Utils::tempdir_short();
|
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.
|
# Set up a new database instance.
|
||||||
my $primary = PostgreSQL::Test::Cluster->new('primary');
|
my $primary = PostgreSQL::Test::Cluster->new('primary');
|
||||||
$primary->init(has_archiving => 1, allows_streaming => 1);
|
$primary->init(has_archiving => 1, allows_streaming => 1);
|
||||||
@ -134,7 +139,8 @@ $pitr2->init_from_backup(
|
|||||||
standby => 1,
|
standby => 1,
|
||||||
has_restoring => 1,
|
has_restoring => 1,
|
||||||
combine_with_prior => ['backup1'],
|
combine_with_prior => ['backup1'],
|
||||||
tablespace_map => { $tsbackup2path => $tspitr2path });
|
tablespace_map => { $tsbackup2path => $tspitr2path },
|
||||||
|
combine_mode => $mode);
|
||||||
$pitr2->append_conf(
|
$pitr2->append_conf(
|
||||||
'postgresql.conf', qq{
|
'postgresql.conf', qq{
|
||||||
recovery_target_lsn = '$lsn'
|
recovery_target_lsn = '$lsn'
|
||||||
|
@ -10,6 +10,11 @@ use PostgreSQL::Test::Cluster;
|
|||||||
use PostgreSQL::Test::Utils;
|
use PostgreSQL::Test::Utils;
|
||||||
use Test::More;
|
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.
|
# Set up a new database instance.
|
||||||
my $node1 = PostgreSQL::Test::Cluster->new('node1');
|
my $node1 = PostgreSQL::Test::Cluster->new('node1');
|
||||||
$node1->init(has_archiving => 1, allows_streaming => 1);
|
$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.
|
# Restore the incremental backup and use it to create a new node.
|
||||||
my $node3 = PostgreSQL::Test::Cluster->new('node3');
|
my $node3 = PostgreSQL::Test::Cluster->new('node3');
|
||||||
$node3->init_from_backup($node1, 'backup3',
|
$node3->init_from_backup($node1, 'backup3',
|
||||||
combine_with_prior => [ 'backup1', 'backup2' ]);
|
combine_with_prior => [ 'backup1', 'backup2' ],
|
||||||
|
combine_mode => $mode);
|
||||||
$node3->start();
|
$node3->start();
|
||||||
|
|
||||||
# Let's insert one more row.
|
# Let's insert one more row.
|
||||||
|
@ -12,6 +12,11 @@ use PostgreSQL::Test::Cluster;
|
|||||||
use PostgreSQL::Test::Utils;
|
use PostgreSQL::Test::Utils;
|
||||||
use Test::More;
|
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.
|
# Set up a new database instance.
|
||||||
my $node = PostgreSQL::Test::Cluster->new('node');
|
my $node = PostgreSQL::Test::Cluster->new('node');
|
||||||
$node->init(has_archiving => 1, allows_streaming => 1);
|
$node->init(has_archiving => 1, allows_streaming => 1);
|
||||||
@ -53,9 +58,9 @@ sub combine_and_test_one_backup
|
|||||||
combine_and_test_one_backup('nomanifest',
|
combine_and_test_one_backup('nomanifest',
|
||||||
qr/could not open file.*backup_manifest/,
|
qr/could not open file.*backup_manifest/,
|
||||||
'--no-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',
|
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.
|
# Verify that SHA224 is mentioned in the SHA224 manifest lots of times.
|
||||||
my $sha224_manifest =
|
my $sha224_manifest =
|
||||||
|
@ -13,6 +13,11 @@ use PostgreSQL::Test::Cluster;
|
|||||||
use PostgreSQL::Test::Utils;
|
use PostgreSQL::Test::Utils;
|
||||||
use Test::More;
|
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.
|
# Set up a new database instance.
|
||||||
my $node1 = PostgreSQL::Test::Cluster->new('node1');
|
my $node1 = PostgreSQL::Test::Cluster->new('node1');
|
||||||
$node1->init(has_archiving => 1, allows_streaming => 1);
|
$node1->init(has_archiving => 1, allows_streaming => 1);
|
||||||
@ -79,13 +84,13 @@ my $resultpath = $node1->backup_dir . '/result';
|
|||||||
|
|
||||||
# Can't combine 2 full backups.
|
# Can't combine 2 full backups.
|
||||||
$node1->command_fails_like(
|
$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/,
|
qr/is a full backup, but only the first backup should be a full backup/,
|
||||||
"can't combine full backups");
|
"can't combine full backups");
|
||||||
|
|
||||||
# Can't combine 2 incremental backups.
|
# Can't combine 2 incremental backups.
|
||||||
$node1->command_fails_like(
|
$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/,
|
qr/is an incremental backup, but the first backup should be a full backup/,
|
||||||
"can't combine full backups");
|
"can't combine full backups");
|
||||||
|
|
||||||
@ -93,7 +98,7 @@ $node1->command_fails_like(
|
|||||||
$node1->command_fails_like(
|
$node1->command_fails_like(
|
||||||
[
|
[
|
||||||
'pg_combinebackup', $backup1path, $backupother2path, '-o',
|
'pg_combinebackup', $backup1path, $backupother2path, '-o',
|
||||||
$resultpath
|
$resultpath, $mode
|
||||||
],
|
],
|
||||||
qr/expected system identifier.*but found/,
|
qr/expected system identifier.*but found/,
|
||||||
"can't combine backups from different nodes");
|
"can't combine backups from different nodes");
|
||||||
@ -106,7 +111,7 @@ copy("$backupother2path/backup_manifest", "$backup2path/backup_manifest")
|
|||||||
$node1->command_fails_like(
|
$node1->command_fails_like(
|
||||||
[
|
[
|
||||||
'pg_combinebackup', $backup1path, $backup2path, $backup3path,
|
'pg_combinebackup', $backup1path, $backup2path, $backup3path,
|
||||||
'-o', $resultpath
|
'-o', $resultpath, $mode
|
||||||
],
|
],
|
||||||
qr/ manifest system identifier is .*, but control file has /,
|
qr/ manifest system identifier is .*, but control file has /,
|
||||||
"can't combine backups with different manifest system identifier ");
|
"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.
|
# Can't omit a required backup.
|
||||||
$node1->command_fails_like(
|
$node1->command_fails_like(
|
||||||
[ 'pg_combinebackup', $backup1path, $backup3path, '-o', $resultpath ],
|
[ 'pg_combinebackup', $backup1path, $backup3path, '-o', $resultpath, $mode ],
|
||||||
qr/starts at LSN.*but expected/,
|
qr/starts at LSN.*but expected/,
|
||||||
"can't omit a required backup");
|
"can't omit a required backup");
|
||||||
|
|
||||||
@ -124,7 +129,7 @@ $node1->command_fails_like(
|
|||||||
$node1->command_fails_like(
|
$node1->command_fails_like(
|
||||||
[
|
[
|
||||||
'pg_combinebackup', $backup1path, $backup3path, $backup2path,
|
'pg_combinebackup', $backup1path, $backup3path, $backup2path,
|
||||||
'-o', $resultpath
|
'-o', $resultpath, $mode
|
||||||
],
|
],
|
||||||
qr/starts at LSN.*but expected/,
|
qr/starts at LSN.*but expected/,
|
||||||
"can't combine backups in the wrong order");
|
"can't combine backups in the wrong order");
|
||||||
@ -133,7 +138,7 @@ $node1->command_fails_like(
|
|||||||
$node1->command_ok(
|
$node1->command_ok(
|
||||||
[
|
[
|
||||||
'pg_combinebackup', $backup1path, $backup2path, $backup3path,
|
'pg_combinebackup', $backup1path, $backup2path, $backup3path,
|
||||||
'-o', $resultpath
|
'-o', $resultpath, $mode
|
||||||
],
|
],
|
||||||
"can combine 3 matching backups");
|
"can combine 3 matching backups");
|
||||||
rmtree($resultpath);
|
rmtree($resultpath);
|
||||||
@ -143,19 +148,19 @@ my $synthetic12path = $node1->backup_dir . '/synthetic12';
|
|||||||
$node1->command_ok(
|
$node1->command_ok(
|
||||||
[
|
[
|
||||||
'pg_combinebackup', $backup1path, $backup2path, '-o',
|
'pg_combinebackup', $backup1path, $backup2path, '-o',
|
||||||
$synthetic12path
|
$synthetic12path, $mode
|
||||||
],
|
],
|
||||||
"can combine 2 matching backups");
|
"can combine 2 matching backups");
|
||||||
|
|
||||||
# Can combine result of previous step with second incremental.
|
# Can combine result of previous step with second incremental.
|
||||||
$node1->command_ok(
|
$node1->command_ok(
|
||||||
[ 'pg_combinebackup', $synthetic12path, $backup3path, '-o', $resultpath ],
|
[ 'pg_combinebackup', $synthetic12path, $backup3path, '-o', $resultpath, $mode ],
|
||||||
"can combine synthetic backup with later incremental");
|
"can combine synthetic backup with later incremental");
|
||||||
rmtree($resultpath);
|
rmtree($resultpath);
|
||||||
|
|
||||||
# Can't combine result of 1+2 with 2.
|
# Can't combine result of 1+2 with 2.
|
||||||
$node1->command_fails_like(
|
$node1->command_fails_like(
|
||||||
[ 'pg_combinebackup', $synthetic12path, $backup2path, '-o', $resultpath ],
|
[ 'pg_combinebackup', $synthetic12path, $backup2path, '-o', $resultpath, $mode ],
|
||||||
qr/starts at LSN.*but expected/,
|
qr/starts at LSN.*but expected/,
|
||||||
"can't combine synthetic backup with included incremental");
|
"can't combine synthetic backup with included incremental");
|
||||||
|
|
||||||
|
@ -7,6 +7,11 @@ use PostgreSQL::Test::Cluster;
|
|||||||
use PostgreSQL::Test::Utils;
|
use PostgreSQL::Test::Utils;
|
||||||
use Test::More;
|
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.
|
# Set up a new database instance.
|
||||||
my $primary = PostgreSQL::Test::Cluster->new('primary');
|
my $primary = PostgreSQL::Test::Cluster->new('primary');
|
||||||
$primary->init(has_archiving => 1, allows_streaming => 1);
|
$primary->init(has_archiving => 1, allows_streaming => 1);
|
||||||
@ -45,7 +50,8 @@ $primary->command_ok(
|
|||||||
# Recover the incremental backup.
|
# Recover the incremental backup.
|
||||||
my $restore = PostgreSQL::Test::Cluster->new('restore');
|
my $restore = PostgreSQL::Test::Cluster->new('restore');
|
||||||
$restore->init_from_backup($primary, 'backup2',
|
$restore->init_from_backup($primary, 'backup2',
|
||||||
combine_with_prior => ['backup1']);
|
combine_with_prior => ['backup1'],
|
||||||
|
combine_mode => $mode);
|
||||||
$restore->start();
|
$restore->start();
|
||||||
|
|
||||||
# Query the DB.
|
# Query the DB.
|
||||||
|
@ -856,6 +856,11 @@ sub init_from_backup
|
|||||||
push @combineargs, "-T$olddir=$newdir";
|
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;
|
push @combineargs, @prior_backup_path, $backup_path, '-o', $data_path;
|
||||||
PostgreSQL::Test::Utils::system_or_bail(@combineargs);
|
PostgreSQL::Test::Utils::system_or_bail(@combineargs);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user