You've already forked pgbackrest
							
							
				mirror of
				https://github.com/pgbackrest/pgbackrest.git
				synced 2025-10-30 23:37:45 +02:00 
			
		
		
		
	Logging enhancements:
1) Show log output realtime when --max-process=1 or only 1 test is being run. 2) Dry run now shows test output when --vm-out is specified.
This commit is contained in:
		| @@ -46,6 +46,7 @@ sub BackRestTestBackup_Test | |||||||
| { | { | ||||||
|     my $strTest = shift; |     my $strTest = shift; | ||||||
|     my $iThreadMax = shift; |     my $iThreadMax = shift; | ||||||
|  |     my $bVmOut = shift; | ||||||
|  |  | ||||||
|     # If no test was specified, then run them all |     # If no test was specified, then run them all | ||||||
|     if (!defined($strTest)) |     if (!defined($strTest)) | ||||||
| @@ -75,8 +76,11 @@ sub BackRestTestBackup_Test | |||||||
|     my $strArchiveTestFile2 = BackRestTestCommon_DataPathGet() . '/test.archive1.bin'; |     my $strArchiveTestFile2 = BackRestTestCommon_DataPathGet() . '/test.archive1.bin'; | ||||||
|  |  | ||||||
|     # Print test banner |     # Print test banner | ||||||
|     &log(INFO, 'BACKUP MODULE ******************************************************************'); |     if (!$bVmOut) | ||||||
|     &log(INFO, "THREAD-MAX: ${iThreadMax}\n"); |     { | ||||||
|  |         &log(INFO, 'BACKUP MODULE ******************************************************************'); | ||||||
|  |         &log(INFO, "THREAD-MAX: ${iThreadMax}\n"); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     # Drop any existing cluster |     # Drop any existing cluster | ||||||
|     BackRestTestBackup_Drop(true, true); |     BackRestTestBackup_Drop(true, true); | ||||||
| @@ -114,7 +118,10 @@ sub BackRestTestBackup_Test | |||||||
|         $bCreate = true; |         $bCreate = true; | ||||||
|         my $oFile; |         my $oFile; | ||||||
|  |  | ||||||
|         &log(INFO, "Test ${strThisTest}\n"); |         if (!$bVmOut) | ||||||
|  |         { | ||||||
|  |             &log(INFO, "Test ${strThisTest}\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         for (my $bRemote = false; $bRemote <= true; $bRemote++) |         for (my $bRemote = false; $bRemote <= true; $bRemote++) | ||||||
|         { |         { | ||||||
| @@ -388,7 +395,10 @@ sub BackRestTestBackup_Test | |||||||
|         $bCreate = true; |         $bCreate = true; | ||||||
|         my $oFile; |         my $oFile; | ||||||
|  |  | ||||||
|         &log(INFO, "Test ${strThisTest}\n"); |         if (!$bVmOut) | ||||||
|  |         { | ||||||
|  |             &log(INFO, "Test ${strThisTest}\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         for (my $bRemote = false; $bRemote <= true; $bRemote++) |         for (my $bRemote = false; $bRemote <= true; $bRemote++) | ||||||
|         { |         { | ||||||
| @@ -529,7 +539,10 @@ sub BackRestTestBackup_Test | |||||||
|         $bCreate = true; |         $bCreate = true; | ||||||
|         my $oFile; |         my $oFile; | ||||||
|  |  | ||||||
|         &log(INFO, "Test ${strThisTest}\n"); |         if (!$bVmOut) | ||||||
|  |         { | ||||||
|  |             &log(INFO, "Test ${strThisTest}\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         for (my $bRemote = false; $bRemote <= true; $bRemote++) |         for (my $bRemote = false; $bRemote <= true; $bRemote++) | ||||||
|         { |         { | ||||||
| @@ -694,7 +707,10 @@ sub BackRestTestBackup_Test | |||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|         my $oFile; |         my $oFile; | ||||||
|  |  | ||||||
|         &log(INFO, "Test ${strThisTest}\n"); |         if (!$bVmOut) | ||||||
|  |         { | ||||||
|  |             &log(INFO, "Test ${strThisTest}\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         if (BackRestTestCommon_Run(++$iRun, |         if (BackRestTestCommon_Run(++$iRun, | ||||||
|                                     "local", |                                     "local", | ||||||
| @@ -793,7 +809,10 @@ sub BackRestTestBackup_Test | |||||||
|     { |     { | ||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|  |  | ||||||
|         &log(INFO, "Test ${strModule} - ${strThisTest}\n"); |         if (!$bVmOut) | ||||||
|  |         { | ||||||
|  |             &log(INFO, "Test ${strModule} - ${strThisTest}\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         for (my $bRemote = false; $bRemote <= true; $bRemote++) |         for (my $bRemote = false; $bRemote <= true; $bRemote++) | ||||||
|         { |         { | ||||||
| @@ -1314,7 +1333,10 @@ sub BackRestTestBackup_Test | |||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|         $bCreate = true; |         $bCreate = true; | ||||||
|  |  | ||||||
|         &log(INFO, "Test Full Backup\n"); |         if (!$bVmOut) | ||||||
|  |         { | ||||||
|  |             &log(INFO, "Test Full Backup\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         for (my $bRemote = false; $bRemote <= true; $bRemote++) |         for (my $bRemote = false; $bRemote <= true; $bRemote++) | ||||||
|         { |         { | ||||||
| @@ -1822,7 +1844,10 @@ sub BackRestTestBackup_Test | |||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|         my $iRunMax = 1000; |         my $iRunMax = 1000; | ||||||
|  |  | ||||||
|         &log(INFO, "Test Backup Collision\n"); |         if (!$bVmOut) | ||||||
|  |         { | ||||||
|  |             &log(INFO, "Test Backup Collision\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         # Create the file object |         # Create the file object | ||||||
|         my $oFile = (BackRest::File->new |         my $oFile = (BackRest::File->new | ||||||
| @@ -1949,7 +1974,10 @@ sub BackRestTestBackup_Test | |||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|         my $iRunMax = 1000; |         my $iRunMax = 1000; | ||||||
|  |  | ||||||
|         &log(INFO, "Test Rsync Collision\n"); |         if (!$bVmOut) | ||||||
|  |         { | ||||||
|  |             &log(INFO, "Test Rsync Collision\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         # Create the file object |         # Create the file object | ||||||
|         my $oFile = (BackRest::File->new |         my $oFile = (BackRest::File->new | ||||||
|   | |||||||
| @@ -68,6 +68,7 @@ sub new | |||||||
|     $self->{bSuppressError} = defined($self->{bSuppressError}) ? $self->{bSuppressError} : false; |     $self->{bSuppressError} = defined($self->{bSuppressError}) ? $self->{bSuppressError} : false; | ||||||
|     $self->{bSuppressStdErr} = defined($self->{bSuppressStdErr}) ? $self->{bSuppressStdErr} : false; |     $self->{bSuppressStdErr} = defined($self->{bSuppressStdErr}) ? $self->{bSuppressStdErr} : false; | ||||||
|     $self->{bShowOutput} = defined($self->{bShowOutput}) ? $self->{bShowOutput} : false; |     $self->{bShowOutput} = defined($self->{bShowOutput}) ? $self->{bShowOutput} : false; | ||||||
|  |     $self->{bShowOutputAsync} = defined($self->{bShowOutputAsync}) ? $self->{bShowOutputAsync} : false; | ||||||
|     $self->{iExpectedExitStatus} = defined($self->{iExpectedExitStatus}) ? $self->{iExpectedExitStatus} : 0; |     $self->{iExpectedExitStatus} = defined($self->{iExpectedExitStatus}) ? $self->{iExpectedExitStatus} : 0; | ||||||
|     $self->{iRetrySeconds} = defined($self->{iRetrySeconds}) ? $self->{iRetrySeconds} : undef; |     $self->{iRetrySeconds} = defined($self->{iRetrySeconds}) ? $self->{iRetrySeconds} : undef; | ||||||
|  |  | ||||||
| @@ -169,9 +170,14 @@ sub endRetry | |||||||
|         # Drain the stdout stream and look for test points |         # Drain the stdout stream and look for test points | ||||||
|         while (defined(my $strLine = $self->{oIO}->lineRead(0, true, false))) |         while (defined(my $strLine = $self->{oIO}->lineRead(0, true, false))) | ||||||
|         { |         { | ||||||
|             $self->{strOutLog} .= "$strLine\n"; |             $self->{strOutLog} .= "${strLine}\n"; | ||||||
|             $bFound = true; |             $bFound = true; | ||||||
|  |  | ||||||
|  |             if ($self->{bShowOutputAsync}) | ||||||
|  |             { | ||||||
|  |                 syswrite(*STDOUT, "    ${strLine}\n") | ||||||
|  |             } | ||||||
|  |  | ||||||
|             if (defined($strTest) && testCheck($strLine, $strTest)) |             if (defined($strTest) && testCheck($strLine, $strTest)) | ||||||
|             { |             { | ||||||
|                 &log(DEBUG, "Found test ${strTest}"); |                 &log(DEBUG, "Found test ${strTest}"); | ||||||
| @@ -196,13 +202,18 @@ sub endRetry | |||||||
|     # Drain the stdout stream |     # Drain the stdout stream | ||||||
|     while (defined(my $strLine = $self->{oIO}->lineRead(0, true, false))) |     while (defined(my $strLine = $self->{oIO}->lineRead(0, true, false))) | ||||||
|     { |     { | ||||||
|         $self->{strOutLog} .= "$strLine\n"; |         $self->{strOutLog} .= "${strLine}\n"; | ||||||
|  |  | ||||||
|  |         if ($self->{bShowOutputAsync}) | ||||||
|  |         { | ||||||
|  |             syswrite(*STDOUT, "    ${strLine}\n") | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     # Drain the stderr stream |     # Drain the stderr stream | ||||||
|     while (defined(my $strLine = $self->{oIO}->lineRead(0, false, false))) |     while (defined(my $strLine = $self->{oIO}->lineRead(0, false, false))) | ||||||
|     { |     { | ||||||
|         $self->{strErrorLog} .= "$strLine\n"; |         $self->{strErrorLog} .= "${strLine}\n"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     # Pass the log to the LogTest object |     # Pass the log to the LogTest object | ||||||
|   | |||||||
| @@ -175,7 +175,7 @@ sub BackRestTestCommon_Run | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     # Return if this test should not be run |     # Return if this test should not be run | ||||||
|     if ((defined($iModuleTestRunOnly) && $iModuleTestRunOnly != $iRun) || $bDryRun) |     if (defined($iModuleTestRunOnly) && $iModuleTestRunOnly != $iRun) | ||||||
|     { |     { | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| @@ -183,6 +183,11 @@ sub BackRestTestCommon_Run | |||||||
|     # Output information about test to run |     # Output information about test to run | ||||||
|     &log(INFO, 'run ' . sprintf('%03d', $iRun) . ' - ' . $strLog); |     &log(INFO, 'run ' . sprintf('%03d', $iRun) . ' - ' . $strLog); | ||||||
|  |  | ||||||
|  |     if ($bDryRun) | ||||||
|  |     { | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     # If the module is defined then create a LogTest object |     # If the module is defined then create a LogTest object | ||||||
|     if (defined($strModuleParam)) |     if (defined($strModuleParam)) | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -239,6 +239,8 @@ our @EXPORT = qw(BackRestTestConfig_Test); | |||||||
| sub BackRestTestConfig_Test | sub BackRestTestConfig_Test | ||||||
| { | { | ||||||
|     my $strTest = shift; |     my $strTest = shift; | ||||||
|  |     my $iThreadMax = shift; | ||||||
|  |     my $bVmOut = shift; | ||||||
|  |  | ||||||
|     # Setup test variables |     # Setup test variables | ||||||
|     my $iRun; |     my $iRun; | ||||||
| @@ -252,7 +254,11 @@ sub BackRestTestConfig_Test | |||||||
|     use constant BOGUS => 'bogus'; |     use constant BOGUS => 'bogus'; | ||||||
|  |  | ||||||
|     # Print test banner |     # Print test banner | ||||||
|     &log(INFO, 'CONFIG MODULE ******************************************************************'); |     if (!$bVmOut) | ||||||
|  |     { | ||||||
|  |         &log(INFO, 'CONFIG MODULE ******************************************************************'); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     BackRestTestCommon_Drop(); |     BackRestTestCommon_Drop(); | ||||||
|  |  | ||||||
|     #------------------------------------------------------------------------------------------------------------------------------- |     #------------------------------------------------------------------------------------------------------------------------------- | ||||||
| @@ -264,7 +270,10 @@ sub BackRestTestConfig_Test | |||||||
|     { |     { | ||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|  |  | ||||||
|         &log(INFO, "Test ${strThisTest}\n"); |         if (!$bVmOut) | ||||||
|  |         { | ||||||
|  |             &log(INFO, "Test ${strThisTest}\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         if (BackRestTestCommon_Run(++$iRun, 'backup with no stanza')) |         if (BackRestTestCommon_Run(++$iRun, 'backup with no stanza')) | ||||||
|         { |         { | ||||||
| @@ -552,7 +561,10 @@ sub BackRestTestConfig_Test | |||||||
|     { |     { | ||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|  |  | ||||||
|         &log(INFO, "Test ${strThisTest}\n"); |         if (!$bVmOut) | ||||||
|  |         { | ||||||
|  |             &log(INFO, "Test ${strThisTest}\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         BackRestTestCommon_Create(); |         BackRestTestCommon_Create(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -75,6 +75,8 @@ our @EXPORT = qw(BackRestTestFile_Test); | |||||||
| sub BackRestTestFile_Test | sub BackRestTestFile_Test | ||||||
| { | { | ||||||
|     my $strTest = shift; |     my $strTest = shift; | ||||||
|  |     my $iThreadMax = shift; | ||||||
|  |     my $bVmOut = shift; | ||||||
|  |  | ||||||
|     # If no test was specified, then run them all |     # If no test was specified, then run them all | ||||||
|     if (!defined($strTest)) |     if (!defined($strTest)) | ||||||
| @@ -92,7 +94,10 @@ sub BackRestTestFile_Test | |||||||
|     $strUserBackRest = BackRestTestCommon_UserBackRestGet(); |     $strUserBackRest = BackRestTestCommon_UserBackRestGet(); | ||||||
|  |  | ||||||
|     # Print test banner |     # Print test banner | ||||||
|     &log(INFO, 'FILE MODULE ********************************************************************'); |     if (!$bVmOut) | ||||||
|  |     { | ||||||
|  |         &log(INFO, 'FILE MODULE ********************************************************************'); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     #------------------------------------------------------------------------------------------------------------------------------- |     #------------------------------------------------------------------------------------------------------------------------------- | ||||||
|     # Create remotes |     # Create remotes | ||||||
| @@ -125,7 +130,10 @@ sub BackRestTestFile_Test | |||||||
|     { |     { | ||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|  |  | ||||||
|         &log(INFO, "Test File->pathCreate()\n"); |         if (!$bVmOut) | ||||||
|  |         { | ||||||
|  |             &log(INFO, "Test File->pathCreate()\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         # Loop through local/remote |         # Loop through local/remote | ||||||
|         for (my $bRemote = 0; $bRemote <= 1; $bRemote++) |         for (my $bRemote = 0; $bRemote <= 1; $bRemote++) | ||||||
| @@ -234,8 +242,10 @@ sub BackRestTestFile_Test | |||||||
|     { |     { | ||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|  |  | ||||||
|         &log(INFO, '--------------------------------------------------------------------------------'); |         if (!$bVmOut) | ||||||
|         &log(INFO, "Test File->move()\n"); |         { | ||||||
|  |             &log(INFO, "Test File->move()\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         for (my $bRemote = 0; $bRemote <= 0; $bRemote++) |         for (my $bRemote = 0; $bRemote <= 0; $bRemote++) | ||||||
|         { |         { | ||||||
| @@ -333,8 +343,10 @@ sub BackRestTestFile_Test | |||||||
|     { |     { | ||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|  |  | ||||||
|         &log(INFO, '--------------------------------------------------------------------------------'); |         if (!$bVmOut) | ||||||
|         &log(INFO, "Test File->compress()\n"); |         { | ||||||
|  |             &log(INFO, "Test File->compress()\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         for (my $bRemote = 0; $bRemote <= 0; $bRemote++) |         for (my $bRemote = 0; $bRemote <= 0; $bRemote++) | ||||||
|         { |         { | ||||||
| @@ -425,8 +437,10 @@ sub BackRestTestFile_Test | |||||||
|     { |     { | ||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|  |  | ||||||
|         &log(INFO, '--------------------------------------------------------------------------------'); |         if (!$bVmOut) | ||||||
|         &log(INFO, "Test File->wait()\n"); |         { | ||||||
|  |             &log(INFO, "Test File->wait()\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         for (my $bRemote = 0; $bRemote <= 1; $bRemote++) |         for (my $bRemote = 0; $bRemote <= 1; $bRemote++) | ||||||
|         { |         { | ||||||
| @@ -482,8 +496,10 @@ sub BackRestTestFile_Test | |||||||
|     { |     { | ||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|  |  | ||||||
|         &log(INFO, '--------------------------------------------------------------------------------'); |         if (!$bVmOut) | ||||||
|         &log(INFO, "Test File->manifest()\n"); |         { | ||||||
|  |             &log(INFO, "Test File->manifest()\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         my $strManifestCompare = |         my $strManifestCompare = | ||||||
|             ".,d,${strUser},${strGroup},0770,,,,\n" . |             ".,d,${strUser},${strGroup},0770,,,,\n" . | ||||||
| @@ -636,8 +652,10 @@ sub BackRestTestFile_Test | |||||||
|     { |     { | ||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|  |  | ||||||
|         &log(INFO, '--------------------------------------------------------------------------------'); |         if (!$bVmOut) | ||||||
|         &log(INFO, "Test File->list()\n"); |         { | ||||||
|  |             &log(INFO, "Test File->list()\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         for (my $bRemote = false; $bRemote <= true; $bRemote++) |         for (my $bRemote = false; $bRemote <= true; $bRemote++) | ||||||
|         { |         { | ||||||
| @@ -763,8 +781,10 @@ sub BackRestTestFile_Test | |||||||
|     { |     { | ||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|  |  | ||||||
|         &log(INFO, '--------------------------------------------------------------------------------'); |         if (!$bVmOut) | ||||||
|         &log(INFO, "Test File->remove()\n"); |         { | ||||||
|  |             &log(INFO, "Test File->remove()\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         for (my $bRemote = 0; $bRemote <= 1; $bRemote++) |         for (my $bRemote = 0; $bRemote <= 1; $bRemote++) | ||||||
|         { |         { | ||||||
| @@ -866,8 +886,10 @@ sub BackRestTestFile_Test | |||||||
|     { |     { | ||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|  |  | ||||||
|         &log(INFO, '--------------------------------------------------------------------------------'); |         if (!$bVmOut) | ||||||
|         &log(INFO, "test File->hash()\n"); |         { | ||||||
|  |             &log(INFO, "test File->hash()\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         for (my $bRemote = false; $bRemote <= true; $bRemote++) |         for (my $bRemote = false; $bRemote <= true; $bRemote++) | ||||||
|         { |         { | ||||||
| @@ -957,8 +979,10 @@ sub BackRestTestFile_Test | |||||||
|     { |     { | ||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|  |  | ||||||
|         &log(INFO, '--------------------------------------------------------------------------------'); |         if (!$bVmOut) | ||||||
|         &log(INFO, "test File->exists()\n"); |         { | ||||||
|  |             &log(INFO, "test File->exists()\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         for (my $bRemote = 0; $bRemote <= 1; $bRemote++) |         for (my $bRemote = 0; $bRemote <= 1; $bRemote++) | ||||||
|         { |         { | ||||||
|   | |||||||
| @@ -38,13 +38,18 @@ our @EXPORT = qw(BackRestTestHelp_Test); | |||||||
| sub BackRestTestHelp_Test | sub BackRestTestHelp_Test | ||||||
| { | { | ||||||
|     my $strTest = shift; |     my $strTest = shift; | ||||||
|  |     my $iThreadMax = shift; | ||||||
|  |     my $bVmOut = shift; | ||||||
|  |  | ||||||
|     # Setup test variables |     # Setup test variables | ||||||
|     my $iRun; |     my $iRun; | ||||||
|     my $strModule = 'help'; |     my $strModule = 'help'; | ||||||
|  |  | ||||||
|     # Print test banner |     # Print test banner | ||||||
|     &log(INFO, 'HELP MODULE *****************************************************************'); |     if (!$bVmOut) | ||||||
|  |     { | ||||||
|  |         &log(INFO, 'HELP MODULE *****************************************************************'); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     #------------------------------------------------------------------------------------------------------------------------------- |     #------------------------------------------------------------------------------------------------------------------------------- | ||||||
|     # Test config |     # Test config | ||||||
| @@ -55,7 +60,10 @@ sub BackRestTestHelp_Test | |||||||
|     { |     { | ||||||
|         $iRun = 0; |         $iRun = 0; | ||||||
|  |  | ||||||
|         &log(INFO, "Test help\n"); |         if (!$bVmOut) | ||||||
|  |         { | ||||||
|  |             &log(INFO, "Test help\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         BackRestTestCommon_Drop(true); |         BackRestTestCommon_Drop(true); | ||||||
|         BackRestTestCommon_Create(); |         BackRestTestCommon_Create(); | ||||||
|   | |||||||
							
								
								
									
										78
									
								
								test/test.pl
									
									
									
									
									
								
							
							
						
						
									
										78
									
								
								test/test.pl
									
									
									
									
									
								
							| @@ -379,8 +379,10 @@ eval | |||||||
|                                 if ($iDbVersionIdx == -1 || $strDbVersion eq 'all' || |                                 if ($iDbVersionIdx == -1 || $strDbVersion eq 'all' || | ||||||
|                                     ($strDbVersion ne 'all' && $strDbVersion eq ${$$oyVm{$strTestOS}{db}}[$iDbVersionIdx])) |                                     ($strDbVersion ne 'all' && $strDbVersion eq ${$$oyVm{$strTestOS}{db}}[$iDbVersionIdx])) | ||||||
|                                 { |                                 { | ||||||
|                                     my $iTestRunMin = defined($iModuleTestRun) ? $iModuleTestRun : (defined($$oTest{total}) ? 1 : -1); |                                     my $iTestRunMin = defined($iModuleTestRun) ? | ||||||
|                                     my $iTestRunMax = defined($iModuleTestRun) ? $iModuleTestRun : (defined($$oTest{total}) ? $$oTest{total} : -1); |                                                           $iModuleTestRun : (defined($$oTest{total}) ? 1 : -1); | ||||||
|  |                                     my $iTestRunMax = defined($iModuleTestRun) ? | ||||||
|  |                                                           $iModuleTestRun : (defined($$oTest{total}) ? $$oTest{total} : -1); | ||||||
|  |  | ||||||
|                                     if (defined($$oTest{total}) && $iTestRunMax > $$oTest{total}) |                                     if (defined($$oTest{total}) && $iTestRunMax > $$oTest{total}) | ||||||
|                                     { |                                     { | ||||||
| @@ -431,7 +433,7 @@ eval | |||||||
|         my $iTestFail = 0; |         my $iTestFail = 0; | ||||||
|         my $oyProcess = []; |         my $oyProcess = []; | ||||||
|  |  | ||||||
|         if (!$bDryRun) |         if (!$bDryRun || $bVmOut) | ||||||
|         { |         { | ||||||
|             for (my $iProcessIdx = 0; $iProcessIdx < 8; $iProcessIdx++) |             for (my $iProcessIdx = 0; $iProcessIdx < 8; $iProcessIdx++) | ||||||
|             { |             { | ||||||
| @@ -441,12 +443,17 @@ eval | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         if ($bDryRun) | ||||||
|  |         { | ||||||
|  |             $iProcessMax = 1; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         my $iTestIdx = 0; |         my $iTestIdx = 0; | ||||||
|         my $iProcessTotal; |         my $iProcessTotal; | ||||||
|         my $iTestMax = @{$oyTestRun}; |         my $iTestMax = @{$oyTestRun}; | ||||||
|         my $lStartTime = time(); |         my $lStartTime = time(); | ||||||
|  |         my $bShowOutputAsync = $bVmOut && (@{$oyTestRun} == 1 || $iProcessMax == 1) && ! $bDryRun ? true : false; | ||||||
|  |  | ||||||
|         # foreach my $oTest (@{$oyTestRun}) |  | ||||||
|         do |         do | ||||||
|         { |         { | ||||||
|             do |             do | ||||||
| @@ -465,19 +472,25 @@ eval | |||||||
|  |  | ||||||
|                         if (defined($iExitStatus)) |                         if (defined($iExitStatus)) | ||||||
|                         { |                         { | ||||||
|  |                             if ($bShowOutputAsync) | ||||||
|  |                             { | ||||||
|  |                                 syswrite(*STDOUT, "\n"); | ||||||
|  |                             } | ||||||
|  |  | ||||||
|                             my $fTestElapsedTime = ceil((gettimeofday() - $$oyProcess[$iProcessIdx]{start_time}) * 100) / 100; |                             my $fTestElapsedTime = ceil((gettimeofday() - $$oyProcess[$iProcessIdx]{start_time}) * 100) / 100; | ||||||
|  |  | ||||||
|                             if (!($iExitStatus == 0 || $iExitStatus == 255)) |                             if (!($iExitStatus == 0 || $iExitStatus == 255)) | ||||||
|                             { |                             { | ||||||
|                                 &log(ERROR, "${strTestDone} (err${iExitStatus}-${fTestElapsedTime}s)" . |                                 &log(ERROR, "${strTestDone} (err${iExitStatus}-${fTestElapsedTime}s)" . | ||||||
|                                      (defined($oExecDone->{strOutLog}) ? ":\n\n" . trim($oExecDone->{strOutLog}) . "\n" : ''), |                                      (defined($oExecDone->{strOutLog}) && !$bShowOutputAsync ? | ||||||
|                                      undef, undef, 4); |                                         ":\n\n" . trim($oExecDone->{strOutLog}) . "\n" : ''), undef, undef, 4); | ||||||
|                                 $iTestFail++; |                                 $iTestFail++; | ||||||
|                             } |                             } | ||||||
|                             else |                             else | ||||||
|                             { |                             { | ||||||
|                                 &log( INFO, "${strTestDone} (${fTestElapsedTime}s)". |                                 &log(INFO, "${strTestDone} (${fTestElapsedTime}s)". | ||||||
|                                             ($bVmOut ? ":\n\n" . trim($oExecDone->{strOutLog}) . "\n" : ''), undef, undef, 4); |                                      ($bVmOut && !$bShowOutputAsync ? | ||||||
|  |                                          ":\n\n" . trim($oExecDone->{strOutLog}) . "\n" : ''), undef, undef, 4); | ||||||
|                             } |                             } | ||||||
|  |  | ||||||
|                             if (!$bNoCleanup) |                             if (!$bNoCleanup) | ||||||
| @@ -517,9 +530,10 @@ eval | |||||||
|  |  | ||||||
|                     my $strImage = 'test-' . $iProcessIdx; |                     my $strImage = 'test-' . $iProcessIdx; | ||||||
|  |  | ||||||
|                     &log($bDryRun ? INFO : DEBUG, $strTest); |                     &log($bDryRun && !$bVmOut || $bShowOutputAsync ? INFO : DEBUG, "${strTest}" . | ||||||
|  |                          ($bVmOut || $bShowOutputAsync ? "\n" : '')); | ||||||
|  |  | ||||||
|                     if (!$bDryRun) |                     if (!$bDryRun || $bVmOut) | ||||||
|                     { |                     { | ||||||
|                         executeTest("docker run -itd -h $$oTest{os}-test --name=${strImage}" . |                         executeTest("docker run -itd -h $$oTest{os}-test --name=${strImage}" . | ||||||
|                                     " -v /backrest:/backrest backrest/$$oTest{os}-test"); |                                     " -v /backrest:/backrest backrest/$$oTest{os}-test"); | ||||||
| @@ -537,14 +551,17 @@ eval | |||||||
|                                      (defined($$oTest{run}) ? " --run=$$oTest{run}" : '') . |                                      (defined($$oTest{run}) ? " --run=$$oTest{run}" : '') . | ||||||
|                                      (defined($$oTest{thread}) ? " --thread-max=$$oTest{thread}" : '') . |                                      (defined($$oTest{thread}) ? " --thread-max=$$oTest{thread}" : '') . | ||||||
|                                      (defined($$oTest{db}) ? " --db-version=$$oTest{db}" : '') . |                                      (defined($$oTest{db}) ? " --db-version=$$oTest{db}" : '') . | ||||||
|                                      " --no-cleanup"; |                                      ($bDryRun ? " --dry-run" : '') . | ||||||
|  |                                      " --no-cleanup --vm-out"; | ||||||
|  |  | ||||||
|                     &log(DEBUG, $strCommand); |                     &log(DEBUG, $strCommand); | ||||||
|  |  | ||||||
|                     if (!$bDryRun) |                     if (!$bDryRun || $bVmOut) | ||||||
|                     { |                     { | ||||||
|                         my $fTestStartTime = gettimeofday(); |                         my $fTestStartTime = gettimeofday(); | ||||||
|                         my $oExec = new BackRestTest::Common::ExecuteTest($strCommand, {bSuppressError => true}); |                         my $oExec = new BackRestTest::Common::ExecuteTest( | ||||||
|  |                             $strCommand, | ||||||
|  |                             {bSuppressError => true, bShowOutputAsync => $bShowOutputAsync}); | ||||||
|  |  | ||||||
|                         $oExec->begin(); |                         $oExec->begin(); | ||||||
|  |  | ||||||
| @@ -565,8 +582,15 @@ eval | |||||||
|         } |         } | ||||||
|         while ($iProcessTotal > 0); |         while ($iProcessTotal > 0); | ||||||
|  |  | ||||||
|         &log(INFO, 'TESTS COMPLETED ' . ($iTestFail == 0 ? 'SUCCESSFULLY' : "WITH ${iTestFail} FAILURE(S)") . |         if ($bDryRun) | ||||||
|                    ' (' . (time() - $lStartTime) . 's)'); |         { | ||||||
|  |             &log(INFO, 'DRY RUN COMPLETED'); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             &log(INFO, 'TESTS COMPLETED ' . ($iTestFail == 0 ? 'SUCCESSFULLY' : "WITH ${iTestFail} FAILURE(S)") . | ||||||
|  |                        ' (' . (time() - $lStartTime) . 's)'); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         exit 0; |         exit 0; | ||||||
|     } |     } | ||||||
| @@ -600,7 +624,7 @@ eval | |||||||
|  |  | ||||||
|                     if (-e "${strVersionPath}/initdb") |                     if (-e "${strVersionPath}/initdb") | ||||||
|                     { |                     { | ||||||
|                         &log(INFO, "FOUND pgsql-bin at ${strVersionPath}"); |                         &log(DEBUG, "FOUND pgsql-bin at ${strVersionPath}"); | ||||||
|                         push @stryTestVersion, $strVersionPath; |                         push @stryTestVersion, $strVersionPath; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
| @@ -641,7 +665,13 @@ eval | |||||||
|         if (BackRestTestCommon_Setup($strExe, $strTestPath, $stryTestVersion[0], $iModuleTestRun, |         if (BackRestTestCommon_Setup($strExe, $strTestPath, $stryTestVersion[0], $iModuleTestRun, | ||||||
|                                      $bDryRun, $bNoCleanup, $bLogForce)) |                                      $bDryRun, $bNoCleanup, $bLogForce)) | ||||||
|         { |         { | ||||||
|             &log(INFO, "TESTING psql-bin = $stryTestVersion[0]\n"); |             if (!$bVmOut && | ||||||
|  |                 ($strModule eq 'all' || | ||||||
|  |                  $strModule eq 'backup' && $strModuleTest eq 'all' || | ||||||
|  |                  $strModule eq 'backup' && $strModuleTest eq 'full')) | ||||||
|  |             { | ||||||
|  |                 &log(INFO, "TESTING psql-bin = $stryTestVersion[0]\n"); | ||||||
|  |             } | ||||||
|  |  | ||||||
|             if ($bInfinite) |             if ($bInfinite) | ||||||
|             { |             { | ||||||
| @@ -656,29 +686,29 @@ eval | |||||||
|  |  | ||||||
|             if ($strModule eq 'all' || $strModule eq 'help') |             if ($strModule eq 'all' || $strModule eq 'help') | ||||||
|             { |             { | ||||||
|                 BackRestTestHelp_Test($strModuleTest); |                 BackRestTestHelp_Test($strModuleTest, undef, $bVmOut); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if ($strModule eq 'all' || $strModule eq 'config') |             if ($strModule eq 'all' || $strModule eq 'config') | ||||||
|             { |             { | ||||||
|                 BackRestTestConfig_Test($strModuleTest); |                 BackRestTestConfig_Test($strModuleTest, undef, $bVmOut); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if ($strModule eq 'all' || $strModule eq 'file') |             if ($strModule eq 'all' || $strModule eq 'file') | ||||||
|             { |             { | ||||||
|                 BackRestTestFile_Test($strModuleTest); |                 BackRestTestFile_Test($strModuleTest, undef, $bVmOut); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if ($strModule eq 'all' || $strModule eq 'backup') |             if ($strModule eq 'all' || $strModule eq 'backup') | ||||||
|             { |             { | ||||||
|                 if (!defined($iThreadMax) || $iThreadMax == 1) |                 if (!defined($iThreadMax) || $iThreadMax == 1) | ||||||
|                 { |                 { | ||||||
|                     BackRestTestBackup_Test($strModuleTest, 1); |                     BackRestTestBackup_Test($strModuleTest, 1, $bVmOut); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 if (!defined($iThreadMax) || $iThreadMax > 1) |                 if (!defined($iThreadMax) || $iThreadMax > 1) | ||||||
|                 { |                 { | ||||||
|                     BackRestTestBackup_Test($strModuleTest, defined($iThreadMax) ? $iThreadMax : 4); |                     BackRestTestBackup_Test($strModuleTest, defined($iThreadMax) ? $iThreadMax : 4, $bVmOut); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 if (@stryTestVersion > 1 && ($strModuleTest eq 'all' || $strModuleTest eq 'full')) |                 if (@stryTestVersion > 1 && ($strModuleTest eq 'all' || $strModuleTest eq 'full')) | ||||||
| @@ -688,7 +718,7 @@ eval | |||||||
|                         BackRestTestCommon_Setup($strExe, $strTestPath, $stryTestVersion[$iVersionIdx], |                         BackRestTestCommon_Setup($strExe, $strTestPath, $stryTestVersion[$iVersionIdx], | ||||||
|                                                  $iModuleTestRun, $bDryRun, $bNoCleanup); |                                                  $iModuleTestRun, $bDryRun, $bNoCleanup); | ||||||
|                         &log(INFO, "TESTING psql-bin = $stryTestVersion[$iVersionIdx] for backup/full\n"); |                         &log(INFO, "TESTING psql-bin = $stryTestVersion[$iVersionIdx] for backup/full\n"); | ||||||
|                         BackRestTestBackup_Test('full', defined($iThreadMax) ? $iThreadMax : 4); |                         BackRestTestBackup_Test('full', defined($iThreadMax) ? $iThreadMax : 4, $bVmOut); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -717,7 +747,7 @@ if ($@) | |||||||
|     exit 250; |     exit 250; | ||||||
| } | } | ||||||
|  |  | ||||||
| if (!$bDryRun) | if (!$bDryRun && !$bVmOut) | ||||||
| { | { | ||||||
|     &log(INFO, 'TESTS COMPLETED SUCCESSFULLY (DESPITE ANY ERROR MESSAGES YOU SAW)'); |     &log(INFO, 'TESTS COMPLETED SUCCESSFULLY (DESPITE ANY ERROR MESSAGES YOU SAW)'); | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user