2016-12-23 15:22:59 +02:00
|
|
|
####################################################################################################################################
|
2017-06-20 00:55:00 +02:00
|
|
|
# Test All Commands On PostgreSQL Clusters
|
2016-12-23 15:22:59 +02:00
|
|
|
####################################################################################################################################
|
2017-06-20 00:55:00 +02:00
|
|
|
package pgBackRestTest::Module::Real::RealAllTest;
|
2017-05-12 22:43:04 +02:00
|
|
|
use parent 'pgBackRestTest::Env::HostEnvTest';
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Perl includes
|
|
|
|
####################################################################################################################################
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
|
|
|
|
use File::Basename qw(dirname);
|
|
|
|
|
2017-06-21 14:02:21 +02:00
|
|
|
use pgBackRest::Archive::Info;
|
2017-05-15 22:01:00 +02:00
|
|
|
use pgBackRest::Backup::Info;
|
2016-12-23 15:22:59 +02:00
|
|
|
use pgBackRest::Db;
|
|
|
|
use pgBackRest::DbVersion;
|
|
|
|
use pgBackRest::Common::Exception;
|
|
|
|
use pgBackRest::Common::Ini;
|
|
|
|
use pgBackRest::Common::Log;
|
|
|
|
use pgBackRest::Common::Wait;
|
|
|
|
use pgBackRest::Config::Config;
|
2017-04-03 16:42:55 +02:00
|
|
|
use pgBackRest::InfoCommon;
|
2016-12-23 15:22:59 +02:00
|
|
|
use pgBackRest::Manifest;
|
2017-06-09 23:51:41 +02:00
|
|
|
use pgBackRest::Protocol::Storage::Helper;
|
2016-12-23 15:22:59 +02:00
|
|
|
use pgBackRest::Version;
|
|
|
|
|
|
|
|
use pgBackRestTest::Common::ContainerTest;
|
|
|
|
use pgBackRestTest::Common::ExecuteTest;
|
|
|
|
use pgBackRestTest::Common::FileTest;
|
|
|
|
use pgBackRestTest::Common::RunTest;
|
2017-06-21 22:07:13 +02:00
|
|
|
use pgBackRestTest::Common::VmTest;
|
2017-05-12 22:43:04 +02:00
|
|
|
use pgBackRestTest::Env::Host::HostBaseTest;
|
|
|
|
use pgBackRestTest::Env::Host::HostBackupTest;
|
|
|
|
use pgBackRestTest::Env::Host::HostDbTest;
|
2017-06-21 22:07:13 +02:00
|
|
|
use pgBackRestTest::Env::HostEnvTest;
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# run
|
|
|
|
####################################################################################################################################
|
|
|
|
sub run
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
2017-06-12 16:52:32 +02:00
|
|
|
foreach my $bS3 (false, true)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
2017-06-12 16:52:32 +02:00
|
|
|
foreach my $bHostBackup ($bS3 ? (true) : (false, true))
|
|
|
|
{
|
2017-06-21 22:07:13 +02:00
|
|
|
# Standby should only be tested for pg versions that support it
|
2017-06-12 16:52:32 +02:00
|
|
|
foreach my $bHostStandby ($bS3 ? (false) : (false, true))
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
2017-06-21 22:07:13 +02:00
|
|
|
# Master and standby backup destinations on need to be tested on one db version since it is not version specific
|
2016-12-23 15:22:59 +02:00
|
|
|
foreach my $strBackupDestination (
|
2017-06-12 16:52:32 +02:00
|
|
|
$bS3 || $bHostBackup ? (HOST_BACKUP) : $bHostStandby ? (HOST_DB_MASTER, HOST_DB_STANDBY) : (HOST_DB_MASTER))
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
2017-06-21 22:07:13 +02:00
|
|
|
my $bCompress = $bHostBackup && !$bHostStandby;
|
|
|
|
|
2016-12-23 15:22:59 +02:00
|
|
|
# Increment the run, log, and decide whether this unit test should be run
|
|
|
|
next if (!$self->begin(
|
2017-06-21 22:07:13 +02:00
|
|
|
"bkp ${bHostBackup}, sby ${bHostStandby}, dst ${strBackupDestination}, cmp ${bCompress}, s3 ${bS3}",
|
2017-06-22 01:21:16 +02:00
|
|
|
$self->pgVersion() eq PG_VERSION_96));
|
2017-06-21 22:07:13 +02:00
|
|
|
|
|
|
|
# Skip when s3 and host backup tests when there is more than one version of pg being tested and this is not the last one
|
|
|
|
my $hyVm = vmGet();
|
|
|
|
|
|
|
|
if (($bS3 || $bHostBackup) &&
|
2017-06-27 21:48:34 +02:00
|
|
|
(@{$hyVm->{$self->vm()}{&VM_DB_TEST}} > 1 && ${$hyVm->{$self->vm()}{&VM_DB_TEST}}[-1] ne $self->pgVersion()))
|
2017-06-21 22:07:13 +02:00
|
|
|
{
|
|
|
|
&log(INFO,
|
2017-06-27 21:48:34 +02:00
|
|
|
'skipped - this test is run this OS using PG ' . ${$hyVm->{$self->vm()}{&VM_DB_TEST}}[-1]);
|
2017-06-21 22:07:13 +02:00
|
|
|
next;
|
|
|
|
}
|
2016-12-23 15:22:59 +02:00
|
|
|
|
2017-06-21 22:07:13 +02:00
|
|
|
# Skip hot standby tests if the system does not support hot standby
|
2016-12-23 15:22:59 +02:00
|
|
|
if ($bHostStandby && $self->pgVersion() < PG_VERSION_HOT_STANDBY)
|
|
|
|
{
|
|
|
|
&log(INFO, 'skipped - this version of PostgreSQL does not support hot standby');
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2017-06-21 22:07:13 +02:00
|
|
|
# Skip backup destinations other than backup host when standby except for one arbitrary db version
|
|
|
|
if ($bHostStandby && $strBackupDestination ne HOST_BACKUP && $self->pgVersion() ne PG_VERSION_96)
|
|
|
|
{
|
2017-06-27 21:48:34 +02:00
|
|
|
&log(INFO, 'skipped - standby with backup destination other than backup host is tested on PG ' . PG_VERSION_96);
|
2017-06-21 22:07:13 +02:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2016-12-23 15:22:59 +02:00
|
|
|
# Create hosts, file object, and config
|
2017-06-12 16:52:32 +02:00
|
|
|
my ($oHostDbMaster, $oHostDbStandby, $oHostBackup, $oHostS3) = $self->setup(
|
2016-12-23 15:22:59 +02:00
|
|
|
false, $self->expect(),
|
|
|
|
{bHostBackup => $bHostBackup, bStandby => $bHostStandby, strBackupDestination => $strBackupDestination,
|
2017-06-21 22:07:13 +02:00
|
|
|
bCompress => $bCompress, bArchiveAsync => false, bS3 => $bS3});
|
|
|
|
|
2017-09-01 18:29:34 +02:00
|
|
|
# Create a manifest with the pg version to get version-specific paths
|
|
|
|
my $oManifest = new pgBackRest::Manifest(BOGUS, {bLoad => false, strDbVersion => $self->pgVersion()});
|
|
|
|
|
2017-06-21 22:07:13 +02:00
|
|
|
# Only perform extra tests on certain runs to save time
|
|
|
|
my $bTestLocal = $self->runCurrent() == 1;
|
|
|
|
my $bTestExtra =
|
|
|
|
$bTestLocal || $self->runCurrent() == 4 || ($self->runCurrent() == 6 && $self->pgVersion() eq PG_VERSION_96);
|
2016-12-23 15:22:59 +02:00
|
|
|
|
2017-06-21 22:07:13 +02:00
|
|
|
# If S3 set process max to 2. This seems like the best place for parallel testing since it will help speed S3 processing
|
|
|
|
# without slowing down the other tests too much.
|
|
|
|
if ($bS3)
|
|
|
|
{
|
2017-08-25 22:47:47 +02:00
|
|
|
$oHostBackup->configUpdate({&CFGDEF_SECTION_GLOBAL => {cfgOptionName(CFGOPT_PROCESS_MAX) => 2}});
|
|
|
|
$oHostDbMaster->configUpdate({&CFGDEF_SECTION_GLOBAL => {cfgOptionName(CFGOPT_PROCESS_MAX) => 2}});
|
2017-06-21 22:07:13 +02:00
|
|
|
}
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
$oHostDbMaster->clusterCreate();
|
|
|
|
|
|
|
|
# Create the stanza
|
|
|
|
$oHostBackup->stanzaCreate('main create stanza info files');
|
|
|
|
|
|
|
|
# Static backup parameters
|
|
|
|
my $fTestDelay = 1;
|
|
|
|
|
|
|
|
# Variable backup parameters
|
|
|
|
my $bDelta = true;
|
|
|
|
my $bForce = false;
|
|
|
|
my $strType = undef;
|
|
|
|
my $strTarget = undef;
|
|
|
|
my $bTargetExclusive = false;
|
|
|
|
my $strTargetAction;
|
|
|
|
my $strTargetTimeline = undef;
|
|
|
|
my $oRecoveryHashRef = undef;
|
|
|
|
my $strComment = undef;
|
|
|
|
my $iExpectedExitStatus = undef;
|
|
|
|
|
|
|
|
# Restore test string
|
|
|
|
my $strDefaultMessage = 'default';
|
|
|
|
my $strFullMessage = 'full';
|
|
|
|
my $strStandbyMessage = 'standby';
|
|
|
|
my $strIncrMessage = 'incr';
|
|
|
|
my $strTimeMessage = 'time';
|
|
|
|
my $strXidMessage = 'xid';
|
|
|
|
my $strNameMessage = 'name';
|
|
|
|
my $strTimelineMessage = 'timeline3';
|
|
|
|
|
|
|
|
# Create two new databases
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal)
|
|
|
|
{
|
|
|
|
$oHostDbMaster->sqlExecute('create database test1', {bAutoCommit => true});
|
|
|
|
$oHostDbMaster->sqlExecute('create database test2', {bAutoCommit => true});
|
|
|
|
}
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Test check command and stanza create
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
if ($bTestExtra)
|
|
|
|
{
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_BACKUP_TYPE_FULL;
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Remove the files in the archive directory
|
2017-06-09 23:51:41 +02:00
|
|
|
forceStorageRemove(storageRepo(), STORAGE_REPO_ARCHIVE, {bRecurse => true});
|
|
|
|
|
2016-12-23 15:22:59 +02:00
|
|
|
$oHostDbMaster->check(
|
|
|
|
'fail on missing archive.info file',
|
|
|
|
{iTimeout => 0.1, iExpectedExitStatus => ERROR_FILE_MISSING});
|
|
|
|
|
|
|
|
# Backup.info was created earlier so force stanza-create to create archive info file
|
2017-08-25 22:47:47 +02:00
|
|
|
$oHostBackup->stanzaCreate('force create stanza info files', {strOptionalParam => ' --' . cfgOptionName(CFGOPT_FORCE)});
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Check ERROR_ARCHIVE_DISABLED error
|
|
|
|
$strComment = 'fail on archive_mode=off';
|
|
|
|
$oHostDbMaster->clusterRestart({bIgnoreLogError => true, bArchiveEnabled => false});
|
|
|
|
|
|
|
|
$oHostBackup->backup($strType, $strComment, {iExpectedExitStatus => ERROR_ARCHIVE_DISABLED});
|
|
|
|
$oHostDbMaster->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_DISABLED});
|
|
|
|
|
|
|
|
# If running the remote tests then also need to run check locally
|
|
|
|
if ($bHostBackup)
|
|
|
|
{
|
|
|
|
$oHostBackup->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_DISABLED});
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check ERROR_ARCHIVE_COMMAND_INVALID error
|
|
|
|
$strComment = 'fail on invalid archive_command';
|
|
|
|
$oHostDbMaster->clusterRestart({bIgnoreLogError => true, bArchive => false});
|
|
|
|
|
|
|
|
$oHostBackup->backup($strType, $strComment, {iExpectedExitStatus => ERROR_ARCHIVE_COMMAND_INVALID});
|
|
|
|
$oHostDbMaster->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_COMMAND_INVALID});
|
|
|
|
|
|
|
|
# If running the remote tests then also need to run check locally
|
|
|
|
if ($bHostBackup)
|
|
|
|
{
|
|
|
|
$oHostBackup->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_COMMAND_INVALID});
|
|
|
|
}
|
|
|
|
|
|
|
|
# When archive-check=n then ERROR_ARCHIVE_TIMEOUT will be raised instead of ERROR_ARCHIVE_COMMAND_INVALID
|
|
|
|
# ??? But maybe we should error with the fact that that option is not valid
|
|
|
|
$strComment = 'fail on archive timeout when archive-check=n';
|
|
|
|
$oHostDbMaster->check(
|
|
|
|
$strComment,
|
|
|
|
{iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_TIMEOUT, strOptionalParam => '--no-archive-check'});
|
|
|
|
|
|
|
|
# Stop the cluster ignoring any errors in the postgresql log
|
|
|
|
$oHostDbMaster->clusterStop({bIgnoreLogError => true});
|
|
|
|
|
|
|
|
# Providing a sufficient archive-timeout, verify that the check command runs successfully.
|
|
|
|
$strComment = 'verify success';
|
|
|
|
|
|
|
|
$oHostDbMaster->clusterStart();
|
|
|
|
$oHostDbMaster->check($strComment, {iTimeout => 5});
|
|
|
|
|
|
|
|
# If running the remote tests then also need to run check locally
|
|
|
|
if ($bHostBackup)
|
|
|
|
{
|
|
|
|
$oHostBackup->check($strComment, {iTimeout => 5});
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check archive mismatch due to upgrade error
|
|
|
|
$strComment = 'fail on archive mismatch after upgrade';
|
|
|
|
|
|
|
|
# load the archive info file and munge it for testing by breaking the database version
|
|
|
|
$oHostBackup->infoMunge(
|
2017-06-09 23:51:41 +02:00
|
|
|
storageRepo()->pathGet(STORAGE_REPO_ARCHIVE . qw{/} . ARCHIVE_INFO_FILE),
|
2016-12-23 15:22:59 +02:00
|
|
|
{&INFO_ARCHIVE_SECTION_DB => {&INFO_ARCHIVE_KEY_DB_VERSION => '8.0'}});
|
|
|
|
|
|
|
|
$oHostDbMaster->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_MISMATCH});
|
|
|
|
|
|
|
|
# If running the remote tests then also need to run check locally
|
|
|
|
if ($bHostBackup)
|
|
|
|
{
|
|
|
|
$oHostBackup->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_MISMATCH});
|
|
|
|
}
|
|
|
|
|
|
|
|
# Restore the file to its original condition
|
2017-06-09 23:51:41 +02:00
|
|
|
$oHostBackup->infoRestore(storageRepo()->pathGet(STORAGE_REPO_ARCHIVE . qw{/} . ARCHIVE_INFO_FILE));
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Check archive_timeout error when WAL segment is not found
|
|
|
|
$strComment = 'fail on archive timeout';
|
|
|
|
|
|
|
|
$oHostDbMaster->clusterRestart({bIgnoreLogError => true, bArchiveInvalid => true});
|
|
|
|
$oHostDbMaster->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_TIMEOUT});
|
|
|
|
|
|
|
|
# If running the remote tests then also need to run check locally
|
|
|
|
if ($bHostBackup)
|
|
|
|
{
|
|
|
|
$oHostBackup->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_TIMEOUT});
|
|
|
|
}
|
|
|
|
|
|
|
|
# Restart the cluster ignoring any errors in the postgresql log
|
|
|
|
$oHostDbMaster->clusterRestart({bIgnoreLogError => true});
|
|
|
|
|
|
|
|
# With a valid archive info, create the backup.info file by running a backup then munge the backup.info file.
|
|
|
|
# Check backup mismatch error
|
|
|
|
$strComment = 'fail on backup info mismatch';
|
|
|
|
|
|
|
|
# Load the backup.info file and munge it for testing by breaking the database version and system id
|
|
|
|
$oHostBackup->infoMunge(
|
2017-06-09 23:51:41 +02:00
|
|
|
storageRepo()->pathGet(STORAGE_REPO_BACKUP . qw{/} . FILE_BACKUP_INFO),
|
2016-12-23 15:22:59 +02:00
|
|
|
{&INFO_BACKUP_SECTION_DB =>
|
|
|
|
{&INFO_BACKUP_KEY_DB_VERSION => '8.0', &INFO_BACKUP_KEY_SYSTEM_ID => 6999999999999999999}});
|
|
|
|
|
|
|
|
# Run the test
|
|
|
|
$oHostDbMaster->check($strComment, {iTimeout => 5, iExpectedExitStatus => ERROR_BACKUP_MISMATCH});
|
|
|
|
|
|
|
|
# If running the remote tests then also need to run check locally
|
|
|
|
if ($bHostBackup)
|
|
|
|
{
|
|
|
|
$oHostBackup->check($strComment, {iTimeout => 5, iExpectedExitStatus => ERROR_BACKUP_MISMATCH});
|
|
|
|
}
|
|
|
|
|
|
|
|
# Restore the file to its original condition
|
2017-06-09 23:51:41 +02:00
|
|
|
$oHostBackup->infoRestore(storageRepo()->pathGet(STORAGE_REPO_BACKUP . qw{/} . FILE_BACKUP_INFO));
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Providing a sufficient archive-timeout, verify that the check command runs successfully now with valid
|
|
|
|
# archive.info and backup.info files
|
|
|
|
$strComment = 'verify success after backup';
|
|
|
|
|
|
|
|
$oHostDbMaster->check($strComment, {iTimeout => 5});
|
|
|
|
|
|
|
|
# If running the remote tests then also need to run check locally
|
|
|
|
if ($bHostBackup)
|
|
|
|
{
|
|
|
|
$oHostBackup->check($strComment, {iTimeout => 5});
|
|
|
|
}
|
|
|
|
|
|
|
|
# Restart the cluster ignoring any errors in the postgresql log
|
|
|
|
$oHostDbMaster->clusterRestart({bIgnoreLogError => true});
|
|
|
|
|
2017-04-03 16:42:55 +02:00
|
|
|
# Stanza Create
|
2016-12-23 15:22:59 +02:00
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
2017-06-09 23:51:41 +02:00
|
|
|
# With data existing in the archive and backup directory, remove info files and confirm failure
|
|
|
|
forceStorageRemove(storageRepo(), STORAGE_REPO_BACKUP . qw{/} . FILE_BACKUP_INFO);
|
|
|
|
forceStorageRemove(storageRepo(), STORAGE_REPO_BACKUP . qw{/} . FILE_BACKUP_INFO . INI_COPY_EXT);
|
|
|
|
forceStorageRemove(storageRepo(), STORAGE_REPO_ARCHIVE . qw{/} . ARCHIVE_INFO_FILE);
|
|
|
|
forceStorageRemove(storageRepo(), STORAGE_REPO_ARCHIVE . qw{/} . ARCHIVE_INFO_FILE . INI_COPY_EXT);
|
|
|
|
|
2017-06-12 16:52:32 +02:00
|
|
|
if (!$bS3)
|
|
|
|
{
|
|
|
|
$oHostBackup->stanzaCreate('fail on backup info file missing from non-empty dir',
|
|
|
|
{iExpectedExitStatus => ERROR_PATH_NOT_EMPTY});
|
|
|
|
}
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Force the backup.info file to be recreated
|
2017-08-25 22:47:47 +02:00
|
|
|
$oHostBackup->stanzaCreate('verify success with force', {strOptionalParam => ' --' . cfgOptionName(CFGOPT_FORCE)});
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Remove the backup info file
|
2017-06-09 23:51:41 +02:00
|
|
|
forceStorageRemove(storageRepo(), STORAGE_REPO_BACKUP . qw{/} . FILE_BACKUP_INFO);
|
|
|
|
forceStorageRemove(storageRepo(), STORAGE_REPO_BACKUP . qw{/} . FILE_BACKUP_INFO . INI_COPY_EXT);
|
2016-12-23 15:22:59 +02:00
|
|
|
|
2017-04-03 16:42:55 +02:00
|
|
|
# Change the database version by copying a new pg_control file to a new db-path to use for db mismatch test
|
2017-06-09 23:51:41 +02:00
|
|
|
storageDb()->pathCreate(
|
|
|
|
$oHostDbMaster->dbPath() . '/testbase/' . DB_PATH_GLOBAL,
|
|
|
|
{strMode => '0700', bIgnoreExists => true, bCreateParent => true});
|
|
|
|
|
2017-04-03 16:42:55 +02:00
|
|
|
if ($self->pgVersion() eq PG_VERSION_94)
|
|
|
|
{
|
2017-06-09 23:51:41 +02:00
|
|
|
storageDb()->copy(
|
|
|
|
$self->dataPath() . '/backup.pg_control_' . WAL_VERSION_95 . '.bin',
|
|
|
|
$oHostDbMaster->dbPath() . '/testbase/' . DB_FILE_PGCONTROL);
|
2017-04-03 16:42:55 +02:00
|
|
|
} else
|
|
|
|
{
|
2017-06-09 23:51:41 +02:00
|
|
|
storageDb()->copy(
|
|
|
|
$self->dataPath() . '/backup.pg_control_' . WAL_VERSION_94 . '.bin',
|
|
|
|
$oHostDbMaster->dbPath() . '/testbase/' . DB_FILE_PGCONTROL);
|
2017-04-03 16:42:55 +02:00
|
|
|
}
|
2016-12-23 15:22:59 +02:00
|
|
|
|
2017-04-03 16:42:55 +02:00
|
|
|
# Run stanza-create online to confirm proper handling of configValidation error against new db-path
|
|
|
|
$oHostBackup->stanzaCreate('fail on database mismatch with directory',
|
2017-08-25 22:47:47 +02:00
|
|
|
{strOptionalParam => ' --' . $oHostBackup->optionIndexName(CFGOPT_DB_PATH, 1) . '=' . $oHostDbMaster->dbPath() .
|
|
|
|
'/testbase/', iExpectedExitStatus => ERROR_DB_MISMATCH});
|
2017-04-03 16:42:55 +02:00
|
|
|
|
|
|
|
# Stanza Upgrade - tests configValidate code - all other tests in synthetic integration tests
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
|
|
|
# Run stanza-create offline with --force to create files needing to be upgraded (using new db-path)
|
|
|
|
$oHostBackup->stanzaCreate('successfully create stanza files to be upgraded',
|
2017-08-25 22:47:47 +02:00
|
|
|
{strOptionalParam =>
|
|
|
|
' --' . $oHostBackup->optionIndexName(CFGOPT_DB_PATH, 1) . '=' . $oHostDbMaster->dbPath() .
|
|
|
|
'/testbase/ --no-' . cfgOptionName(CFGOPT_ONLINE) . ' --' . cfgOptionName(CFGOPT_FORCE)});
|
2017-06-21 14:02:21 +02:00
|
|
|
my $oAchiveInfo = new pgBackRest::Archive::Info(storageRepo()->pathGet('archive/' . $self->stanza()));
|
2017-06-09 23:51:41 +02:00
|
|
|
my $oBackupInfo = new pgBackRest::Backup::Info(storageRepo()->pathGet('backup/' . $self->stanza()));
|
2017-04-03 16:42:55 +02:00
|
|
|
|
|
|
|
# Read info files to confirm the files were created with a different database version
|
|
|
|
if ($self->pgVersion() eq PG_VERSION_94)
|
|
|
|
{
|
|
|
|
$self->testResult(sub {$oAchiveInfo->test(INFO_ARCHIVE_SECTION_DB, INFO_ARCHIVE_KEY_DB_VERSION, undef,
|
|
|
|
PG_VERSION_95)}, true, 'archive upgrade forced with db-mismatch');
|
|
|
|
$self->testResult(sub {$oBackupInfo->test(INFO_BACKUP_SECTION_DB, INFO_BACKUP_KEY_DB_VERSION, undef,
|
|
|
|
PG_VERSION_95)}, true, 'backup upgrade forced with db-mismatch');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$self->testResult(sub {$oAchiveInfo->test(INFO_ARCHIVE_SECTION_DB, INFO_ARCHIVE_KEY_DB_VERSION, undef,
|
|
|
|
PG_VERSION_94)}, true, 'archive create forced with db-mismatch in prep for stanza-upgrade');
|
|
|
|
$self->testResult(sub {$oBackupInfo->test(INFO_BACKUP_SECTION_DB, INFO_BACKUP_KEY_DB_VERSION, undef,
|
|
|
|
PG_VERSION_94)}, true, 'backup create forced with db-mismatch in prep for stanza-upgrade');
|
|
|
|
}
|
2016-12-23 15:22:59 +02:00
|
|
|
|
2017-04-03 16:42:55 +02:00
|
|
|
# Run stanza-upgrade online with the default db-path to correct the info files
|
|
|
|
$oHostBackup->stanzaUpgrade('upgrade stanza files online');
|
2016-12-23 15:22:59 +02:00
|
|
|
|
2017-04-03 16:42:55 +02:00
|
|
|
# Reread the info files and confirm the result
|
2017-06-21 14:02:21 +02:00
|
|
|
$oAchiveInfo = new pgBackRest::Archive::Info(storageRepo()->pathGet('archive/' . $self->stanza()));
|
2017-06-09 23:51:41 +02:00
|
|
|
$oBackupInfo = new pgBackRest::Backup::Info(storageRepo()->pathGet('backup/' . $self->stanza()));
|
2017-04-03 16:42:55 +02:00
|
|
|
$self->testResult(sub {$oAchiveInfo->test(INFO_ARCHIVE_SECTION_DB, INFO_ARCHIVE_KEY_DB_VERSION, undef,
|
|
|
|
$self->pgVersion())}, true, 'archive upgrade online corrects db');
|
|
|
|
$self->testResult(sub {$oBackupInfo->test(INFO_BACKUP_SECTION_DB, INFO_BACKUP_KEY_DB_VERSION, undef,
|
|
|
|
$self->pgVersion())}, true, 'backup upgrade online corrects db');
|
2016-12-23 15:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Full backup
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_BACKUP_TYPE_FULL;
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Create the table where test messages will be stored
|
|
|
|
$oHostDbMaster->sqlExecute("create table test (message text not null)");
|
2017-09-01 18:29:34 +02:00
|
|
|
$oHostDbMaster->sqlWalRotate();
|
2016-12-23 15:22:59 +02:00
|
|
|
$oHostDbMaster->sqlExecute("insert into test values ('$strDefaultMessage')");
|
|
|
|
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
|
|
|
# Acquire the backup advisory lock so it looks like a backup is running
|
|
|
|
if (!$oHostDbMaster->sqlSelectOne('select pg_try_advisory_lock(' . DB_BACKUP_ADVISORY_LOCK . ')'))
|
|
|
|
{
|
|
|
|
confess 'unable to acquire advisory lock for testing';
|
|
|
|
}
|
|
|
|
|
|
|
|
$oHostBackup->backup($strType, 'fail on backup lock exists', {iExpectedExitStatus => ERROR_LOCK_ACQUIRE});
|
|
|
|
|
|
|
|
# Release the backup advisory lock so the next backup will succeed
|
|
|
|
if (!$oHostDbMaster->sqlSelectOne('select pg_advisory_unlock(' . DB_BACKUP_ADVISORY_LOCK . ')'))
|
|
|
|
{
|
|
|
|
confess 'unable to release advisory lock';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my $oExecuteBackup = $oHostBackup->backupBegin(
|
|
|
|
$strType, 'update during backup',
|
|
|
|
{strTest => TEST_MANIFEST_BUILD, fTestDelay => $fTestDelay,
|
2017-08-25 22:47:47 +02:00
|
|
|
strOptionalParam => ' --' . cfgOptionName(CFGOPT_BUFFER_SIZE) . '=16384'});
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
$oHostDbMaster->sqlExecute("update test set message = '$strFullMessage'");
|
|
|
|
|
|
|
|
# Required to set hint bits to be sent to the standby to make the heap match on both sides
|
|
|
|
$oHostDbMaster->sqlSelectOneTest('select message from test', $strFullMessage);
|
|
|
|
|
|
|
|
my $strFullBackup = $oHostBackup->backupEnd($strType, $oExecuteBackup);
|
|
|
|
|
2017-06-21 22:07:13 +02:00
|
|
|
# Enabled async archiving
|
2017-08-25 22:47:47 +02:00
|
|
|
$oHostBackup->configUpdate({&CFGDEF_SECTION_GLOBAL => {cfgOptionName(CFGOPT_ARCHIVE_ASYNC) => 'y'}});
|
2017-06-21 22:07:13 +02:00
|
|
|
|
2016-12-23 15:22:59 +02:00
|
|
|
# Kick out a bunch of archive logs to excercise async archiving. Only do this when compressed and remote to slow it
|
|
|
|
# down enough to make it evident that the async process is working.
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestExtra && $bCompress && $strBackupDestination eq HOST_BACKUP)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
2017-09-01 18:29:34 +02:00
|
|
|
&log(INFO, ' multiple wal switches to exercise async archiving');
|
|
|
|
$oHostDbMaster->sqlExecute("create table wal_activity (id int)");
|
|
|
|
$oHostDbMaster->sqlWalRotate();
|
|
|
|
$oHostDbMaster->sqlExecute("insert into wal_activity values (1)");
|
|
|
|
$oHostDbMaster->sqlWalRotate();
|
|
|
|
$oHostDbMaster->sqlExecute("insert into wal_activity values (2)");
|
|
|
|
$oHostDbMaster->sqlWalRotate();
|
|
|
|
$oHostDbMaster->sqlExecute("insert into wal_activity values (3)");
|
|
|
|
$oHostDbMaster->sqlWalRotate();
|
|
|
|
$oHostDbMaster->sqlExecute("insert into wal_activity values (4)");
|
|
|
|
$oHostDbMaster->sqlWalRotate();
|
2016-12-23 15:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Setup replica
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
if ($bHostStandby)
|
|
|
|
{
|
|
|
|
$bDelta = false;
|
|
|
|
$bForce = false;
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_RESTORE_TYPE_DEFAULT;
|
2016-12-23 15:22:59 +02:00
|
|
|
$strTarget = undef;
|
|
|
|
$bTargetExclusive = undef;
|
|
|
|
$strTargetAction = undef;
|
|
|
|
$strTargetTimeline = undef;
|
|
|
|
$oRecoveryHashRef = undef;
|
|
|
|
$strComment = undef;
|
|
|
|
$iExpectedExitStatus = undef;
|
|
|
|
|
|
|
|
$strComment = 'restore backup on replica';
|
|
|
|
|
|
|
|
my %oRemapHash;
|
|
|
|
$oRemapHash{&MANIFEST_TARGET_PGDATA} = $oHostDbStandby->dbBasePath();
|
|
|
|
|
|
|
|
if ($oHostDbStandby->pgVersion() >= PG_VERSION_92)
|
|
|
|
{
|
2017-09-01 18:29:34 +02:00
|
|
|
$oHostDbStandby->linkRemap($oManifest->walPath(), $oHostDbStandby->dbPath() . '/' . $oManifest->walPath());
|
2016-12-23 15:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$oHostDbStandby->restore(
|
2017-08-25 22:47:47 +02:00
|
|
|
cfgRuleOptionDefault(CFGCMD_RESTORE, CFGOPT_SET), undef, \%oRemapHash, $bDelta, $bForce, $strType, $strTarget,
|
|
|
|
$bTargetExclusive, $strTargetAction, $strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus,
|
2016-12-23 15:22:59 +02:00
|
|
|
' --recovery-option=standby_mode=on' .
|
|
|
|
' --recovery-option="primary_conninfo=host=' . HOST_DB_MASTER .
|
|
|
|
' port=' . $oHostDbMaster->pgPort() . ' user=replicator"');
|
|
|
|
|
|
|
|
$oHostDbStandby->clusterStart({bHotStandby => true});
|
|
|
|
|
|
|
|
# Make sure streaming replication is on
|
|
|
|
$oHostDbMaster->sqlSelectOneTest(
|
|
|
|
"select client_addr || '-' || state from pg_stat_replication", $oHostDbStandby->ipGet() . '/32-streaming');
|
|
|
|
|
|
|
|
# Check that the cluster was restored properly
|
|
|
|
$oHostDbStandby->sqlSelectOneTest('select message from test', $strFullMessage);
|
|
|
|
|
|
|
|
# Update message for standby
|
|
|
|
$oHostDbMaster->sqlExecute("update test set message = '$strStandbyMessage'");
|
|
|
|
|
2017-09-01 01:15:44 +02:00
|
|
|
if ($oHostDbStandby->pgVersion() >= PG_VERSION_BACKUP_STANDBY)
|
|
|
|
{
|
|
|
|
# If there is only a master and a replica and the replica is the backup destination, then if db2-host and db3-host
|
|
|
|
# are BOGUS, confirm failure to reach the master
|
|
|
|
if (!$bHostBackup && $bHostStandby && $strBackupDestination eq HOST_DB_STANDBY)
|
|
|
|
{
|
|
|
|
my $strStandbyBackup = $oHostBackup->backup(
|
|
|
|
CFGOPTVAL_BACKUP_TYPE_FULL, 'backup from standby, failure to reach master',
|
|
|
|
{bStandby => true,
|
|
|
|
iExpectedExitStatus => ERROR_DB_CONNECT,
|
|
|
|
strOptionalParam => '--' .
|
|
|
|
$oHostBackup->optionIndexName(CFGOPT_DB_HOST, cfgOptionIndexTotal(CFGOPT_DB_PATH)) . '=' . BOGUS});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
my $strStandbyBackup = $oHostBackup->backup(
|
|
|
|
CFGOPTVAL_BACKUP_TYPE_FULL, 'backup from standby, failure to access at least one standby',
|
|
|
|
{bStandby => true,
|
|
|
|
iExpectedExitStatus => ERROR_HOST_CONNECT,
|
|
|
|
strOptionalParam => '--' .
|
|
|
|
$oHostBackup->optionIndexName(CFGOPT_DB_HOST, cfgOptionIndexTotal(CFGOPT_DB_PATH)) . '=' . BOGUS});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-23 15:22:59 +02:00
|
|
|
my $strStandbyBackup = $oHostBackup->backup(
|
2017-08-25 22:47:47 +02:00
|
|
|
CFGOPTVAL_BACKUP_TYPE_FULL, 'backup from standby',
|
2016-12-23 15:22:59 +02:00
|
|
|
{bStandby => true,
|
|
|
|
iExpectedExitStatus => $oHostDbStandby->pgVersion() >= PG_VERSION_BACKUP_STANDBY ? undef : ERROR_CONFIG,
|
2017-08-25 22:47:47 +02:00
|
|
|
strOptionalParam => '--' . cfgOptionName(CFGOPT_RETENTION_FULL) . '=1'});
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
if ($oHostDbStandby->pgVersion() >= PG_VERSION_BACKUP_STANDBY)
|
|
|
|
{
|
|
|
|
$strFullBackup = $strStandbyBackup;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Confirm the check command runs without error on a standby
|
|
|
|
$oHostDbStandby->check('verify check command on standby');
|
2017-07-24 13:57:47 +02:00
|
|
|
|
|
|
|
# Shutdown the stanby before creating tablespaces (this will error since paths are different)
|
|
|
|
$oHostDbStandby->clusterStop({bIgnoreLogError => true});
|
2016-12-23 15:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Execute stop and make sure the backup fails
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
# Restart the cluster to check for any errors before continuing since the stop tests will definitely create errors and
|
|
|
|
# the logs will to be deleted to avoid causing issues further down the line.
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestExtra && !$bS3)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_BACKUP_TYPE_INCR;
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
$oHostDbMaster->clusterRestart();
|
|
|
|
|
|
|
|
$oHostDbMaster->stop();
|
|
|
|
|
|
|
|
$oHostBackup->backup($strType, 'attempt backup when stopped', {iExpectedExitStatus => ERROR_STOP});
|
|
|
|
|
|
|
|
$oHostDbMaster->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
# Setup the time target
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
$oHostDbMaster->sqlExecute("update test set message = '$strTimeMessage'");
|
2017-09-01 18:29:34 +02:00
|
|
|
$oHostDbMaster->sqlWalRotate();
|
2016-12-23 15:22:59 +02:00
|
|
|
my $strTimeTarget = $oHostDbMaster->sqlSelectOne("select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS.US TZ')");
|
|
|
|
&log(INFO, " time target is ${strTimeTarget}");
|
|
|
|
|
|
|
|
# Incr backup - fail on archive_mode=always when version >= 9.5
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal && $oHostDbMaster->pgVersion() >= PG_VERSION_95)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_BACKUP_TYPE_INCR;
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Set archive_mode=always
|
|
|
|
$oHostDbMaster->clusterRestart({bArchiveAlways => true});
|
|
|
|
|
|
|
|
$oHostBackup->backup($strType, 'fail on archive_mode=always', {iExpectedExitStatus => ERROR_FEATURE_NOT_SUPPORTED});
|
|
|
|
|
|
|
|
# Reset the cluster to a normal state so the next test will work
|
|
|
|
$oHostDbMaster->clusterRestart();
|
|
|
|
}
|
|
|
|
|
|
|
|
# Incr backup
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_BACKUP_TYPE_INCR;
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Create a tablespace directory
|
2017-06-09 23:51:41 +02:00
|
|
|
storageTest()->pathCreate($oHostDbMaster->tablespacePath(1), {strMode => '0700', bCreateParent => true});
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Also create it on the standby so replay won't fail
|
|
|
|
if (defined($oHostDbStandby))
|
|
|
|
{
|
2017-06-09 23:51:41 +02:00
|
|
|
storageTest()->pathCreate($oHostDbStandby->tablespacePath(1), {strMode => '0700', bCreateParent => true});
|
2016-12-23 15:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$oHostDbMaster->sqlExecute(
|
|
|
|
"create tablespace ts1 location '" . $oHostDbMaster->tablespacePath(1) . "'", {bAutoCommit => true});
|
2017-06-27 22:47:40 +02:00
|
|
|
$oHostDbMaster->sqlExecute("alter table test set tablespace ts1");
|
|
|
|
|
|
|
|
# Create a table in the tablespace that will not be modified again to be sure it does get full page writes in the WAL later
|
|
|
|
$oHostDbMaster->sqlExecute("create table test_exists (id int) tablespace ts1", {bCommit => true, bCheckPoint => true});
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Create a table in the tablespace
|
|
|
|
$oHostDbMaster->sqlExecute("create table test_remove (id int)");
|
2017-09-01 18:29:34 +02:00
|
|
|
$oHostDbMaster->sqlWalRotate();
|
2016-12-23 15:22:59 +02:00
|
|
|
$oHostDbMaster->sqlExecute("update test set message = '$strDefaultMessage'");
|
2017-09-01 18:29:34 +02:00
|
|
|
$oHostDbMaster->sqlWalRotate();
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Start a backup so the next backup has to restart it. This test is not required for PostgreSQL >= 9.6 since backups
|
|
|
|
# are run in non-exlusive mode.
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal && $oHostDbMaster->pgVersion() >= PG_VERSION_93 && $oHostDbMaster->pgVersion() < PG_VERSION_96)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
|
|
|
$oHostDbMaster->sqlSelectOne("select pg_start_backup('test backup that will cause an error', true)");
|
|
|
|
|
|
|
|
# Verify that an error is returned if the backup is already running
|
|
|
|
$oHostBackup->backup($strType, 'fail on backup already running', {iExpectedExitStatus => ERROR_DB_QUERY});
|
|
|
|
|
|
|
|
# Restart the cluster ignoring any errors in the postgresql log
|
|
|
|
$oHostDbMaster->clusterRestart({bIgnoreLogError => true});
|
|
|
|
|
|
|
|
# Start a new backup to make the next test restart it
|
|
|
|
$oHostDbMaster->sqlSelectOne("select pg_start_backup('test backup that will be restarted', true)");
|
|
|
|
}
|
|
|
|
|
|
|
|
$oExecuteBackup = $oHostBackup->backupBegin(
|
|
|
|
$strType, 'update during backup',
|
|
|
|
{strTest => TEST_MANIFEST_BUILD, fTestDelay => $fTestDelay,
|
2017-08-25 22:47:47 +02:00
|
|
|
strOptionalParam => '--' . cfgOptionName(CFGOPT_STOP_AUTO) . ' --no-' . cfgOptionName(CFGOPT_ARCHIVE_CHECK) .
|
|
|
|
' --' . cfgOptionName(CFGOPT_BUFFER_SIZE) . '=32768'});
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Drop a table
|
|
|
|
$oHostDbMaster->sqlExecute('drop table test_remove');
|
2017-09-01 18:29:34 +02:00
|
|
|
$oHostDbMaster->sqlWalRotate();
|
2016-12-23 15:22:59 +02:00
|
|
|
$oHostDbMaster->sqlExecute("update test set message = '$strIncrMessage'", {bCommit => true});
|
|
|
|
|
|
|
|
# Check that application name is set
|
|
|
|
if ($oHostDbMaster->pgVersion() >= PG_VERSION_APPLICATION_NAME)
|
|
|
|
{
|
2017-08-25 22:47:47 +02:00
|
|
|
my $strApplicationNameExpected = BACKREST_NAME . ' [' . cfgCommandName(CFGCMD_BACKUP) . ']';
|
2016-12-23 15:22:59 +02:00
|
|
|
my $strApplicationName = $oHostDbMaster->sqlSelectOne(
|
|
|
|
"select application_name from pg_stat_activity where application_name like '" . BACKREST_NAME . "%'");
|
|
|
|
|
|
|
|
if (!defined($strApplicationName) || $strApplicationName ne $strApplicationNameExpected)
|
|
|
|
{
|
|
|
|
confess &log(ERROR,
|
|
|
|
"application name '" . (defined($strApplicationName) ? $strApplicationName : '[null]') .
|
|
|
|
"' does not match '" . $strApplicationNameExpected . "'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my $strIncrBackup = $oHostBackup->backupEnd($strType, $oExecuteBackup);
|
|
|
|
|
|
|
|
# Setup the xid target
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
my $strXidTarget = undef;
|
|
|
|
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
|
|
|
$oHostDbMaster->sqlExecute("update test set message = '$strXidMessage'", {bCommit => false});
|
2017-09-01 18:29:34 +02:00
|
|
|
$oHostDbMaster->sqlWalRotate();
|
2016-12-23 15:22:59 +02:00
|
|
|
$strXidTarget = $oHostDbMaster->sqlSelectOne("select txid_current()");
|
|
|
|
$oHostDbMaster->sqlCommit();
|
|
|
|
&log(INFO, " xid target is ${strXidTarget}");
|
|
|
|
}
|
|
|
|
|
|
|
|
# Setup the name target
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
my $strNameTarget = 'backrest';
|
|
|
|
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
|
|
|
$oHostDbMaster->sqlExecute("update test set message = '$strNameMessage'", {bCommit => true});
|
2017-09-01 18:29:34 +02:00
|
|
|
$oHostDbMaster->sqlWalRotate();
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
if ($oHostDbMaster->pgVersion() >= PG_VERSION_91)
|
|
|
|
{
|
|
|
|
$oHostDbMaster->sqlExecute("select pg_create_restore_point('${strNameTarget}')");
|
|
|
|
}
|
|
|
|
|
|
|
|
&log(INFO, " name target is ${strNameTarget}");
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create a table and data in database test2
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal)
|
|
|
|
{
|
|
|
|
$oHostDbMaster->sqlExecute(
|
|
|
|
'create table test (id int);' .
|
|
|
|
'insert into test values (1);' .
|
|
|
|
'create table test_ts1 (id int) tablespace ts1;' .
|
|
|
|
'insert into test_ts1 values (2);',
|
|
|
|
{strDb => 'test2', bAutoCommit => true});
|
2017-09-01 18:29:34 +02:00
|
|
|
$oHostDbMaster->sqlWalRotate();
|
2017-06-21 22:07:13 +02:00
|
|
|
}
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Restore (type = default)
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
$bDelta = false;
|
|
|
|
$bForce = false;
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_RESTORE_TYPE_DEFAULT;
|
2016-12-23 15:22:59 +02:00
|
|
|
$strTarget = undef;
|
|
|
|
$bTargetExclusive = undef;
|
|
|
|
$strTargetAction = undef;
|
|
|
|
$strTargetTimeline = undef;
|
|
|
|
$oRecoveryHashRef = undef;
|
|
|
|
$strComment = undef;
|
|
|
|
$iExpectedExitStatus = undef;
|
|
|
|
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
|
|
|
# Expect failure because postmaster.pid exists
|
|
|
|
$strComment = 'postmaster running';
|
|
|
|
$iExpectedExitStatus = ERROR_POSTMASTER_RUNNING;
|
|
|
|
|
|
|
|
$oHostDbMaster->restore(
|
2017-08-25 22:47:47 +02:00
|
|
|
cfgRuleOptionDefault(CFGCMD_RESTORE, CFGOPT_SET), undef, undef, $bDelta, $bForce, $strType, $strTarget,
|
|
|
|
$bTargetExclusive, $strTargetAction, $strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus);
|
2016-12-23 15:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$oHostDbMaster->clusterStop();
|
|
|
|
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
|
|
|
# Expect failure because db path is not empty
|
|
|
|
$strComment = 'path not empty';
|
|
|
|
$iExpectedExitStatus = ERROR_PATH_NOT_EMPTY;
|
|
|
|
|
|
|
|
$oHostDbMaster->restore(
|
2017-08-25 22:47:47 +02:00
|
|
|
cfgRuleOptionDefault(CFGCMD_RESTORE, CFGOPT_SET), undef, undef, $bDelta, $bForce, $strType, $strTarget,
|
|
|
|
$bTargetExclusive, $strTargetAction, $strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus);
|
2016-12-23 15:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Drop and recreate db path
|
|
|
|
testPathRemove($oHostDbMaster->dbBasePath());
|
2017-06-09 23:51:41 +02:00
|
|
|
storageTest()->pathCreate($oHostDbMaster->dbBasePath(), {strMode => '0700'});
|
2017-09-01 18:29:34 +02:00
|
|
|
testPathRemove($oHostDbMaster->dbPath() . qw{/} . $oManifest->walPath());
|
|
|
|
storageTest()->pathCreate($oHostDbMaster->dbPath() . qw{/} . $oManifest->walPath(), {strMode => '0700'});
|
2016-12-23 15:22:59 +02:00
|
|
|
testPathRemove($oHostDbMaster->tablespacePath(1));
|
2017-06-09 23:51:41 +02:00
|
|
|
storageTest()->pathCreate($oHostDbMaster->tablespacePath(1), {strMode => '0700'});
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Now the restore should work
|
|
|
|
$strComment = undef;
|
|
|
|
$iExpectedExitStatus = undef;
|
|
|
|
|
|
|
|
$oHostDbMaster->restore(
|
2017-08-25 22:47:47 +02:00
|
|
|
cfgRuleOptionDefault(CFGCMD_RESTORE, CFGOPT_SET), undef, undef, $bDelta, $bForce, $strType, $strTarget,
|
|
|
|
$bTargetExclusive, $strTargetAction, $strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus,
|
2017-06-21 22:07:13 +02:00
|
|
|
$bTestLocal ? ' --db-include=test1' : undef);
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
$oHostDbMaster->clusterStart();
|
2017-06-21 22:07:13 +02:00
|
|
|
$oHostDbMaster->sqlSelectOneTest('select message from test', $bTestLocal ? $strNameMessage : $strIncrMessage);
|
2016-12-23 15:22:59 +02:00
|
|
|
|
2017-06-27 22:47:40 +02:00
|
|
|
# The tablespace path should exist and have files in it
|
|
|
|
my $strTablespacePath = $oHostDbMaster->tablespacePath(1);
|
|
|
|
|
|
|
|
# Version <= 8.4 always places a PG_VERSION file in the tablespace
|
|
|
|
if ($oHostDbMaster->pgVersion() <= PG_VERSION_84)
|
|
|
|
{
|
|
|
|
if (!storageDb()->exists("${strTablespacePath}/" . DB_FILE_PGVERSION))
|
|
|
|
{
|
|
|
|
confess &log(ASSERT, "unable to find '" . DB_FILE_PGVERSION . "' in tablespace path '${strTablespacePath}'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# Version >= 9.0 creates a special path using the version and catalog number
|
|
|
|
else
|
|
|
|
{
|
|
|
|
# Backup info will have the catalog number
|
|
|
|
my $oBackupInfo = new pgBackRest::Common::Ini(
|
|
|
|
storageRepo()->pathGet(STORAGE_REPO_BACKUP . qw{/} . FILE_BACKUP_INFO),
|
|
|
|
{bLoad => false, strContent => ${storageRepo()->get(STORAGE_REPO_BACKUP . qw{/} . FILE_BACKUP_INFO)}});
|
|
|
|
|
|
|
|
# Construct the special path
|
|
|
|
$strTablespacePath .=
|
|
|
|
'/PG_' . $oHostDbMaster->pgVersion() . qw{_} . $oBackupInfo->get(INFO_BACKUP_SECTION_DB, INFO_BACKUP_KEY_CATALOG);
|
|
|
|
|
|
|
|
# Check that path exists
|
|
|
|
if (!storageDb()->pathExists($strTablespacePath))
|
|
|
|
{
|
|
|
|
confess &log(ASSERT, "unable to find tablespace path '${strTablespacePath}'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Make sure there are some files in the tablespace path (exclude PG_VERSION if <= 8.4 since that was tested above)
|
|
|
|
if (grep(!/^PG\_VERSION$/i, storageDb()->list($strTablespacePath)) == 0)
|
|
|
|
{
|
|
|
|
confess &log(ASSERT, "no files found in tablespace path '${strTablespacePath}'");
|
|
|
|
}
|
|
|
|
|
|
|
|
# This table should exist to prove that the tablespace was restored. It has not been updated since it was created so it
|
|
|
|
# should not be created by any full page writes. Once it is verified to exist it can be dropped.
|
|
|
|
$oHostDbMaster->sqlSelectOneTest("select count(*) from test_exists", 0);
|
|
|
|
$oHostDbMaster->sqlExecute('drop table test_exists');
|
|
|
|
|
2016-12-23 15:22:59 +02:00
|
|
|
# Now it should be OK to drop database test2
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal)
|
|
|
|
{
|
|
|
|
$oHostDbMaster->sqlExecute('drop database test2', {bAutoCommit => true});
|
|
|
|
}
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# The test table lives in ts1 so it needs to be moved or dropped
|
|
|
|
if ($oHostDbMaster->pgVersion() >= PG_VERSION_90)
|
|
|
|
{
|
|
|
|
$oHostDbMaster->sqlExecute('alter table test set tablespace pg_default');
|
|
|
|
}
|
|
|
|
# Drop for older versions
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$oHostDbMaster->sqlExecute('drop table test');
|
|
|
|
}
|
|
|
|
|
|
|
|
# And drop the tablespace
|
|
|
|
$oHostDbMaster->sqlExecute("drop tablespace ts1", {bAutoCommit => true});
|
|
|
|
|
|
|
|
# Restore (restore type = immediate, inclusive)
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-06-21 22:07:13 +02:00
|
|
|
if (($bTestLocal || $bHostStandby) && $oHostDbMaster->pgVersion() >= PG_VERSION_94)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
|
|
|
$bDelta = false;
|
|
|
|
$bForce = true;
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_RESTORE_TYPE_IMMEDIATE;
|
2016-12-23 15:22:59 +02:00
|
|
|
$strTarget = undef;
|
|
|
|
$bTargetExclusive = undef;
|
|
|
|
$strTargetAction = undef;
|
|
|
|
$strTargetTimeline = undef;
|
|
|
|
$oRecoveryHashRef = undef;
|
|
|
|
$strComment = undef;
|
|
|
|
$iExpectedExitStatus = undef;
|
|
|
|
|
|
|
|
&log(INFO, " testing recovery type = ${strType}");
|
|
|
|
|
|
|
|
$oHostDbMaster->clusterStop();
|
|
|
|
|
|
|
|
$oHostDbMaster->restore(
|
|
|
|
$strFullBackup, undef, undef, $bDelta, $bForce, $strType, $strTarget, $bTargetExclusive, $strTargetAction,
|
|
|
|
$strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus, undef);
|
|
|
|
|
|
|
|
$oHostDbMaster->clusterStart();
|
|
|
|
$oHostDbMaster->sqlSelectOneTest(
|
|
|
|
'select message from test', ($bHostStandby ? $strStandbyMessage : $strFullMessage));
|
|
|
|
}
|
|
|
|
|
|
|
|
# Restore (restore type = xid, inclusive)
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
|
|
|
$bDelta = false;
|
|
|
|
$bForce = true;
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_RESTORE_TYPE_XID;
|
2016-12-23 15:22:59 +02:00
|
|
|
$strTarget = $strXidTarget;
|
|
|
|
$bTargetExclusive = undef;
|
|
|
|
$strTargetAction = $oHostDbMaster->pgVersion() >= PG_VERSION_91 ? 'promote' : undef;
|
|
|
|
$strTargetTimeline = undef;
|
|
|
|
$oRecoveryHashRef = undef;
|
|
|
|
$strComment = undef;
|
|
|
|
$iExpectedExitStatus = undef;
|
|
|
|
|
|
|
|
&log(INFO, " testing recovery type = ${strType}");
|
|
|
|
|
|
|
|
$oHostDbMaster->clusterStop();
|
|
|
|
|
|
|
|
executeTest('rm -rf ' . $oHostDbMaster->dbBasePath() . "/*");
|
2017-09-01 18:29:34 +02:00
|
|
|
executeTest('rm -rf ' . $oHostDbMaster->dbPath() . qw{/} . $oManifest->walPath() . '/*');
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
$oHostDbMaster->restore(
|
|
|
|
$strIncrBackup, undef, undef, $bDelta, $bForce, $strType, $strTarget, $bTargetExclusive, $strTargetAction,
|
|
|
|
$strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus,
|
|
|
|
'--tablespace-map-all=../../tablespace', false);
|
|
|
|
|
|
|
|
# Save recovery file to test so we can use it in the next test
|
2017-06-09 23:51:41 +02:00
|
|
|
storageDb()->copy(
|
|
|
|
$oHostDbMaster->dbBasePath() . qw{/} . DB_FILE_RECOVERYCONF, $self->testPath() . qw{/} . DB_FILE_RECOVERYCONF);
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
$oHostDbMaster->clusterStart();
|
|
|
|
$oHostDbMaster->sqlSelectOneTest('select message from test', $strXidMessage);
|
|
|
|
|
|
|
|
$oHostDbMaster->sqlExecute("update test set message = '$strTimelineMessage'");
|
|
|
|
}
|
|
|
|
|
|
|
|
# Restore (restore type = preserve, inclusive)
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
|
|
|
$bDelta = false;
|
|
|
|
$bForce = false;
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_RESTORE_TYPE_PRESERVE;
|
2016-12-23 15:22:59 +02:00
|
|
|
$strTarget = undef;
|
|
|
|
$bTargetExclusive = undef;
|
|
|
|
$strTargetAction = undef;
|
|
|
|
$strTargetTimeline = undef;
|
|
|
|
$oRecoveryHashRef = undef;
|
|
|
|
$strComment = undef;
|
|
|
|
$iExpectedExitStatus = undef;
|
|
|
|
|
|
|
|
&log(INFO, " testing recovery type = ${strType}");
|
|
|
|
|
|
|
|
$oHostDbMaster->clusterStop();
|
|
|
|
|
|
|
|
executeTest('rm -rf ' . $oHostDbMaster->dbBasePath() . "/*");
|
2017-09-01 18:29:34 +02:00
|
|
|
executeTest('rm -rf ' . $oHostDbMaster->dbPath() . qw{/} . $oManifest->walPath() . '/*');
|
2016-12-23 15:22:59 +02:00
|
|
|
executeTest('rm -rf ' . $oHostDbMaster->tablespacePath(1) . "/*");
|
|
|
|
|
|
|
|
# Restore recovery file that was saved in last test
|
2017-06-09 23:51:41 +02:00
|
|
|
storageDb()->move($self->testPath . '/recovery.conf', $oHostDbMaster->dbBasePath() . '/recovery.conf');
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
$oHostDbMaster->restore(
|
2017-08-25 22:47:47 +02:00
|
|
|
cfgRuleOptionDefault(CFGCMD_RESTORE, CFGOPT_SET), undef, undef, $bDelta, $bForce, $strType, $strTarget,
|
|
|
|
$bTargetExclusive, $strTargetAction, $strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus);
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
$oHostDbMaster->clusterStart();
|
|
|
|
$oHostDbMaster->sqlSelectOneTest('select message from test', $strXidMessage);
|
|
|
|
|
|
|
|
$oHostDbMaster->sqlExecute("update test set message = '$strTimelineMessage'");
|
|
|
|
}
|
|
|
|
|
|
|
|
# Restore (restore type = time, inclusive) - there is no exclusive time test because I can't find a way to find the
|
|
|
|
# exact commit time of a transaction.
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
$bDelta = true;
|
|
|
|
$bForce = false;
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_RESTORE_TYPE_TIME;
|
2016-12-23 15:22:59 +02:00
|
|
|
$strTarget = $strTimeTarget;
|
|
|
|
$bTargetExclusive = undef;
|
|
|
|
$strTargetAction = undef;
|
|
|
|
$strTargetTimeline = undef;
|
|
|
|
$oRecoveryHashRef = undef;
|
|
|
|
$strComment = undef;
|
|
|
|
$iExpectedExitStatus = undef;
|
|
|
|
|
|
|
|
&log(INFO, " testing recovery type = ${strType}");
|
|
|
|
|
|
|
|
$oHostDbMaster->clusterStop();
|
|
|
|
|
|
|
|
$oHostDbMaster->restore(
|
|
|
|
$strFullBackup, undef, undef, $bDelta, $bForce, $strType, $strTarget, $bTargetExclusive, $strTargetAction,
|
|
|
|
$strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus);
|
|
|
|
|
|
|
|
$oHostDbMaster->clusterStart();
|
|
|
|
$oHostDbMaster->sqlSelectOneTest('select message from test', $strTimeMessage);
|
|
|
|
|
|
|
|
# Restore (restore type = xid, exclusive)
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
|
|
|
$bDelta = true;
|
|
|
|
$bForce = false;
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_RESTORE_TYPE_XID;
|
2016-12-23 15:22:59 +02:00
|
|
|
$strTarget = $strXidTarget;
|
|
|
|
$bTargetExclusive = true;
|
|
|
|
$strTargetAction = undef;
|
|
|
|
$strTargetTimeline = undef;
|
|
|
|
$oRecoveryHashRef = undef;
|
|
|
|
$strComment = undef;
|
|
|
|
$iExpectedExitStatus = undef;
|
|
|
|
|
|
|
|
&log(INFO, " testing recovery type = ${strType}");
|
|
|
|
|
|
|
|
$oHostDbMaster->clusterStop();
|
|
|
|
|
|
|
|
$oHostDbMaster->restore(
|
|
|
|
$strIncrBackup, undef, undef, $bDelta, $bForce, $strType, $strTarget, $bTargetExclusive, $strTargetAction,
|
|
|
|
$strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus);
|
|
|
|
|
|
|
|
$oHostDbMaster->clusterStart();
|
|
|
|
$oHostDbMaster->sqlSelectOneTest('select message from test', $strIncrMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Restore (restore type = name)
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal && $oHostDbMaster->pgVersion() >= PG_VERSION_91)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
|
|
|
$bDelta = true;
|
|
|
|
$bForce = true;
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_RESTORE_TYPE_NAME;
|
2016-12-23 15:22:59 +02:00
|
|
|
$strTarget = $strNameTarget;
|
|
|
|
$bTargetExclusive = undef;
|
|
|
|
$strTargetAction = undef;
|
|
|
|
$strTargetTimeline = undef;
|
|
|
|
$oRecoveryHashRef = undef;
|
|
|
|
$strComment = undef;
|
|
|
|
$iExpectedExitStatus = undef;
|
|
|
|
|
|
|
|
&log(INFO, " testing recovery type = ${strType}");
|
|
|
|
|
|
|
|
$oHostDbMaster->clusterStop();
|
|
|
|
|
|
|
|
$oHostDbMaster->restore(
|
2017-08-25 22:47:47 +02:00
|
|
|
cfgRuleOptionDefault(CFGCMD_RESTORE, CFGOPT_SET), undef, undef, $bDelta, $bForce, $strType, $strTarget,
|
|
|
|
$bTargetExclusive, $strTargetAction, $strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus);
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
$oHostDbMaster->clusterStart();
|
|
|
|
$oHostDbMaster->sqlSelectOneTest('select message from test', $strNameMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Restore (restore type = default, timeline = 3)
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestLocal && $oHostDbMaster->pgVersion() >= PG_VERSION_84)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
|
|
|
$bDelta = true;
|
|
|
|
$bForce = false;
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_RESTORE_TYPE_DEFAULT;
|
2016-12-23 15:22:59 +02:00
|
|
|
$strTarget = undef;
|
|
|
|
$bTargetExclusive = undef;
|
|
|
|
$strTargetAction = undef;
|
|
|
|
$strTargetTimeline = 4;
|
|
|
|
$oRecoveryHashRef = $oHostDbMaster->pgVersion() >= PG_VERSION_90 ? {'standby-mode' => 'on'} : undef;
|
|
|
|
$strComment = undef;
|
|
|
|
$iExpectedExitStatus = undef;
|
|
|
|
|
|
|
|
&log(INFO, " testing recovery type = ${strType}");
|
|
|
|
|
|
|
|
$oHostDbMaster->clusterStop();
|
|
|
|
|
|
|
|
$oHostDbMaster->restore(
|
|
|
|
$strIncrBackup, undef, undef, $bDelta, $bForce, $strType, $strTarget, $bTargetExclusive, $strTargetAction,
|
|
|
|
$strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus);
|
|
|
|
|
|
|
|
$oHostDbMaster->clusterStart({bHotStandby => true});
|
|
|
|
$oHostDbMaster->sqlSelectOneTest('select message from test', $strTimelineMessage, {iTimeout => 120});
|
|
|
|
}
|
|
|
|
|
2017-02-03 03:44:42 +02:00
|
|
|
# Stop clusters to catch any errors in the postgres log
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-07-24 13:57:47 +02:00
|
|
|
$oHostDbMaster->clusterStop();
|
2017-02-03 03:44:42 +02:00
|
|
|
|
|
|
|
# Test no-online backups
|
2016-12-23 15:22:59 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-06-21 22:07:13 +02:00
|
|
|
if ($bTestExtra & !$bS3)
|
2016-12-23 15:22:59 +02:00
|
|
|
{
|
2017-02-03 03:44:42 +02:00
|
|
|
# Create a postmaster.pid file so it appears that the server is running
|
2017-06-09 23:51:41 +02:00
|
|
|
storageTest()->put($oHostDbMaster->dbBasePath() . '/postmaster.pid', '99999');
|
2017-02-03 03:44:42 +02:00
|
|
|
|
|
|
|
# Incr backup - make sure a --no-online backup fails
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_BACKUP_TYPE_INCR;
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
$oHostBackup->backup(
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType, 'fail on --no-' . cfgOptionName(CFGOPT_ONLINE),
|
|
|
|
{iExpectedExitStatus => ERROR_POSTMASTER_RUNNING, strOptionalParam => '--no-' . cfgOptionName(CFGOPT_ONLINE)});
|
2016-12-23 15:22:59 +02:00
|
|
|
|
2017-02-03 03:44:42 +02:00
|
|
|
# Incr backup - allow --no-online backup to succeed with --force
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType = CFGOPTVAL_BACKUP_TYPE_INCR;
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
$oHostBackup->backup(
|
2017-08-25 22:47:47 +02:00
|
|
|
$strType, 'succeed on --no-' . cfgOptionName(CFGOPT_ONLINE) . ' with --' . cfgOptionName(CFGOPT_FORCE),
|
|
|
|
{strOptionalParam => '--no-' . cfgOptionName(CFGOPT_ONLINE) . ' --' . cfgOptionName(CFGOPT_FORCE)});
|
2016-12-23 15:22:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-12 16:52:32 +02:00
|
|
|
}
|
2016-12-23 15:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|