Francois Gouget : testbot: Separate the per-task task and testbot logs.

Alexandre Julliard julliard at winehq.org
Tue Feb 4 13:03:07 CST 2020


Module: tools
Branch: master
Commit: c6ea1c622ac67d66f1c157b3aec8f7320036c242
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=c6ea1c622ac67d66f1c157b3aec8f7320036c242

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Tue Feb  4 03:50:16 2020 +0100

testbot: Separate the per-task task and testbot logs.

Each task has pairs of xxx.report and xxx.report.err files where the
.err file contains extra errors detected while parsing xxx.report and
can thus be rebuilt from the report files.
They also have log and log.err files but log.err is completely
independent from the log file:
* log contains the traces printed by the script running on the VM,
  typically the build log or batch file commands.
* log.err contains errors that occurred on the TestBot-server side, such
  as perl errors in the WineRun* scripts, or messages when the TestBot
  had to kill a stuck task.
So rename log to task.log and log.err to testbot.log. This way their
purpose is clearer and log.err does not run the risk of being
confused with the other .err files.

Note:
* After applying this patch run UpdateTaskLogs to move and rename the
  existing reference reports.
* It is not necessary to run UpdateTaskLogs when downgrading to run
  code just before this patch. However one can use the following
  commands to rename the task and testbot logs:
  find jobs -name task.log | while read f;do echo mv "$f" `dirname "$f"`/log;done
  find jobs -name testbot.log | while read f;do mv "$f" `dirname "$f"`/log.err;done

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/bin/UpdateTaskLogs          | 20 ++++++++++++++++++++
 testbot/bin/WineRunBuild.pl         |  8 ++++----
 testbot/bin/WineRunReconfig.pl      |  8 ++++----
 testbot/bin/WineRunTask.pl          |  6 +++---
 testbot/bin/WineRunWineTest.pl      |  8 ++++----
 testbot/lib/WineTestBot/LogUtils.pm | 22 ++++++++++++----------
 testbot/lib/WineTestBot/Tasks.pm    | 10 +++++-----
 7 files changed, 52 insertions(+), 30 deletions(-)

diff --git a/testbot/bin/UpdateTaskLogs b/testbot/bin/UpdateTaskLogs
index 11dd6d3..4ba383f 100755
--- a/testbot/bin/UpdateTaskLogs
+++ b/testbot/bin/UpdateTaskLogs
@@ -342,6 +342,26 @@ sub ProcessTaskLogs($$$)
       }
       $Rc += Delete($StepReportPath, "unneeded");
     }
+
+    my %LogMap = (
+      "log"         => "task.log",
+      "log.err"     => "testbot.log",
+      "old_log"     => "old_task.log",
+      "old_log.err" => "old_testbot.log");
+    while (my ($OldName, $NewName) = each %LogMap)
+    {
+      if (-f "$TaskDir/$OldName" and !-f "$TaskDir/$NewName" and
+          !rename("$TaskDir/$OldName", "$TaskDir/$NewName"))
+      {
+        Error TaskKeyStr($Task) .": Could not rename $OldName because $NewName already exists\n";
+        $Rc = 1;
+      }
+    }
+
+    # testbot.log is the only log which we expect to be empty.
+    # There is not much point keeping it if that's the case.
+    my $TestBotLog = "$TaskDir/testbot.log";
+    $Rc += Delete($TestBotLog) if (-z $TestBotLog);
   }
 
   if (($OptDelete or $OptRebuild) and !$CollectOnly)
diff --git a/testbot/bin/WineRunBuild.pl b/testbot/bin/WineRunBuild.pl
index 6b68c0d..45288af 100755
--- a/testbot/bin/WineRunBuild.pl
+++ b/testbot/bin/WineRunBuild.pl
@@ -181,14 +181,14 @@ sub LogTaskError($)
   Debug("$Name0:error: ", $ErrMessage);
 
   my $OldUMask = umask(002);
-  if (open(my $ErrFile, ">>", "$TaskDir/log.err"))
+  if (open(my $ErrFile, ">>", "$TaskDir/testbot.log"))
   {
     print $ErrFile $ErrMessage;
     close($ErrFile);
   }
   else
   {
-    Error "Unable to open 'log.err' for writing: $!\n";
+    Error "Unable to open 'testbot.log' for writing: $!\n";
   }
   umask($OldUMask);
 }
@@ -417,9 +417,9 @@ if (!defined $TA->Wait($Pid, $Task->Timeout, 60))
 }
 
 Debug(Elapsed($Start), " Retrieving 'Build.log'\n");
