From a3b3f98f66e6e36154831800434e1a7ad3dac431 Mon Sep 17 00:00:00 2001 From: David Steele Date: Thu, 22 Jan 2015 20:55:16 -0500 Subject: [PATCH] Fixed some issues with remote backups after restore (unit test bugs only). --- test/lib/BackRestTest/BackupTest.pm | 17 +++++++++-------- test/lib/BackRestTest/CommonTest.pm | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/test/lib/BackRestTest/BackupTest.pm b/test/lib/BackRestTest/BackupTest.pm index 2aa1ad789..14d523695 100755 --- a/test/lib/BackRestTest/BackupTest.pm +++ b/test/lib/BackRestTest/BackupTest.pm @@ -790,6 +790,7 @@ sub BackRestTestBackup_Restore my $oFile = shift; my $strBackup = shift; my $strStanza = shift; + my $bRemote = shift; my $oExpectedManifestRef = shift; my $oRemapHashRef = shift; my $bDelta = shift; @@ -800,15 +801,15 @@ sub BackRestTestBackup_Restore $bDelta = defined($bDelta) ? $bDelta : false; $bForce = defined($bForce) ? $bForce : false; - if (defined($oRemapHashRef)) - { - BackRestTestCommon_ConfigRemap($oRemapHashRef, $oExpectedManifestRef); - } - &log(INFO, ' ' . ($bDelta ? 'delta ' : '') . ($bForce ? 'force ' : '') . (defined($oRemapHashRef) ? 'remap ' : '') . 'restore' . (defined($strComment) ? " (${strComment})" : '')); + if (defined($oRemapHashRef)) + { + BackRestTestCommon_ConfigRemap($oRemapHashRef, $oExpectedManifestRef, $bRemote); + } + # Create the backup command BackRestTestCommon_Execute(BackRestTestCommon_CommandMainGet() . ' --config=' . BackRestTestCommon_DbPathGet() . '/pg_backrest.conf' . (defined($bDelta) && $bDelta ? ' --delta' : '') . @@ -1249,7 +1250,7 @@ sub BackRestTestBackup_Test # Remove a file BackRestTestBackup_FileRemove(\%oManifest, 'base', 'PG_VERSION'); - BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, \%oManifest, undef, $bDelta, $bForce, + BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, $bRemote, \%oManifest, undef, $bDelta, $bForce, 'add and delete files'); # Incr backup - add a tablespace @@ -1299,9 +1300,9 @@ sub BackRestTestBackup_Test # Remap the base path my %oRemapHash; $oRemapHash{base} = BackRestTestCommon_DbCommonPathGet(2); -# $oRemapHash{1} = BackRestTestCommon_DbTablespacePathGet(1, 2); + $oRemapHash{1} = BackRestTestCommon_DbTablespacePathGet(1, 2); - BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, \%oManifest, \%oRemapHash, $bDelta, $bForce, + BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, $bRemote, \%oManifest, \%oRemapHash, $bDelta, $bForce, 'remap base path'); # Incr Backup diff --git a/test/lib/BackRestTest/CommonTest.pm b/test/lib/BackRestTest/CommonTest.pm index 56f4e3720..6c33c7337 100755 --- a/test/lib/BackRestTest/CommonTest.pm +++ b/test/lib/BackRestTest/CommonTest.pm @@ -418,6 +418,7 @@ sub BackRestTestCommon_ConfigRemap { my $oRemapHashRef = shift; my $oManifestRef = shift; + my $bRemote = shift; # Create config filename my $strConfigFile = BackRestTestCommon_DbPathGet() . '/pg_backrest.conf'; @@ -427,6 +428,16 @@ sub BackRestTestCommon_ConfigRemap my %oConfig; ini_load($strConfigFile, \%oConfig); + # Load remote config file + my %oRemoteConfig; + my $strRemoteConfigFile = BackRestTestCommon_TestPathGet() . '/pg_backrest.conf.remote'; + + if ($bRemote) + { + BackRestTestCommon_Execute("mv " . BackRestTestCommon_BackupPathGet() . "/pg_backrest.conf ${strRemoteConfigFile}", true); + ini_load($strRemoteConfigFile, \%oRemoteConfig); + } + # Rewrite remap section delete($oConfig{"${strStanza}:tablespace:map"}); @@ -438,6 +449,11 @@ sub BackRestTestCommon_ConfigRemap { $oConfig{$strStanza}{path} = $strRemapPath; ${$oManifestRef}{'backup:path'}{base} = $strRemapPath; + + if ($bRemote) + { + $oRemoteConfig{$strStanza}{path} = $strRemapPath; + } } else { @@ -451,6 +467,13 @@ sub BackRestTestCommon_ConfigRemap # Resave the config file ini_save($strConfigFile, \%oConfig); + + # Load remote config file + if ($bRemote) + { + ini_save($strRemoteConfigFile, \%oRemoteConfig); + BackRestTestCommon_Execute("mv ${strRemoteConfigFile} " . BackRestTestCommon_BackupPathGet() . '/pg_backrest.conf', true); + } } ####################################################################################################################################