Francois Gouget : testbot/web: Automatically refresh the failure bug information.

Alexandre Julliard julliard at winehq.org
Thu Jun 16 16:13:56 CDT 2022


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

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Thu Jun 16 18:28:00 2022 +0200

testbot/web: Automatically refresh the failure bug information.

Automatically refresh the failure bug information when the bug id is
modified.
Also trigger a refresh when a failure is undeleted.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48912
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/bin/Engine.pl                    | 39 ++++++++++++++++++++++++++++++++
 testbot/lib/WineTestBot/Engine/Notify.pm | 20 +++++++++++++++-
 testbot/lib/WineTestBot/Failures.pm      | 31 +++++++++++++++++++++++++
 testbot/web/FailureDetails.pl            |  1 -
 testbot/web/FailuresList.pl              |  5 ++--
 5 files changed, 91 insertions(+), 5 deletions(-)

diff --git a/testbot/bin/Engine.pl b/testbot/bin/Engine.pl
index 88852730..29dce183 100755
--- a/testbot/bin/Engine.pl
+++ b/testbot/bin/Engine.pl
@@ -49,6 +49,7 @@ use WineTestBot::Config;
 use WineTestBot::Engine::Events;
 use WineTestBot::Engine::Notify;
 use WineTestBot::Engine::Scheduler;
+use WineTestBot::Failures;
 use WineTestBot::Jobs;
 use WineTestBot::Log;
 use WineTestBot::Patches;
@@ -548,6 +549,43 @@ sub HandleGetScreenshot($)
   return "1" . $ImageBytes;
 }
 
+sub HandleUpdateFailure($)
+{
+  my ($FailureId) = @_;
+
+  # Validate FailureId
+  if ($FailureId !~ /^(\d+)$/)
+  {
+    LogMsg "Invalid failure id\n";
+    return "0Invalid Failure Id";
+  }
+  $FailureId = $1;
+
+  if (!CreateFailures()->GetItem($FailureId))
+  {
+    LogMsg "Unknown Failure $FailureId\n";
+    return "0Unknown Failure $FailureId";
+  }
+
+  my $Pid = fork;
+  if (!defined $Pid)
+  {
+    LogMsg "Unable to fork for UpdateFailures.pl: $!\n";
+  }
+  elsif (!$Pid)
+  {
+    # Clean up the child environment
+    CloseAllDBBackEnds();
+    WineTestBot::Log::SetupRedirects();
+
+    exec("$BinDir/UpdateFailures.pl --log-only $FailureId") or
+        LogMsg "Unable to exec ${ProjectName}UpdateFailures.pl: $!\n";
+    exit(1);
+  }
+
+  return "1";
+}
+
 my %Handlers=(
     "getscreenshot"            => \&HandleGetScreenshot,
     "jobcontrol"               => \&HandleJobControl,
@@ -558,6 +596,7 @@ my %Handlers=(
     "vmstatuschange"           => \&HandleVMStatusChange,
     "winepatchmlsubmission"    => \&HandleWinePatchMLSubmission,
     "winepatchwebsubmission"   => \&HandleWinePatchWebSubmission,
+    "updatefailure"            => \&HandleUpdateFailure,
     );
 
 sub HandleClientCmd(@)
diff --git a/testbot/lib/WineTestBot/Engine/Notify.pm b/testbot/lib/WineTestBot/Engine/Notify.pm
index 82221c9e..9c180298 100644
--- a/testbot/lib/WineTestBot/Engine/Notify.pm
+++ b/testbot/lib/WineTestBot/Engine/Notify.pm
@@ -31,7 +31,8 @@ use Exporter 'import';
 our $RunningInEngine;
 our @EXPORT = qw(Shutdown PingEngine JobStatusChange JobControl
                  RescheduleJobs VMStatusChange
-                 WinePatchMLSubmission WinePatchWebSubmission GetScreenshot);
+                 WinePatchMLSubmission WinePatchWebSubmission
+                 UpdateFailure GetScreenshot);
 our @EXPORT_OK = qw($RunningInEngine);
 
 use Socket;
