diff --git a/bin/pg_backrest.pl b/bin/pg_backrest.pl index 9b02831f0..58284a0ad 100755 --- a/bin/pg_backrest.pl +++ b/bin/pg_backrest.pl @@ -222,7 +222,7 @@ elsif (defined(config_load(CONFIG_SECTION_STANZA, CONFIG_KEY_HOST))) { confess &log(ERROR, 'db and backup cannot both be configured as remote'); } - + $strRemote = REMOTE_DB; } else diff --git a/lib/BackRest/File.pm b/lib/BackRest/File.pm index 40ab36af0..c278a146f 100644 --- a/lib/BackRest/File.pm +++ b/lib/BackRest/File.pm @@ -34,7 +34,7 @@ our @EXPORT = qw(PATH_ABSOLUTE PATH_DB PATH_DB_ABSOLUTE PATH_BACKUP PATH_BACKUP_ COMMAND_ERR_LINK_READ COMMAND_ERR_PATH_MISSING COMMAND_ERR_PATH_CREATE COMMAND_ERR_PARAM PIPE_STDIN PIPE_STDOUT PIPE_STDERR - + REMOTE_DB REMOTE_BACKUP REMOTE_NONE OP_FILE_LIST OP_FILE_EXISTS OP_FILE_HASH OP_FILE_REMOVE OP_FILE_MANIFEST OP_FILE_COMPRESS diff --git a/test/lib/BackRestTest/CommonTest.pm b/test/lib/BackRestTest/CommonTest.pm index dacbc4baf..13eefc3e9 100755 --- a/test/lib/BackRestTest/CommonTest.pm +++ b/test/lib/BackRestTest/CommonTest.pm @@ -16,8 +16,9 @@ use File::Basename; use Cwd 'abs_path'; use Exporter qw(import); -our @EXPORT = qw(BackRestCommonTestSetup BackRestCommonStanzaGet BackRestCommonCommandRemoteGet BackRestCommonHostGet - BackRestCommonUserGet BackRestCommonGroupGet BackRestCommonUserBackRestGet BackRestCommonTestPathGet); +our @EXPORT = qw(BackRestTestCommon_Setup BackRestTestCommon_StanzaGet BackRestTestCommon_CommandRemoteGet + BackRestTestCommon_HostGet BackRestTestCommon_UserGet BackRestTestCommon_GroupGet + BackRestTestCommon_UserBackRestGet BackRestTestCommon_TestPathGet); my $strCommonStanza; my $strCommonCommandRemote; @@ -28,9 +29,9 @@ my $strCommonUserBackRest; my $strCommonTestPath; #################################################################################################################################### -# BackRestCommonTestSetup +# BackRestTestCommon_Setup #################################################################################################################################### -sub BackRestCommonTestSetup +sub BackRestTestCommon_Setup { $strCommonStanza = "db"; $strCommonCommandRemote = "/Users/dsteele/pg_backrest/bin/pg_backrest_remote.pl"; @@ -44,37 +45,37 @@ sub BackRestCommonTestSetup #################################################################################################################################### # Get Methods #################################################################################################################################### -sub BackRestCommonStanzaGet +sub BackRestTestCommon_StanzaGet { return $strCommonStanza; } -sub BackRestCommonCommandRemoteGet +sub BackRestTestCommon_CommandRemoteGet { return $strCommonCommandRemote; } -sub BackRestCommonHostGet +sub BackRestTestCommon_HostGet { return $strCommonHost; } -sub BackRestCommonUserGet +sub BackRestTestCommon_UserGet { return $strCommonUser; } -sub BackRestCommonGroupGet +sub BackRestTestCommon_GroupGet { return $strCommonGroup; } -sub BackRestCommonUserBackRestGet +sub BackRestTestCommon_UserBackRestGet { return $strCommonUserBackRest; } -sub BackRestCommonTestPathGet +sub BackRestTestCommon_TestPathGet { return $strCommonTestPath; } diff --git a/test/lib/BackRestTest/FileTest.pm b/test/lib/BackRestTest/FileTest.pm index 77e57f435..14438bf6f 100755 --- a/test/lib/BackRestTest/FileTest.pm +++ b/test/lib/BackRestTest/FileTest.pm @@ -18,33 +18,28 @@ use File::stat; use Fcntl ':mode'; use Scalar::Util 'blessed'; -#use lib dirname($0) . "/../lib"; -use BackRestTest::CommonTest; - use lib dirname($0) . "/../lib"; use BackRest::Utility; use BackRest::File; use BackRest::Remote; +use BackRestTest::CommonTest; + use Exporter qw(import); -our @EXPORT = qw(BackRestFileTest); +our @EXPORT = qw(BackRestTestFile_Test); -# my $strTestPath; -# my $strHost; -# my $strUserBackRest; +my $strTestPath; +my $strHost; +my $strUserBackRest; #################################################################################################################################### -# BackRestFileTestSetup +# BackRestTestFile_Setup #################################################################################################################################### -sub BackRestFileTestSetup +sub BackRestTestFile_Setup { my $bPrivate = shift; my $bDropOnly = shift; - my $strTestPath = BackRestCommonTestPathGet(); - my $strUserBackRest = BackRestCommonUserBackRestGet(); - my $strHost = BackRestCommonHostGet(); - # Remove the backrest private directory if (-e "${strTestPath}/private") { @@ -68,11 +63,12 @@ sub BackRestFileTestSetup } #################################################################################################################################### -# BackRestFileTest +# BackRestTestFile_Test #################################################################################################################################### -sub BackRestFileTest +sub BackRestTestFile_Test { my $strTest = shift; + my $iTestRun = shift; # If no test was specified, then run them all if (!defined($strTest)) @@ -82,13 +78,12 @@ sub BackRestFileTest # Setup test variables my $iRun; - my $strTestPath = BackRestCommonTestPathGet(); - my $strStanza = BackRestCommonStanzaGet(); - my $strUser = BackRestCommonUserGet(); - my $strGroup = BackRestCommonGroupGet(); - - # $strHost = "127.0.0.1"; - # $strUserBackRest = 'backrest'; + $strTestPath = BackRestTestCommon_TestPathGet(); + my $strStanza = BackRestTestCommon_StanzaGet(); + my $strUser = BackRestTestCommon_UserGet(); + my $strGroup = BackRestTestCommon_GroupGet(); + $strHost = BackRestTestCommon_HostGet(); + $strUserBackRest = BackRestTestCommon_UserBackRestGet(); # Print test parameters &log(INFO, "FILE MODULE ********************************************************************"); @@ -98,9 +93,9 @@ sub BackRestFileTest #------------------------------------------------------------------------------------------------------------------------------- my $oRemote = BackRest::Remote->new ( - strHost => BackRestCommonHostGet(), + strHost => $strHost, strUser => $strUser, - strCommand => BackRestCommonCommandRemoteGet(), + strCommand => BackRestTestCommon_CommandRemoteGet(), ); #------------------------------------------------------------------------------------------------------------------------------- @@ -137,11 +132,16 @@ sub BackRestFileTest $iRun++; + if (defined($iTestRun) && $iTestRun != $iRun) + { + next; + } + &log(INFO, "run ${iRun} - " . "remote ${bRemote}, exists ${bExists}, error ${bError}, permission ${bPermission}"); # Setup test directory - BackRestFileTestSetup($bError); + BackRestTestFile_Setup($bError); mkdir("$strTestPath/backup") or confess "Unable to create test/backup directory"; mkdir("$strTestPath/backup/db") or confess "Unable to create test/backup/db directory"; @@ -153,13 +153,6 @@ sub BackRestFileTest if ($bPermission) { $strPermission = "0700"; - - # # Make sure that we are not testing with the default permission - # if ($strPermission eq $oFile->{strDefaultPathPermission}) - # { - # confess 'cannot set test permission ${strPermission} equal to default permission' . - # $oFile->{strDefaultPathPermission}; - # } } # If not exists then set the path to something bogus @@ -271,7 +264,7 @@ sub BackRestFileTest ", dst_exists $bDestinationExists, dst_error $bDestinationError, dst_create $bCreate"); # Setup test directory - BackRestFileTestSetup($bSourceError || $bDestinationError); + BackRestTestFile_Setup($bSourceError || $bDestinationError); my $strSourceFile = "${strTestPath}/test.txt"; my $strDestinationFile = "${strTestPath}/test-dest.txt"; @@ -359,7 +352,7 @@ sub BackRestFileTest "remote $bRemote, exists $bExists, error $bError"); # Setup test directory - BackRestFileTestSetup($bError); + BackRestTestFile_Setup($bError); my $strFile = "${strTestPath}/test.txt"; my $strSourceHash; @@ -463,7 +456,7 @@ sub BackRestFileTest "remote $bRemote, error $bError, exists $bExists"); # Setup test directory - BackRestFileTestSetup($bError); + BackRestTestFile_Setup($bError); # Setup test data system("mkdir -m 750 ${strTestPath}/sub1") == 0 or confess "Unable to create test directory"; @@ -633,7 +626,7 @@ sub BackRestFileTest "sort " . (defined($strSort) ? $strSort : "[undef]")); # Setup test directory - BackRestFileTestSetup($bError); + BackRestTestFile_Setup($bError); my $strPath = "${strTestPath}"; @@ -742,7 +735,7 @@ sub BackRestFileTest ", ignore missing ${bIgnoreMissing}"); # Setup test directory - BackRestFileTestSetup($bError); + BackRestTestFile_Setup($bError); my $strFile = "${strTestPath}/test.txt"; @@ -840,7 +833,7 @@ sub BackRestFileTest "remote $bRemote, error $bError, exists $bExists"); # Setup test directory - BackRestFileTestSetup($bError); + BackRestTestFile_Setup($bError); my $strFile = "${strTestPath}/test.txt"; @@ -922,7 +915,7 @@ sub BackRestFileTest "remote $bRemote, exists $bExists, error ${bError}"); # Setup test directory - BackRestFileTestSetup($bError); + BackRestTestFile_Setup($bError); my $strFile = "${strTestPath}/test.txt"; @@ -1044,7 +1037,7 @@ sub BackRestFileTest ":${strDestinationPath}, dstcmp $bDestinationCompress"); # Setup test directory - BackRestFileTestSetup(false); + BackRestTestFile_Setup(false); system("mkdir ${strTestPath}/backup") == 0 or confess "Unable to create test/backup directory"; system("mkdir ${strTestPath}/db") == 0 or confess "Unable to create test/db directory"; @@ -1151,7 +1144,7 @@ sub BackRestFileTest } } - BackRestFileTestSetup(false, true); + BackRestTestFile_Setup(false, true); } 1; diff --git a/test/test.pl b/test/test.pl index 31aae3702..c2b7ddc85 100755 --- a/test/test.pl +++ b/test/test.pl @@ -27,10 +27,12 @@ use BackRestTest::FileTest; my $strLogLevel = 'off'; # Log level for tests my $strModule = 'all'; my $strModuleTest = 'all'; +my $iModuleTestRun = undef; GetOptions ("log-level=s" => \$strLogLevel, "module=s" => \$strModule, - "module-test=s" => \$strModuleTest) + "module-test=s" => \$strModuleTest, + "module-test-run=s" => \$iModuleTestRun) or die("Error in command line arguments\n"); #################################################################################################################################### @@ -47,7 +49,13 @@ if ($strModuleTest ne 'all' && $strModule eq 'all') confess "--module must be provided for test \"${strModuleTest}\""; } -BackRestCommonTestSetup(); +if (defined($iModuleTestRun) && $strModuleTest eq 'all') +{ + confess "--module-test must be provided for run \"${iModuleTestRun}\""; +} + + +BackRestTestCommon_Setup(); #################################################################################################################################### # Clean whitespace @@ -88,7 +96,7 @@ if (!$bMatch) if ($strModule eq 'all' || $strModule eq "file") { - BackRestFileTest($strModuleTest); + BackRestTestFile_Test($strModuleTest, $iModuleTestRun); } &log(ASSERT, "TESTS COMPLETED SUCCESSFULLY (DESPITE ANY ERROR MESSAGES YOU SAW)");