1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-11-06 08:49:29 +02:00

In the end it was a single non-undefed reference holding up the show. The Backup file should be split into Archive, Backup, Expire, and made into objects. That would cut down on this kind of nastiness.

This commit is contained in:
David Steele
2015-01-30 20:16:21 -05:00
parent 50e015a838
commit 11c257296a
5 changed files with 211 additions and 191 deletions

View File

@@ -1695,181 +1695,181 @@ sub BackRestTestBackup_Test
my $strFullBackup = BackRestTestBackup_BackupEnd($strType, $oFile, $bRemote, undef, undef, $bSynthetic);
# # Setup the time target
# #-----------------------------------------------------------------------------------------------------------------------
# BackRestTestBackup_PgExecute("update test set message = '$strTimeMessage'", false);
# BackRestTestBackup_PgSwitchXlog();
# my $strTimeTarget = BackRestTestBackup_PgSelectOne("select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS.US TZ')");
# &log(INFO, " time target is ${strTimeTarget}");
#
# # Incr backup
# #-----------------------------------------------------------------------------------------------------------------------
# $strType = BACKUP_TYPE_INCR;
# $bTestPoint = true;
#
# BackRestTestBackup_PgExecute("create table test_remove (id int)", false);
# BackRestTestBackup_PgSwitchXlog();
# BackRestTestBackup_PgExecute("update test set message = '$strDefaultMessage'", false);
# BackRestTestBackup_PgSwitchXlog();
#
# BackRestTestBackup_BackupBegin($strType, $strStanza, $bRemote, "update during backup", $bSynthetic, $bTestPoint,
# $fTestDelay);
# BackRestTestCommon_ExecuteEnd(TEST_MANIFEST_BUILD);
#
# BackRestTestBackup_PgExecute("drop table test_remove", false);
# BackRestTestBackup_PgSwitchXlog();
# BackRestTestBackup_PgExecute("update test set message = '$strIncrMessage'", false);
#
# my $strIncrBackup = BackRestTestBackup_BackupEnd($strType, $oFile, $bRemote, undef, undef, $bSynthetic);
#
# # Setup the xid target
# #-----------------------------------------------------------------------------------------------------------------------
# BackRestTestBackup_PgExecute("update test set message = '$strXidMessage'", false, false);
# BackRestTestBackup_PgSwitchXlog();
# my $strXidTarget = BackRestTestBackup_PgSelectOne("select txid_current()");
# BackRestTestBackup_PgCommit();
# &log(INFO, " xid target is ${strXidTarget}");
#
# # Setup the name target
# #-----------------------------------------------------------------------------------------------------------------------
# my $strNameTarget = 'backrest';
#
# BackRestTestBackup_PgExecute("update test set message = '$strNameMessage'", false, true);
# BackRestTestBackup_PgSwitchXlog();
# BackRestTestBackup_PgExecute("select pg_create_restore_point('${strNameTarget}')", false, false);
#
# &log(INFO, " name target is ${strNameTarget}");
#
# # Restore (type = default)
# #-----------------------------------------------------------------------------------------------------------------------
# $strType = RECOVERY_TYPE_DEFAULT;
# $bDelta = false;
# $bForce = false;
#
# &log(INFO, " testing recovery type = ${strType}");
#
# # Expect failure because postmaster.pid exists
# BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, $bRemote, undef, undef, $bDelta, $bForce,
# $strType, undef, undef, undef, undef, undef,
# 'postmaster running', ERROR_POSTMASTER_RUNNING);
#
# BackRestTestBackup_ClusterStop();
#
# # Expect failure because db path is not empty
# BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, $bRemote, undef, undef, $bDelta, $bForce,
# $strType, undef, undef, undef, undef, undef,
# 'path not empty', ERROR_RESTORE_PATH_NOT_EMPTY);
#
# # Drop and recreate db path
# BackRestTestCommon_PathRemove(BackRestTestCommon_DbCommonPathGet());
# BackRestTestCommon_PathCreate(BackRestTestCommon_DbCommonPathGet());
#
# # Now the restore should work
# BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, $bRemote, undef, undef, $bDelta, $bForce,
# $strType, undef, undef, undef, undef, undef);
#
# BackRestTestBackup_ClusterStart();
#
# my $strMessageActual = BackRestTestBackup_PgSelectOne("select message from test");
# my $strMessageExpected = $strNameMessage;
#
# if ($strMessageActual ne $strMessageExpected)
# {
# confess "expected message '${strMessageExpected}' but found '${strMessageActual}'";
# }
#
# # Restore (restore type = xid, inclusive)
# #-----------------------------------------------------------------------------------------------------------------------
# $strType = RECOVERY_TYPE_XID;
# $bDelta = false;
# $bForce = true;
#
# &log(INFO, " testing recovery type = ${strType}");
#
# BackRestTestBackup_ClusterStop();
#
# BackRestTestBackup_Restore($oFile, $strIncrBackup, $strStanza, $bRemote, undef, undef, $bDelta, $bForce,
# $strType, $strXidTarget, undef, undef, undef, undef);
#
# BackRestTestBackup_ClusterStart();
#
# $strMessageActual = BackRestTestBackup_PgSelectOne("select message from test");
# $strMessageExpected = $strXidMessage;
#
# if ($strMessageActual ne $strMessageExpected)
# {
# confess "expected message '${strMessageExpected}' but found '${strMessageActual}'";
# }
#
# # 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.
# #-----------------------------------------------------------------------------------------------------------------------
# $strType = RECOVERY_TYPE_TIME;
# $bDelta = true;
# $bForce = false;
#
# &log(INFO, " testing recovery type = ${strType}");
#
# BackRestTestBackup_ClusterStop();
#
# BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, $bRemote, undef, undef, $bDelta, $bForce,
# $strType, $strTimeTarget, undef, undef, undef, undef);
#
# BackRestTestBackup_ClusterStart();
#
# $strMessageActual = BackRestTestBackup_PgSelectOne("select message from test");
# $strMessageExpected = $strTimeMessage;
#
# if ($strMessageActual ne $strMessageExpected)
# {
# confess "expected message '${strMessageExpected}' but found '${strMessageActual}'";
# }
#
# # Restore (restore type = xid, exclusive)
# #-----------------------------------------------------------------------------------------------------------------------
# $strType = RECOVERY_TYPE_XID;
# $bDelta = true;
# $bForce = false;
#
# &log(INFO, " testing recovery type = ${strType}");
#
# BackRestTestBackup_ClusterStop();
#
# BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, $bRemote, undef, undef, $bDelta, $bForce,
# $strType, $strXidTarget, true, undef, undef, undef);
#
# BackRestTestBackup_ClusterStart();
#
# $strMessageActual = BackRestTestBackup_PgSelectOne("select message from test");
# $strMessageExpected = $strIncrMessage;
#
# if ($strMessageActual ne $strMessageExpected)
# {
# confess "expected message '${strMessageExpected}' but found '${strMessageActual}'";
# }
#
# # Restore (restore type = name)
# #-----------------------------------------------------------------------------------------------------------------------
# $strType = RECOVERY_TYPE_NAME;
# $bDelta = true;
# $bForce = true;
#
# &log(INFO, " testing recovery type = ${strType}");
#
# BackRestTestBackup_ClusterStop();
#
# BackRestTestBackup_Restore($oFile, 'latest', $strStanza, $bRemote, undef, undef, $bDelta, $bForce,
# $strType, $strNameTarget, undef, undef, undef, undef);
#
# BackRestTestBackup_ClusterStart();
#
# $strMessageActual = BackRestTestBackup_PgSelectOne("select message from test");
# $strMessageExpected = $strNameMessage;
#
# if ($strMessageActual ne $strMessageExpected)
# {
# confess "expected message '${strMessageExpected}' but found '${strMessageActual}'";
# }
# Setup the time target
#-----------------------------------------------------------------------------------------------------------------------
BackRestTestBackup_PgExecute("update test set message = '$strTimeMessage'", false);
BackRestTestBackup_PgSwitchXlog();
my $strTimeTarget = BackRestTestBackup_PgSelectOne("select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS.US TZ')");
&log(INFO, " time target is ${strTimeTarget}");
# Incr backup
#-----------------------------------------------------------------------------------------------------------------------
$strType = BACKUP_TYPE_INCR;
$bTestPoint = true;
BackRestTestBackup_PgExecute("create table test_remove (id int)", false);
BackRestTestBackup_PgSwitchXlog();
BackRestTestBackup_PgExecute("update test set message = '$strDefaultMessage'", false);
BackRestTestBackup_PgSwitchXlog();
BackRestTestBackup_BackupBegin($strType, $strStanza, $bRemote, "update during backup", $bSynthetic, $bTestPoint,
$fTestDelay);
BackRestTestCommon_ExecuteEnd(TEST_MANIFEST_BUILD);
BackRestTestBackup_PgExecute("drop table test_remove", false);
BackRestTestBackup_PgSwitchXlog();
BackRestTestBackup_PgExecute("update test set message = '$strIncrMessage'", false);
my $strIncrBackup = BackRestTestBackup_BackupEnd($strType, $oFile, $bRemote, undef, undef, $bSynthetic);
# Setup the xid target
#-----------------------------------------------------------------------------------------------------------------------
BackRestTestBackup_PgExecute("update test set message = '$strXidMessage'", false, false);
BackRestTestBackup_PgSwitchXlog();
my $strXidTarget = BackRestTestBackup_PgSelectOne("select txid_current()");
BackRestTestBackup_PgCommit();
&log(INFO, " xid target is ${strXidTarget}");
# Setup the name target
#-----------------------------------------------------------------------------------------------------------------------
my $strNameTarget = 'backrest';
BackRestTestBackup_PgExecute("update test set message = '$strNameMessage'", false, true);
BackRestTestBackup_PgSwitchXlog();
BackRestTestBackup_PgExecute("select pg_create_restore_point('${strNameTarget}')", false, false);
&log(INFO, " name target is ${strNameTarget}");
# Restore (type = default)
#-----------------------------------------------------------------------------------------------------------------------
$strType = RECOVERY_TYPE_DEFAULT;
$bDelta = false;
$bForce = false;
&log(INFO, " testing recovery type = ${strType}");
# Expect failure because postmaster.pid exists
BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, $bRemote, undef, undef, $bDelta, $bForce,
$strType, undef, undef, undef, undef, undef,
'postmaster running', ERROR_POSTMASTER_RUNNING);
BackRestTestBackup_ClusterStop();
# Expect failure because db path is not empty
BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, $bRemote, undef, undef, $bDelta, $bForce,
$strType, undef, undef, undef, undef, undef,
'path not empty', ERROR_RESTORE_PATH_NOT_EMPTY);
# Drop and recreate db path
BackRestTestCommon_PathRemove(BackRestTestCommon_DbCommonPathGet());
BackRestTestCommon_PathCreate(BackRestTestCommon_DbCommonPathGet());
# Now the restore should work
BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, $bRemote, undef, undef, $bDelta, $bForce,
$strType, undef, undef, undef, undef, undef);
BackRestTestBackup_ClusterStart();
my $strMessageActual = BackRestTestBackup_PgSelectOne("select message from test");
my $strMessageExpected = $strNameMessage;
if ($strMessageActual ne $strMessageExpected)
{
confess "expected message '${strMessageExpected}' but found '${strMessageActual}'";
}
# Restore (restore type = xid, inclusive)
#-----------------------------------------------------------------------------------------------------------------------
$strType = RECOVERY_TYPE_XID;
$bDelta = false;
$bForce = true;
&log(INFO, " testing recovery type = ${strType}");
BackRestTestBackup_ClusterStop();
BackRestTestBackup_Restore($oFile, $strIncrBackup, $strStanza, $bRemote, undef, undef, $bDelta, $bForce,
$strType, $strXidTarget, undef, undef, undef, undef);
BackRestTestBackup_ClusterStart();
$strMessageActual = BackRestTestBackup_PgSelectOne("select message from test");
$strMessageExpected = $strXidMessage;
if ($strMessageActual ne $strMessageExpected)
{
confess "expected message '${strMessageExpected}' but found '${strMessageActual}'";
}
# 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.
#-----------------------------------------------------------------------------------------------------------------------
$strType = RECOVERY_TYPE_TIME;
$bDelta = true;
$bForce = false;
&log(INFO, " testing recovery type = ${strType}");
BackRestTestBackup_ClusterStop();
BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, $bRemote, undef, undef, $bDelta, $bForce,
$strType, $strTimeTarget, undef, undef, undef, undef);
BackRestTestBackup_ClusterStart();
$strMessageActual = BackRestTestBackup_PgSelectOne("select message from test");
$strMessageExpected = $strTimeMessage;
if ($strMessageActual ne $strMessageExpected)
{
confess "expected message '${strMessageExpected}' but found '${strMessageActual}'";
}
# Restore (restore type = xid, exclusive)
#-----------------------------------------------------------------------------------------------------------------------
$strType = RECOVERY_TYPE_XID;
$bDelta = true;
$bForce = false;
&log(INFO, " testing recovery type = ${strType}");
BackRestTestBackup_ClusterStop();
BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, $bRemote, undef, undef, $bDelta, $bForce,
$strType, $strXidTarget, true, undef, undef, undef);
BackRestTestBackup_ClusterStart();
$strMessageActual = BackRestTestBackup_PgSelectOne("select message from test");
$strMessageExpected = $strIncrMessage;
if ($strMessageActual ne $strMessageExpected)
{
confess "expected message '${strMessageExpected}' but found '${strMessageActual}'";
}
# Restore (restore type = name)
#-----------------------------------------------------------------------------------------------------------------------
$strType = RECOVERY_TYPE_NAME;
$bDelta = true;
$bForce = true;
&log(INFO, " testing recovery type = ${strType}");
BackRestTestBackup_ClusterStop();
BackRestTestBackup_Restore($oFile, 'latest', $strStanza, $bRemote, undef, undef, $bDelta, $bForce,
$strType, $strNameTarget, undef, undef, undef, undef);
BackRestTestBackup_ClusterStart();
$strMessageActual = BackRestTestBackup_PgSelectOne("select message from test");
$strMessageExpected = $strNameMessage;
if ($strMessageActual ne $strMessageExpected)
{
confess "expected message '${strMessageExpected}' but found '${strMessageActual}'";
}
$bCreate = true;
}