[1/3] testbot: Add a 'canceled' status for jobs, steps and tasks.

Francois Gouget fgouget at codeweavers.com
Thu Mar 28 08:43:19 CDT 2013


This makes it possible to report a job as canceled rather than failed (failed indicates either a WineTestBot error or a bad patch).
---

*NOTE*:
- This patch requires a database update. See testbot/ddl/update23.sql.
- The WineTestBot server will need to be restarted to deal with the new 
  VM status.
- The Apache server may need to be restarted to pick up the updates to 
  the VM configuration page (but then it may also pick up the changes 
  automatically).

 testbot/ddl/update23.sql         |   10 ++++++++++
 testbot/ddl/winetestbot.sql      |    6 +++---
 testbot/lib/WineTestBot/Jobs.pm  |   30 ++++++++++++++++++++----------
 testbot/lib/WineTestBot/Steps.pm |    4 ++--
 testbot/lib/WineTestBot/Tasks.pm |    2 +-
 testbot/web/JobDetails.pl        |    8 ++++++--
 testbot/web/WineTestBot.css      |    1 +
 testbot/web/index.pl             |    6 ++++--
 8 files changed, 47 insertions(+), 20 deletions(-)
 create mode 100644 testbot/ddl/update23.sql

diff --git a/testbot/ddl/update23.sql b/testbot/ddl/update23.sql
new file mode 100644
index 0000000..71343eb
--- /dev/null
+++ b/testbot/ddl/update23.sql
@@ -0,0 +1,10 @@
+USE winetestbot;
+
+ALTER TABLE Jobs
+  MODIFY Status ENUM('queued', 'running', 'completed', 'failed', 'canceled') NOT NULL;
+
+ALTER TABLE Steps
+  MODIFY Status ENUM('queued', 'running', 'completed', 'failed', 'canceled', 'skipped') NOT NULL;
+
+ALTER TABLE Tasks
+  MODIFY Status ENUM('queued', 'running', 'completed', 'failed', 'canceled', 'skipped') NOT NULL;
diff --git a/testbot/ddl/winetestbot.sql b/testbot/ddl/winetestbot.sql
index 4912a59..87be172 100644
--- a/testbot/ddl/winetestbot.sql
+++ b/testbot/ddl/winetestbot.sql
@@ -111,7 +111,7 @@ CREATE TABLE Jobs
   BranchName VARCHAR(20) NOT NULL,
   UserName   VARCHAR(40) NOT NULL,
   Priority   INT(1)      NOT NULL,
-  Status     ENUM('queued', 'running', 'completed', 'failed') NOT NULL,
+  Status     ENUM('queued', 'running', 'completed', 'failed', 'canceled') NOT NULL,
   Remarks    VARCHAR(128) NULL,
   Submitted  DATETIME    NULL,
   Ended      DATETIME    NULL,
@@ -129,7 +129,7 @@ CREATE TABLE Steps
   JobId                 INT(5) NOT NULL,
   No                    INT(2) NOT NULL,
   Type                  ENUM('suite', 'single', 'build', 'reconfig') NOT NULL,
-  Status                ENUM('queued', 'running', 'completed', 'failed', 'skipped') NOT NULL,
+  Status                ENUM('queued', 'running', 'completed', 'failed', 'canceled', 'skipped') NOT NULL,
   FileName              VARCHAR(100) NOT NULL,
   FileType              ENUM('exe32', 'exe64', 'patchdlls', 'patchprograms') NOT NULL,
   InStaging             ENUM('Y', 'N') NOT NULL,
@@ -145,7 +145,7 @@ CREATE TABLE Tasks
   JobId        INT(5) NOT NULL,
   StepNo       INT(2) NOT NULL,
   No           INT(2) NOT NULL,
-  Status       ENUM('queued', 'running', 'completed', 'failed', 'skipped') NOT NULL,
+  Status       ENUM('queued', 'running', 'completed', 'failed', 'canceled', 'skipped') NOT NULL,
   VMName       VARCHAR(20) NOT NULL,
   Timeout      INT(4) NOT NULL,
   CmdLineArg   VARCHAR(256) NULL,
diff --git a/testbot/lib/WineTestBot/Jobs.pm b/testbot/lib/WineTestBot/Jobs.pm
index c6421e9..ab82c07 100644
--- a/testbot/lib/WineTestBot/Jobs.pm
+++ b/testbot/lib/WineTestBot/Jobs.pm
@@ -54,6 +54,7 @@ use WineTestBot::Config;
 use WineTestBot::Branches;
 use WineTestBot::Engine::Notify;
 use WineTestBot::WineTestBotObjects;