-if ($TA->GetFile("Build.log", "$TaskDir/log"))
+if ($TA->GetFile("Build.log", "$TaskDir/task.log"))
 {
-  my $LogInfo = ParseTaskLog("$TaskDir/log");
+  my $LogInfo = ParseTaskLog("$TaskDir/task.log");
   if ($LogInfo->{Task} eq "ok")
   {
     # We must have gotten the full log and the build did succeed.
diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl
index 04c0e26..3005ba7 100755
--- a/testbot/bin/WineRunReconfig.pl
+++ b/testbot/bin/WineRunReconfig.pl
@@ -182,14 +182,14 @@ sub LogTaskError($)
   Debug("$Name0:error: ", $ErrMessage);
 
   my $OldUMask = umask(002);
-  if (open(my $ErrFile, ">>", "$TaskDir/log.err"))
+  if (open(my $ErrFile, ">>", "$TaskDir/testbot.log"))
   {
     print $ErrFile $ErrMessage;
     close($ErrFile);
   }
   else
   {
-    Error "Unable to open 'log.err' for writing: $!\n";
+    Error "Unable to open 'testbot.log' for writing: $!\n";
   }
   umask($OldUMask);
 }
@@ -418,9 +418,9 @@ if (!defined $TA->Wait($Pid, $Task->Timeout, 60))
 
 my $LogInfo;
 Debug(Elapsed($Start), " Retrieving 'Reconfig.log'\n");
-if ($TA->GetFile("Reconfig.log", "$TaskDir/log"))
+if ($TA->GetFile("Reconfig.log", "$TaskDir/task.log"))
 {
-  $LogInfo = ParseTaskLog("$TaskDir/log");
+  $LogInfo = ParseTaskLog("$TaskDir/task.log");
   if ($LogInfo->{Task} eq "ok")
   {
     # We must have gotten the full log and the build did succeed.
diff --git a/testbot/bin/WineRunTask.pl b/testbot/bin/WineRunTask.pl
index 2b54048..59975c3 100755
--- a/testbot/bin/WineRunTask.pl
+++ b/testbot/bin/WineRunTask.pl
@@ -210,14 +210,14 @@ sub LogTaskError($)
   Debug("$Name0:error: ", $ErrMessage);
 
   my $OldUMask = umask(002);
-  if (open(my $ErrFile, ">>", "$TaskDir/log.err"))
+  if (open(my $ErrFile, ">>", "$TaskDir/testbot.log"))
   {
     print $ErrFile $ErrMessage;
     close($ErrFile);
   }
   else
   {
-    Error "Unable to open 'log.err' for writing: $!\n";
+    Error "Unable to open 'testbot.log' for writing: $!\n";
   }
   umask($OldUMask);
 }
@@ -534,7 +534,7 @@ if (!defined $TA->Wait($Pid, $Timeout, $Keepalive))
 }
 
 Debug(Elapsed($Start), " Retrieving 'Task.log'\n");
-if (!$TA->GetFile("Task.log", "$TaskDir/log") and !defined $TAError)
+if (!$TA->GetFile("Task.log", "$TaskDir/task.log") and !defined $TAError)
 {
   $TAError = "An error occurred while retrieving the task log: ". $TA->GetLastError();
 }
diff --git a/testbot/bin/WineRunWineTest.pl b/testbot/bin/WineRunWineTest.pl
index 9a0a4eb..9d54745 100755
--- a/testbot/bin/WineRunWineTest.pl
+++ b/testbot/bin/WineRunWineTest.pl
@@ -206,14 +206,14 @@ sub LogTaskError($)
   my ($ErrMessage) = @_;
   Debug("$Name0:error: ", $ErrMessage);
 
-  if (open(my $ErrFile, ">>", "$TaskDir/log.err"))
+  if (open(my $ErrFile, ">>", "$TaskDir/testbot.log"))
   {
     print $ErrFile $ErrMessage;
     close($ErrFile);
   }
   else
   {
-    Error "Unable to open 'log.err' for writing: $!\n";
+    Error "Unable to open 'testbot.log' for writing: $!\n";
   }
 }
 
@@ -506,9 +506,9 @@ if (!defined $TA->Wait($Pid, $Task->Timeout, 60))
 }
 
 Debug(Elapsed($Start), " Retrieving 'Task.log'\n");
