1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-10-30 23:37:45 +02:00

Require description in every call to testResult() and make iWaitSeconds optional.

This commit is contained in:
David Steele
2017-04-05 10:50:32 -04:00
parent c7b61a2002
commit 0da216c034
6 changed files with 71 additions and 33 deletions

View File

@@ -190,6 +190,14 @@
<release-test-list>
<release-refactor-list>
<release-item>
<p>Require description in every call to <code>testResult()</code>.</p>
</release-item>
<release-item>
<p>Make <code>iWaitSeconds</code> an optional parameter for <code>testResult()</code>.</p>
</release-item>
<release-item>
<p>Updated vagrant to new version and image.</p>
</release-item>

View File

@@ -321,7 +321,7 @@ sub run
$self->testResult(
sub {$oFile->list(PATH_BACKUP_ARCHIVE, PG_VERSION_94 . '-1/0000000100000001')},
'(' . join(', ', @stryExpectedWAL) . ')',
'all WAL in archive', 5);
'all WAL in archive', {iWaitSeconds => 5});
#---------------------------------------------------------------------------------------------------------------------------
if (defined($self->expect()))

View File

@@ -99,7 +99,7 @@ sub run
sub {$oFile->list(
PATH_BACKUP_ARCHIVE, PG_VERSION_94 . '-1/0000000100000001', {strExpression => '^(?!000000010000000100000002).+'})},
"000000010000000100000001-72b9da071c13957fb4ca31f05dbd5c644297c2f7${strCompressExt}",
'segment 2-4 not pushed (2 is pushed sometimes when remote but ignore)', 5);
'segment 2-4 not pushed (2 is pushed sometimes when remote but ignore)', {iWaitSeconds => 5});
#---------------------------------------------------------------------------------------------------------------------------
$oHostDbMaster->archivePush($strXlogPath, $strArchiveTestFile, 5);
@@ -109,7 +109,7 @@ sub run
PATH_BACKUP_ARCHIVE, PG_VERSION_94 . '-1/0000000100000001', {strExpression => '^(?!000000010000000100000002).+'})},
"(000000010000000100000001-72b9da071c13957fb4ca31f05dbd5c644297c2f7${strCompressExt}, " .
"000000010000000100000005-72b9da071c13957fb4ca31f05dbd5c644297c2f7${strCompressExt})",
'segment 5 is pushed', 5);
'segment 5 is pushed', {iWaitSeconds => 5});
}
}
}

View File

@@ -285,15 +285,29 @@ sub end
sub testResult
{
my $self = shift;
my $fnSub = shift;
my $strExpected = shift;
my $strDescription = shift;
my $iWaitSeconds = shift;
&log(INFO, ' ' . (defined($strDescription) ? $strDescription : 'no description'));
# Assign function parameters, defaults, and log debug info
my
(
$strOperation,
$fnSub,
$strExpected,
$strDescription,
$iWaitSeconds,
) =
logDebugParam
(
__PACKAGE__ . '::testResult', \@_,
{name => 'fnSub', trace => true},
{name => 'strExpected', required => false, trace => true},
{name => 'strDescription', trace => true},
{name => 'iWaitSeconds', optional => true, default => 0, trace => true},
);
&log(INFO, ' ' . $strDescription);
my $strActual;
my $oWait = waitInit(defined($iWaitSeconds) ? $iWaitSeconds : 0);
my $oWait = waitInit($iWaitSeconds);
my $bDone = false;
do
@@ -341,6 +355,9 @@ sub testResult
$bDone = true;
}
} while (!$bDone);
# Return from function and log return values if any
return logDebugReturn($strOperation);
}
####################################################################################################################################

View File

@@ -93,7 +93,7 @@ sub run
# Else success
else
{
$self->testResult($strFunction, '[undef]');
$self->testResult($strFunction, '[undef]', 'success');
}
}
}

View File