+use WineTestBot::Log;
 
 use vars qw(@ISA @EXPORT);
 
@@ -144,7 +145,8 @@ sub UpdateStatus($)
     $Has{$StepStatus} = 1;
 
     my $Type = $Step->Type;
-    if ($StepStatus eq "failed" && ($Type eq "build" || $Type eq "reconfig"))
+    if (($StepStatus eq "failed" || $StepStatus eq "canceled") &&
+        ($Type eq "build" || $Type eq "reconfig"))
     {
       # The following steps need binaries that this one was supposed to
       # produce. So skip them.
@@ -156,7 +158,7 @@ sub UpdateStatus($)
   # Note that one or more tasks may have been requeued during the cleanup phase
   # of the server startup. So this job may regress from 'running' back to
   # 'queued'. This means all possible step status values must be considered.
-  foreach my $StepStatus ("running", "failed", "skipped", "completed", "queued")
+  foreach my $StepStatus ("running", "failed", "canceled", "skipped", "completed", "queued")
   {
     if ($Has{$StepStatus})
     {
@@ -168,9 +170,9 @@ sub UpdateStatus($)
       }
       else
       {
-        # If all steps are skipped it's because the user canceled the job. In
-        # that case mark the job as 'failed'.
-        $Status = $StepStatus eq "skipped" ? "failed" : $StepStatus;
+        # If all steps are skipped it's because the user canceled the job
+        # before any of them could run.
+        $Status = $StepStatus eq "skipped" ? "canceled" : $StepStatus;
       }
       $self->Status($Status);
       if ($Status ne "running" && $Status ne "queued" && !defined $self->Ended)
@@ -204,9 +206,15 @@ sub Cancel
       }
       elsif (defined $Task->ChildPid)
       {
-        # We don't unset ChildPid so Task::UpdateStatus()
-        # will add a trace in the log
+        LogMsg "Canceling the ". join("/", $self->Id, $Step->No, $Task->No) . " task\n";
         kill("TERM", $Task->ChildPid);
+        $Task->Status("canceled");
+        $Task->ChildPid(undef);
+        $Task->Save();
+
+        my $VM = $Task->VM;
+        $VM->Status('dirty');
+        $VM->Save();
       }
     }
   }
@@ -219,9 +227,9 @@ sub Restart
 {
   my $self = shift;
 
-  if ($self->Status ne "failed" && $self->Status ne "completed")
+  if ($self->Status eq "queued" || $self->Status eq "running")
   {
-    return "Only completed/failed jobs can be restarted";
+    return "This job is already " . $self->Status;
   }
 
   my $JobDir = "$DataDir/jobs/" . $self->Id;
@@ -251,6 +259,8 @@ sub Restart
     $Step->Status("queued");
   }
   $self->Status("queued");
+  $self->Submitted(time);
+  $self->Ended(undef);
   $self->Save(); # Save it all
 
   return undef;
@@ -328,7 +338,7 @@ BEGIN
     CreateItemrefPropertyDescriptor("Branch", "Branch", !1, 1, \&CreateBranches, ["BranchName"]),
     CreateItemrefPropertyDescriptor("User", "Author", !1, 1, \&WineTestBot::Users::CreateUsers, ["UserName"]),
     CreateBasicPropertyDescriptor("Priority", "Priority", !1, 1, "N", 1),
-    CreateEnumPropertyDescriptor("Status", "Status", !1, 1, ['queued', 'running', 'completed', 'failed']),
+    CreateEnumPropertyDescriptor("Status", "Status", !1, 1, ['queued', 'running', 'completed', 'failed', 'canceled']),
     CreateBasicPropertyDescriptor("Remarks", "Remarks", !1, !1, "A", 128),
     CreateBasicPropertyDescriptor("Submitted", "Submitted", !1, !1, "DT", 19),
     CreateBasicPropertyDescriptor("Ended", "Ended", !1, !1, "DT", 19),
diff --git a/testbot/lib/WineTestBot/Steps.pm b/testbot/lib/WineTestBot/Steps.pm
index acbab81..3b77262 100644
--- a/testbot/lib/WineTestBot/Steps.pm
+++ b/testbot/lib/WineTestBot/Steps.pm
@@ -109,7 +109,7 @@ sub UpdateStatus($$)
   # Note that one or more tasks may have been requeued during the cleanup phase
   # of the server startup. So this step may regress from 'running' back to
   # 'queued'. This means all possible task status values must be considered.
