1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-18 04:58:51 +02:00

Reduce the frequency that certain tests are run to save time in regression.

This commit is contained in:
David Steele 2016-07-29 18:32:54 -04:00
parent ac23716d26
commit 1b6b26956a
2 changed files with 253 additions and 208 deletions

View File

@ -222,6 +222,12 @@
<p>Fixed an issue where multi-threaded tests were not being run when requested.</p>
</release-item>
</release-bug-list>
<release-refactor-list>
<release-item>
<p>Reduce the frequency that certain tests are run to save time in regression.</p>
</release-item>
</release-refactor-list>
</release-test-list>
</release>

View File

@ -1550,9 +1550,11 @@ sub backupTestRun
$bRemote, false, undef,
{bCompress => $bCompress, bArchiveAsync => $bArchiveAsync});
# Determine if extra tests are performed. Extra tests should not be primary tests for compression or async archiving.
my $bTestExtra = !$bCompress && !$bArchiveAsync && $iThreadMax == 1;
# For the 'fail on missing archive.info file' test, the archive.info file must not be found so set archive invalid.
$oHostDbMaster->clusterCreate({bArchiveInvalid => true});
$oHostDbMaster->clusterCreate({bArchiveInvalid => $bTestExtra});
# Static backup parameters
my $fTestDelay = 1;
@ -1584,6 +1586,8 @@ sub backupTestRun
# Test invalid check command
#-----------------------------------------------------------------------------------------------------------------------
if ($bTestExtra)
{
$strType = BACKUP_TYPE_FULL;
# NOTE: This must run before the success test since that will create the archive.info file
@ -1651,7 +1655,7 @@ sub backupTestRun
# Check archive_timeout error when WAL segment is not found
$strComment = 'fail on archive timeout';
$oHostDbMaster->clusterRestart({bArchiveInvalid => true});
$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
@ -1690,11 +1694,11 @@ sub backupTestRun
$strComment = 'verify success after backup';
$oHostBackup->check($strComment, {iTimeout => 5});
}
# Clear cluster for next set of tests
$oHostDbMaster->clusterStop();
$oHostDbMaster->clusterStart();
# Restart the cluster ignoring any errors in the postgresql log
$oHostDbMaster->clusterRestart({bIgnoreLogError => true});
}
}
# Full backup
#-----------------------------------------------------------------------------------------------------------------------
@ -1705,6 +1709,8 @@ sub backupTestRun
$oHostDbMaster->sqlXlogRotate();
$oHostDbMaster->sqlExecute("insert into test values ('$strDefaultMessage')");
if ($bTestExtra)
{
# 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 . ')'))
{
@ -1716,7 +1722,8 @@ sub backupTestRun
# 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 acquire advisory lock for testing';
confess 'unable to release advisory lock';
}
}
my $oExecuteBackup = $oHostBackup->backupBegin(
@ -1731,6 +1738,8 @@ sub backupTestRun
#-----------------------------------------------------------------------------------------------------------------------
# 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.
if ($bTestExtra)
{
$oHostDbMaster->clusterRestart();
$oHostDbMaster->stop();
@ -1738,6 +1747,7 @@ sub backupTestRun
$oHostBackup->backup($strType, 'attempt backup when stopped', {iExpectedExitStatus => ERROR_STOP});
$oHostDbMaster->start();
}
# Setup the time target
#-----------------------------------------------------------------------------------------------------------------------
@ -1748,7 +1758,7 @@ sub backupTestRun
# Incr backup - fail on archive_mode=always when version >= 9.5
#-----------------------------------------------------------------------------------------------------------------------
if ($oHostDbMaster->dbVersion() >= PG_VERSION_95)
if ($bTestExtra && $oHostDbMaster->dbVersion() >= PG_VERSION_95)
{
$strType = BACKUP_TYPE_INCR;
@ -1777,7 +1787,7 @@ sub backupTestRun
# 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.
if ($oHostDbMaster->dbVersion() >= PG_VERSION_93 && $oHostDbMaster->dbVersion() < PG_VERSION_96)
if ($bTestExtra && $oHostDbMaster->dbVersion() >= PG_VERSION_93 && $oHostDbMaster->dbVersion() < PG_VERSION_96)
{
$oHostDbMaster->sqlSelectOne("select pg_start_backup('test backup that will be cancelled', true)");
@ -1801,16 +1811,23 @@ sub backupTestRun
# Setup the xid target
#-----------------------------------------------------------------------------------------------------------------------
my $strXidTarget = undef;
if ($bTestExtra)
{
$oHostDbMaster->sqlExecute("update test set message = '$strXidMessage'", {bCommit => false});
$oHostDbMaster->sqlXlogRotate();
my $strXidTarget = $oHostDbMaster->sqlSelectOne("select txid_current()");
$strXidTarget = $oHostDbMaster->sqlSelectOne("select txid_current()");
$oHostDbMaster->sqlCommit();
&log(INFO, " xid target is ${strXidTarget}");
}
# Setup the name target
#-----------------------------------------------------------------------------------------------------------------------
my $strNameTarget = 'backrest';
if ($bTestExtra)
{
$oHostDbMaster->sqlExecute("update test set message = '$strNameMessage'", {bCommit => true});
$oHostDbMaster->sqlXlogRotate();
@ -1820,6 +1837,7 @@ sub backupTestRun
}
&log(INFO, " name target is ${strNameTarget}");
}
# Create a table and data in database test2
#-----------------------------------------------------------------------------------------------------------------------
@ -1844,8 +1862,10 @@ sub backupTestRun
$strComment = undef;
$iExpectedExitStatus = undef;
&log(INFO, " testing recovery type = ${strType}");
# &log(INFO, " testing recovery type = ${strType}");
if ($bTestExtra)
{
# Expect failure because postmaster.pid exists
$strComment = 'postmaster running';
$iExpectedExitStatus = ERROR_POSTMASTER_RUNNING;
@ -1853,9 +1873,12 @@ sub backupTestRun
$oHostDbMaster->restore(
OPTION_DEFAULT_RESTORE_SET, undef, undef, $bDelta, $bForce, $strType, $strTarget, $bTargetExclusive,
$strTargetAction, $strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus);
}
$oHostDbMaster->clusterStop();
if ($bTestExtra)
{
# Expect failure because db path is not empty
$strComment = 'path not empty';
$iExpectedExitStatus = ERROR_RESTORE_PATH_NOT_EMPTY;
@ -1863,6 +1886,7 @@ sub backupTestRun
$oHostDbMaster->restore(
OPTION_DEFAULT_RESTORE_SET, undef, undef, $bDelta, $bForce, $strType, $strTarget, $bTargetExclusive,
$strTargetAction, $strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus);
}
# Drop and recreate db path
testPathRemove($oHostDbMaster->dbBasePath());
@ -1881,7 +1905,7 @@ sub backupTestRun
$strTargetAction, $strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus, ' --db-include=test1');
$oHostDbMaster->clusterStart();
$oHostDbMaster->sqlSelectOneTest('select message from test', $strNameMessage);
$oHostDbMaster->sqlSelectOneTest('select message from test', $bTestExtra ? $strNameMessage : $strIncrMessage);
# Now it should be OK to drop database test2
$oHostDbMaster->sqlExecute('drop database test2', {bAutoCommit => true});
@ -1902,7 +1926,7 @@ sub backupTestRun
# Restore (restore type = immediate, inclusive)
#-----------------------------------------------------------------------------------------------------------------------
if ($oHostDbMaster->dbVersion() >= PG_VERSION_94)
if ($bTestExtra && $oHostDbMaster->dbVersion() >= PG_VERSION_94)
{
$bDelta = false;
$bForce = true;
@ -1929,6 +1953,8 @@ sub backupTestRun
# Restore (restore type = xid, inclusive)
#-----------------------------------------------------------------------------------------------------------------------
if ($bTestExtra)
{
$bDelta = false;
$bForce = true;
$strType = RECOVERY_TYPE_XID;
@ -1949,8 +1975,8 @@ sub backupTestRun
$oHostDbMaster->restore(
$strIncrBackup, undef, undef, $bDelta, $bForce, $strType, $strTarget, $bTargetExclusive, $strTargetAction,
$strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus, '--tablespace-map-all=../../tablespace',
false);
$strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus,
'--tablespace-map-all=../../tablespace', false);
# Save recovery file to test so we can use it in the next test
$oFile->copy(PATH_ABSOLUTE, $oHostDbMaster->dbBasePath() . '/recovery.conf',
@ -1960,9 +1986,12 @@ sub backupTestRun
$oHostDbMaster->sqlSelectOneTest('select message from test', $strXidMessage);
$oHostDbMaster->sqlExecute("update test set message = '$strTimelineMessage'");
}
# Restore (restore type = preserve, inclusive)
#-----------------------------------------------------------------------------------------------------------------------
if ($bTestExtra)
{
$bDelta = false;
$bForce = false;
$strType = RECOVERY_TYPE_PRESERVE;
@ -1994,6 +2023,7 @@ sub backupTestRun
$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.
@ -2022,6 +2052,8 @@ sub backupTestRun
# Restore (restore type = xid, exclusive)
#-----------------------------------------------------------------------------------------------------------------------
if ($bTestExtra)
{
$bDelta = true;
$bForce = false;
$strType = RECOVERY_TYPE_XID;
@ -2043,10 +2075,11 @@ sub backupTestRun
$oHostDbMaster->clusterStart();
$oHostDbMaster->sqlSelectOneTest('select message from test', $strIncrMessage);
}
# Restore (restore type = name)
#-----------------------------------------------------------------------------------------------------------------------
if ($oHostDbMaster->dbVersion() >= PG_VERSION_91)
if ($bTestExtra && $oHostDbMaster->dbVersion() >= PG_VERSION_91)
{
$bDelta = true;
$bForce = true;
@ -2073,7 +2106,7 @@ sub backupTestRun
# Restore (restore type = default, timeline = 3)
#-----------------------------------------------------------------------------------------------------------------------
if ($oHostDbMaster->dbVersion() >= PG_VERSION_84)
if ($bTestExtra && $oHostDbMaster->dbVersion() >= PG_VERSION_84)
{
$bDelta = true;
$bForce = false;
@ -2100,14 +2133,19 @@ sub backupTestRun
# Incr backup - make sure a --no-online backup fails
#-----------------------------------------------------------------------------------------------------------------------
if ($bTestExtra)
{
$strType = BACKUP_TYPE_INCR;
$oHostBackup->backup(
$strType, 'fail on --no-' . OPTION_ONLINE,
{iExpectedExitStatus => ERROR_POSTMASTER_RUNNING, strOptionalParam => '--no-' . OPTION_ONLINE});
}
# Incr backup - allow --no-online backup to succeed with --force
#-----------------------------------------------------------------------------------------------------------------------
if ($bTestExtra)
{
$strType = BACKUP_TYPE_INCR;
$oHostBackup->backup(
@ -2116,6 +2154,7 @@ sub backupTestRun
}
}
}
}
testCleanup();
}