-if ($TA->GetFile("Task.log", "$TaskDir/log"))
+if ($TA->GetFile("Task.log", "$TaskDir/task.log"))
 {
-  my $LogInfo = ParseTaskLog("$TaskDir/log");
+  my $LogInfo = ParseTaskLog("$TaskDir/task.log");
   if ($LogInfo->{Task} eq "ok")
   {
     # We must have gotten the full log and the task completed successfully
diff --git a/testbot/lib/WineTestBot/LogUtils.pm b/testbot/lib/WineTestBot/LogUtils.pm
index 36f3674..0a98a5a 100644
--- a/testbot/lib/WineTestBot/LogUtils.pm
+++ b/testbot/lib/WineTestBot/LogUtils.pm
@@ -622,8 +622,8 @@ sub GetLogFileNames($;$)
                  win32.report win32_*.report
                  wow32.report wow32_*.report
                  wow64.report wow64_*.report
-                 log);
-  push @Globs, "old_log" if ($IncludeOld);
+                 task.log testbot.log);
+  push @Globs, ("old_task.log", "old_testbot.log") if ($IncludeOld);
 
   my (@Logs, %Seen);
   foreach my $Glob (@Globs)
@@ -637,7 +637,7 @@ sub GetLogFileNames($;$)
       {
         $LogName = $1; # untaint
       }
-      elsif ($LogName eq $Glob) # log and old_log cases
+      elsif ($LogName eq $Glob) # (old_) task.log and testbot.log cases
       {
         $LogName = $Glob; # untaint
       }
@@ -659,13 +659,15 @@ sub GetLogFileNames($;$)
 }
 
 my %_LogFileLabels = (
-  "exe32.report" => '32 bit%s report',
-  "exe64.report" => '64 bit%s report',
-  "win32.report" => '32 bit%s report',
-  "wow32.report" => '32 bit%s WoW report',
-  "wow64.report" => '64 bit%s WoW report',
-  "log"          => 'task%s log',
-  "old_log"      => 'old%s logs',
+  "exe32.report"    => '32 bit%s report',
+  "exe64.report"    => '64 bit%s report',
+  "win32.report"    => '32 bit%s report',
+  "wow32.report"    => '32 bit%s WoW report',
+  "wow64.report"    => '64 bit%s WoW report',
+  "task.log"        => 'task%s log',
+  "testbot.log"     => 'testbot%s log',
+  "old_task.log"    => 'old%s task logs',
+  "old_testbot.log" => 'old%s testbot logs',
 );
 
 =pod
diff --git a/testbot/lib/WineTestBot/Tasks.pm b/testbot/lib/WineTestBot/Tasks.pm
index 7b9ac9b..541b555 100644
--- a/testbot/lib/WineTestBot/Tasks.pm
+++ b/testbot/lib/WineTestBot/Tasks.pm
@@ -153,7 +153,7 @@ sub _SetupTask($$)
   if (-d $Dir)
   {
     mkpath("$Dir.new", 0, 0775);
-    foreach my $Filename ("log", "log.err")
+    foreach my $Filename ("task.log", "testbot.log")
     {
       if (-f "$Dir/old_$Filename")
       {
@@ -178,9 +178,9 @@ sub _SetupTask($$)
     rename("$Dir.new", $Dir);
   }
 
-  # Capture Perl errors in the task's generic error log
+  # Capture Perl errors in the per-task TestBot log
   my $TaskDir = $self->CreateDir();
-  if (open(STDERR, ">>", "$TaskDir/log.err"))
+  if (open(STDERR, ">>", "$TaskDir/testbot.log"))
   {
     # Make sure stderr still flushes after each print
     my $tmp=select(STDERR);
@@ -190,7 +190,7 @@ sub _SetupTask($$)
   else
   {
     require WineTestBot::Log;
-    WineTestBot::Log::LogMsg("unable to redirect stderr to '$TaskDir/log.err': $!\n");
+    WineTestBot::Log::LogMsg("unable to redirect stderr to '$TaskDir/testbot.log': $!\n");
   }
 }
 
@@ -253,7 +253,7 @@ sub UpdateStatus($$)
     my ($JobId, $StepNo, $TaskNo) = @{$self->GetMasterKey()};
     my $OldUMask = umask(002);
     my $TaskDir = $self->CreateDir();
-    if (open TASKLOG, ">>$TaskDir/log.err")
+    if (open TASKLOG, ">>$TaskDir/testbot.log")
     {
       print TASKLOG "TestBot process got stuck or died unexpectedly\n";
       close TASKLOG;




More information about the wine-cvs mailing list