-  foreach my $TaskStatus ("running", "failed", "skipped", "completed", "queued")
+  foreach my $TaskStatus ("running", "failed", "canceled", "skipped", "completed", "queued")
   {
     if ($Has{$TaskStatus})
     {
@@ -158,7 +158,7 @@ BEGIN
 {
   @PropertyDescriptors = (
     CreateBasicPropertyDescriptor("No", "Step no",  1,  1, "N", 2),
-    CreateEnumPropertyDescriptor("Status", "Status",  !1,  1, ['queued', 'running', 'completed', 'failed', 'skipped']),
+    CreateEnumPropertyDescriptor("Status", "Status",  !1,  1, ['queued', 'running', 'completed', 'failed', 'canceled', 'skipped']),
     CreateEnumPropertyDescriptor("Type", "Step type",  !1,  1, ['suite', 'single', 'build', 'reconfig']),
     CreateBasicPropertyDescriptor("FileName", "File name",  !1,  1, "A", 100),
     CreateEnumPropertyDescriptor("FileType", "File type",  !1,  1, ['exe32', 'exe64', 'patchdlls', 'patchprograms']),
diff --git a/testbot/lib/WineTestBot/Tasks.pm b/testbot/lib/WineTestBot/Tasks.pm
index c65f7cf..4ca1527 100644
--- a/testbot/lib/WineTestBot/Tasks.pm
+++ b/testbot/lib/WineTestBot/Tasks.pm
@@ -208,7 +208,7 @@ BEGIN
 {
   @PropertyDescriptors = (
     CreateBasicPropertyDescriptor("No", "Task no",  1,  1, "N", 2),
-    CreateEnumPropertyDescriptor("Status", "Status",  !1,  1, ['queued', 'running', 'completed', 'failed', 'skipped']),
+    CreateEnumPropertyDescriptor("Status", "Status",  !1,  1, ['queued', 'running', 'completed', 'failed', 'canceled', 'skipped']),
     CreateItemrefPropertyDescriptor("VM", "VM", !1,  1, \&CreateVMs, ["VMName"]),
     CreateBasicPropertyDescriptor("Timeout", "Timeout", !1, 1, "N", 4),
     CreateBasicPropertyDescriptor("CmdLineArg", "Command line args", !1, !1, "A", 256),
diff --git a/testbot/web/JobDetails.pl b/testbot/web/JobDetails.pl
index 651335c..429a87c 100644
--- a/testbot/web/JobDetails.pl
+++ b/testbot/web/JobDetails.pl
@@ -119,9 +119,9 @@ sub CanRestart
 
   my $Job = CreateJobs()->GetItem($self->{JobId});
   my $Status = $Job->Status;
-  if ($Status ne "failed")
+  if ($Status ne "failed" && $Status ne "canceled")
   {
-    return "Job did not fail";
+    return "Not a failed / canceled Job";
   }
 
   my $Session = $self->GetCurrentSession();
@@ -464,6 +464,10 @@ sub GenerateBody
       }
       close ERRFILE;
     }
+    elsif ($Item->Status eq "canceled")
+    {
+      print "<p>No log, task was canceled</p>\n";
+    }
     elsif ($Item->Status eq "skipped")
     {
       print "<p>No log, task skipped</p>\n";
diff --git a/testbot/web/WineTestBot.css b/testbot/web/WineTestBot.css
index b7e7248..1007372 100644
--- a/testbot/web/WineTestBot.css
+++ b/testbot/web/WineTestBot.css
@@ -326,3 +326,4 @@ pre
 .success   { color: green; }
 .testfail  { color: red; }
 .botfail   { color: #e55600; }
+.canceled  { color: black; }
diff --git a/testbot/web/index.pl b/testbot/web/index.pl
index 1dffaf7..d8eaee8 100644
--- a/testbot/web/index.pl
+++ b/testbot/web/index.pl
@@ -93,10 +93,12 @@ sub GenerateDataCell
     my %HTMLChunks = ("queued" => "<span class='queued'>queued</span>",
                       "running" => "<span class='running'>running</span>",
                       "completed" => "<span class='success'>completed</span>",
-                      "failed" => "<span class='botfail'>failed</span>");
+                      "failed" => "<span class='botfail'>failed</span>",
+                      "canceled" => "<span class='canceled'>canceled</span>",
+        );
     my $Status = $Item->Status;
     my $HTMLStatus = $HTMLChunks{$Status} || $Status;
-    if ($Status eq "completed" || $Status eq "failed")
+    if ($Status eq "completed" || $Status eq "failed" || $Status eq "canceled")
     {
       my $Failures = 0;
       my $HasTestResult;
-- 
1.7.10.4




More information about the wine-patches mailing list