pgbackrest.git / summary / log / commit / refs

commit    9765b4e20b0d1e3878806387ccf0f0cda124abbe
Author:   David Steele <david@pgmasters.net>
Date:     Sun Oct 19 21:41:11 2014 +0000

    Backup unit test - more work on tablespaces and references.


test/lib/BackRestTest/BackupTest.pm | 86 ++++++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 20 deletions(-) diff --git a/test/lib/BackRestTest/BackupTest.pm b/test/lib/BackRestTest/BackupTest.pm index 05a014b05..7daf00c20 100755 --- a/test/lib/BackRestTest/BackupTest.pm +++ b/test/lib/BackRestTest/BackupTest.pm @@ -366,10 +366,9 @@ sub BackRestTestBackup_ManifestReference # Set prior backup ${$oManifestRef}{backup}{prior} = $strReference; + delete(${$oManifestRef}{backup}{reference}); # Find all file sections - my $iTotal = 0; - foreach my $strSectionFile (sort(keys $oManifestRef)) { # Skip non-file sections @@ -383,23 +382,6 @@ sub BackRestTestBackup_ManifestReference if (!defined(${$oManifestRef}{$strSectionFile}{$strFile}{reference})) { ${$oManifestRef}{$strSectionFile}{$strFile}{reference} = $strReference; - $iTotal++; - } - } - } - - if ($iTotal > 0) - { - - if (!defined(${$oManifestRef}{backup}{reference})) - { - ${$oManifestRef}{backup}{reference} = $strReference; - } - else - { - if (${$oManifestRef}{backup}{reference} !~ /$strReference/) - { - ${$oManifestRef}{backup}{reference} .= ",${strReference}"; } } } @@ -434,6 +416,39 @@ sub BackRestTestBackup_CompareBackup ${$oExpectedManifestRef}{backup}{label} = $strBackup; + # Remove old reference list + delete(${$oExpectedManifestRef}{backup}{reference}); + + # Build the new reference list + foreach my $strSectionFile (sort(keys $oExpectedManifestRef)) + { + # Skip non-file sections + if ($strSectionFile !~ /\:file$/) + { + next; + } + + foreach my $strFile (sort(keys ${$oExpectedManifestRef}{$strSectionFile})) + { + if (defined(${$oExpectedManifestRef}{$strSectionFile}{$strFile}{reference})) + { + my $strFileReference = ${$oExpectedManifestRef}{$strSectionFile}{$strFile}{reference}; + + if (!defined(${$oExpectedManifestRef}{backup}{reference})) + { + ${$oExpectedManifestRef}{backup}{reference} = $strFileReference; + } + else + { + if (${$oExpectedManifestRef}{backup}{reference} !~ /$strFileReference/) + { + ${$oExpectedManifestRef}{backup}{reference} .= ",${strFileReference}"; + } + } + } + } + } + # Change permissions on the backup path so it can be read if ($bRemote) { @@ -820,6 +835,9 @@ sub BackRestTestBackup_Test $bRemote ? $oRemote : undef ); + BackRestTestBackup_ManifestFileCreate(\%oManifest, 'base', 'PG_VERSION', '9.3', + $bChecksum ? 'e1f7a3a299f62225cba076fc6d3d6e677f303482' : undef, $lTime); + # Create base path BackRestTestBackup_ManifestPathCreate(\%oManifest, 'base', 'base'); @@ -833,7 +851,7 @@ sub BackRestTestBackup_Test { BackRestTestBackup_ManifestTablespaceCreate(\%oManifest, $iTablespaceIdx); - BackRestTestBackup_ManifestFileCreate(\%oManifest, "tablespace:${iTablespaceIdx}", 'tablespace.txt', 'TBLSPC', + BackRestTestBackup_ManifestFileCreate(\%oManifest, "tablespace:${iTablespaceIdx}", 'tablespace1.txt', 'TBLSPC', $bChecksum ? '44ad0bf042936c576c75891d0e5ded8e2b60fb54' : undef, $lTime); } @@ -899,6 +917,34 @@ sub BackRestTestBackup_Test BackRestTestBackup_ManifestFileCreate(\%oManifest, 'base', 'base/base2.txt', 'BASE2', $bChecksum ? '09b5e31766be1dba1ec27de82f975c1b6eea2a92' : undef, $lTime); + for (my $iTablespaceIdx = 1; $iTablespaceIdx <= $iTablespaceTotal; $iTablespaceIdx++) + { + BackRestTestBackup_ManifestFileCreate(\%oManifest, "tablespace:${iTablespaceIdx}", 'tablespace2.txt', 'TBLSPC2', + $bChecksum ? 'dc7f76e43c46101b47acc55ae4d593a9e6983578' : undef, $lTime); + } + + BackRestTestCommon_Execute("${strCommand} --type=${strType}", $bRemote); + + $oManifest{backup}{type} = $strType; + $strBackup = BackRestTestBackup_LastBackup($oFile); + + BackRestTestBackup_CompareBackup($oFile, $bRemote, BackRestTestBackup_LastBackup($oFile), \%oManifest); + + # Perform third incr backup + BackRestTestBackup_ManifestReference(\%oManifest, $strBackup); + + $strType = 'incr'; + &log(INFO, " ${strType} backup (update files)"); + + BackRestTestBackup_ManifestFileCreate(\%oManifest, 'base', 'base/base1.txt', 'BASEUPDT', + $bChecksum ? '9a53d532e27785e681766c98516a5e93f096a501' : undef, $lTime); + + for (my $iTablespaceIdx = 1; $iTablespaceIdx <= $iTablespaceTotal; $iTablespaceIdx++) + { + BackRestTestBackup_ManifestFileCreate(\%oManifest, "tablespace:${iTablespaceIdx}", 'tablespace1.txt', 'TBLSPCUPDT', + $bChecksum ? 'ff21d59b07e8d9cfa7b1286202610550a71884b5' : undef, $lTime); + } + BackRestTestCommon_Execute("${strCommand} --type=${strType}", $bRemote); $oManifest{backup}{type} = $strType; [parent: 66a5da6fd175]