@@ -194,6 +195,23 @@ sub WinePatchWebSubmission()
   return substr($Reply, 1);
 }
 
+sub UpdateFailure($)
+{
+  my ($FailureId) = @_;
+
+  my $Reply = SendCmdReceiveReply("updatefailure $FailureId\n");
+  if (length($Reply) < 1)
+  {
+    return "The Engine did not acknowledge the UpdateFailure command";
+  }
+  if (substr($Reply, 0, 1) eq "1")
+  {
+    return (undef, substr($Reply, 1));
+  }
+
+  return (substr($Reply, 1), undef);
+}
+
 sub GetScreenshot($)
 {
   my ($VMName) = @_;
diff --git a/testbot/lib/WineTestBot/Failures.pm b/testbot/lib/WineTestBot/Failures.pm
index 344af756..f0f78b6f 100644
--- a/testbot/lib/WineTestBot/Failures.pm
+++ b/testbot/lib/WineTestBot/Failures.pm
@@ -40,6 +40,8 @@ TaskFailure objects.
 use WineTestBot::WineTestBotObjects;
 our @ISA = qw(WineTestBot::WineTestBotItem);
 
+use WineTestBot::Engine::Notify;
+
 
 sub Compare($$)
 {
@@ -55,6 +57,35 @@ sub Compare($$)
   return $Cmp
 }
 
+sub BugId($;$)
+{
+  my ($self, $NewBugId) = @_;
+
+  my $CurrentBugId = $self->SUPER::BugId;
+  return $CurrentBugId if (!defined $NewBugId);
+
+  if (!defined $CurrentBugId or $NewBugId ne $CurrentBugId)
+  {
+    $self->{OldBugId} = $CurrentBugId if (!defined $self->{OldBugId});
+    $self->SUPER::BugId($NewBugId);
+  }
+
+  return $NewBugId;
+}
+
+sub OnSaved($)
+{
+  my ($self) = @_;
+
+  $self->SUPER::OnSaved();
+  if ((defined $self->{OldBugId} and $self->{OldBugId} ne $self->BugId) or
+      !$self->BugStatus or !$self->BugDescription)
+  {
+    UpdateFailure($self->Id);
+  }
+  delete $self->{OldBugId};
+}
+
 sub Validate($)
 {
   my ($self) = @_;
diff --git a/testbot/web/FailureDetails.pl b/testbot/web/FailureDetails.pl
index ab7d1311..c510d8d4 100644
--- a/testbot/web/FailureDetails.pl
+++ b/testbot/web/FailureDetails.pl
@@ -206,7 +206,6 @@ sub OnAction($$)
       $self->{Item}->BugDescription("");
     }
     return undef if (!$self->Save());
-    # FIXME Notify the TestBot Engine so it updates the bug information
     exit($self->RedirectToParent());
   }
   return $self->SUPER::OnAction($Action);
diff --git a/testbot/web/FailuresList.pl b/testbot/web/FailuresList.pl
index f763413f..e271ee1d 100644
--- a/testbot/web/FailuresList.pl
+++ b/testbot/web/FailuresList.pl
@@ -129,9 +129,9 @@ sub OnItemAction($$$)
     return 1 if ($Action eq "Restore" and $Failure->BugStatus ne "deleted");
 
     my $NewStatus = $Action eq "Delete" ? "deleted" :
-                    $Action eq "Restore" ? "unknown" :
+                    $Action eq "Restore" ? "" :
                     undef;
-    if ($NewStatus)
+    if (defined $NewStatus)
     {
       $Failure->BugStatus($NewStatus);
       my ($_ErrProperty, $ErrMessage) = $Failure->Save();
@@ -141,7 +141,6 @@ sub OnItemAction($$$)
         $self->{EnclosingPage}->SetError(undef, $ErrMessage);
         return 0;
       }
-      # FIXME Notify the TestBot Engine so it updates the bug information
       return 1;
     }
   }




More information about the wine-cvs mailing list