@@ -34,11 +34,11 @@ sub run
{
&log(INFO, " File->pathTypeGet()");
$self->testResult(sub {$oLocalFile->pathTypeGet(PATH_ABSOLUTE)}, PATH_ABSOLUTE);
$self->testResult(sub {$oLocalFile->pathTypeGet(PATH_DB)}, PATH_DB);
$self->testResult(sub {$oLocalFile->pathTypeGet(PATH_DB_ABSOLUTE)}, PATH_DB);
$self->testResult(sub {$oLocalFile->pathTypeGet(PATH_BACKUP)}, PATH_BACKUP);
$self->testResult(sub {$oLocalFile->pathTypeGet(PATH_BACKUP_ARCHIVE)}, PATH_BACKUP);
$self->testResult(sub {$oLocalFile->pathTypeGet(PATH_ABSOLUTE)}, PATH_ABSOLUTE, 'absolute path type');
$self->testResult(sub {$oLocalFile->pathTypeGet(PATH_DB)}, PATH_DB, 'db path type');
$self->testResult(sub {$oLocalFile->pathTypeGet(PATH_DB_ABSOLUTE)}, PATH_DB, 'db absolute path type');
$self->testResult(sub {$oLocalFile->pathTypeGet(PATH_BACKUP)}, PATH_BACKUP, 'backup path type');
$self->testResult(sub {$oLocalFile->pathTypeGet(PATH_BACKUP_ARCHIVE)}, PATH_BACKUP, 'backup archive path type');
$self->testException(sub {$oLocalFile->pathTypeGet('bogus')}, ERROR_ASSERT, "no known path types in 'bogus'");
}
@@ -69,12 +69,12 @@ sub run
sub {$oLocalFile->pathGet(PATH_ABSOLUTE)}, ERROR_ASSERT, "strFile must be defined for absolute path");
$self->testException(
sub {$oLocalFile->pathGet(PATH_ABSOLUTE, 'file')}, ERROR_ASSERT, "absolute path absolute:file must start with /");
$self->testResult(sub {$oLocalFile->pathGet(PATH_ABSOLUTE, '/file', true)}, "/file.pgbackrest.tmp");
$self->testResult(sub {$oLocalFile->pathGet(PATH_ABSOLUTE, '/file')}, "/file");
$self->testResult(sub {$oLocalFile->pathGet(PATH_ABSOLUTE, '/file', true)}, "/file.pgbackrest.tmp", 'absolute path temp');
$self->testResult(sub {$oLocalFile->pathGet(PATH_ABSOLUTE, '/file')}, "/file", 'absolute path file');
# Test backup path
$self->testResult(sub {$oLocalFile->pathGet(PATH_BACKUP, 'file')}, $self->testPath() . '/file');
$self->testResult(sub {$oLocalFile->pathGet(PATH_BACKUP, undef)}, $self->testPath());
$self->testResult(sub {$oLocalFile->pathGet(PATH_BACKUP, 'file')}, $self->testPath() . '/file', 'backup path file');
$self->testResult(sub {$oLocalFile->pathGet(PATH_BACKUP, undef)}, $self->testPath(), 'backup path');
# Error when stanza not defined
$self->testException(
@@ -83,38 +83,51 @@ sub run
# Test backup tmp path
$self->testResult(
sub {$oLocalFile->pathGet(PATH_BACKUP_TMP, 'file', true)}, $self->testPath() . '/temp/db.tmp/file.pgbackrest.tmp');
$self->testResult(sub {$oLocalFile->pathGet(PATH_BACKUP_TMP, 'file')}, $self->testPath() . '/temp/db.tmp/file');
$self->testResult(sub {$oLocalFile->pathGet(PATH_BACKUP_TMP, undef)}, $self->testPath() . '/temp/db.tmp');
sub {$oLocalFile->pathGet(PATH_BACKUP_TMP, 'file', true)}, $self->testPath() . '/temp/db.tmp/file.pgbackrest.tmp',
'backup temp path temp file');
$self->testResult(
sub {$oLocalFile->pathGet(PATH_BACKUP_TMP, 'file')}, $self->testPath() . '/temp/db.tmp/file', 'backup temp path file');
$self->testResult(
sub {$oLocalFile->pathGet(PATH_BACKUP_TMP, undef)}, $self->testPath() . '/temp/db.tmp', 'backup temp path');
# Test archive path
$self->testResult(sub {$oLocalFile->pathGet(PATH_BACKUP_ARCHIVE, undef)}, $self->testPath() . '/archive/db');
$self->testResult(sub {$oLocalFile->pathGet(PATH_BACKUP_ARCHIVE, '9.3-1')}, $self->testPath() . '/archive/db/9.3-1');
$self->testResult(
sub {$oLocalFile->pathGet(PATH_BACKUP_ARCHIVE, undef)}, $self->testPath() . '/archive/db', 'archive path');
$self->testResult(
sub {$oLocalFile->pathGet(PATH_BACKUP_ARCHIVE, '9.3-1')}, $self->testPath() . '/archive/db/9.3-1', 'archive id path');
$self->testResult(
sub {$oLocalFile->pathGet(PATH_BACKUP_ARCHIVE, '9.3-1/000000010000000100000001')},
$self->testPath() . '/archive/db/9.3-1/0000000100000001/000000010000000100000001');
$self->testPath() . '/archive/db/9.3-1/0000000100000001/000000010000000100000001',
'archive path file');
$self->testResult(
sub {$oLocalFile->pathGet(PATH_BACKUP_ARCHIVE, '9.3-1/000000010000000100000001', true)},
$self->testPath() . '/archive/db/9.3-1/0000000100000001/000000010000000100000001.pgbackrest.tmp');
$self->testPath() . '/archive/db/9.3-1/0000000100000001/000000010000000100000001.pgbackrest.tmp',
'archive path temp file');
$self->testResult(
sub {$oLocalFile->pathGet(PATH_BACKUP_ARCHIVE, '9.3-1/00000001.history')},
$self->testPath() . '/archive/db/9.3-1/00000001.history');
$self->testPath() . '/archive/db/9.3-1/00000001.history',
'archive path history file');
$self->testResult(
sub {$oLocalFile->pathGet(PATH_BACKUP_ARCHIVE, '9.3-1/00000001.history', true)},
$self->testPath() . '/archive/db/9.3-1/00000001.history.pgbackrest.tmp');
$self->testPath() . '/archive/db/9.3-1/00000001.history.pgbackrest.tmp',
'archive path history temp file');
# Test archive out path
$self->testResult(
sub {$oLocalFile->pathGet(PATH_BACKUP_ARCHIVE_OUT, '000000010000000100000001')},
$self->testPath() . '/archive/db/out/000000010000000100000001');
$self->testResult(sub {$oLocalFile->pathGet(PATH_BACKUP_ARCHIVE_OUT)}, $self->testPath() . '/archive/db/out');
$self->testPath() . '/archive/db/out/000000010000000100000001',
'archive out path file');
$self->testResult(
sub {$oLocalFile->pathGet(PATH_BACKUP_ARCHIVE_OUT)}, $self->testPath() . '/archive/db/out', 'archive out path');
$self->testResult(
sub {$oLocalFile->pathGet(PATH_BACKUP_ARCHIVE_OUT, '000000010000000100000001', true)},
$self->testPath() . '/archive/db/out/000000010000000100000001.pgbackrest.tmp');
$self->testPath() . '/archive/db/out/000000010000000100000001.pgbackrest.tmp',
'archive out path temp file');
# Test backup cluster path
$self->testResult(sub {$oLocalFile->pathGet(PATH_BACKUP_CLUSTER, 'file')}, $self->testPath() . '/backup/db/file');
$self->testResult(sub {$oLocalFile->pathGet(PATH_BACKUP_CLUSTER)}, $self->testPath() . '/backup/db');
$self->testResult(
sub {$oLocalFile->pathGet(PATH_BACKUP_CLUSTER, 'file')}, $self->testPath() . '/backup/db/file', 'cluster path file');
$self->testResult(sub {$oLocalFile->pathGet(PATH_BACKUP_CLUSTER)}, $self->testPath() . '/backup/db', 'cluster path');
# Test invalid path type
$self->testException(sub {$oLocalFile->pathGet('bogus')}, ERROR_ASSERT, "no known path types in 'bogus'");