diff mbox

[OSSTEST,11/17] substep logfiles: Populate new logfile column, at all, for substeps

Message ID 1498839920-17025-12-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson June 30, 2017, 4:25 p.m. UTC
For now we populate it with the sometimes-wrong value based on
$script.  In detail:

* Add a parameter $logfile to $mjobdb->step_start, which currently
  always gets passed undef.

* In JobDB::Executive::step_start, try to use it as the value for the
  new logfile column.  But, if it is not set (which is currently
  always the case), default it to "<stepno>.<script>.log".

  This is the same log filename currently assumed (and therefore used)
  by sg-report-flight.  So with current versions of sg-report-flight,
  this has no visible functional change.

This is part of a "Populate-then-rely" schema change, as described in
schema/README.updates.  Specifically, this is part of the step:

5. Commit: code to populate new column; changing `add' to status
   Needed and `constraint' to status Ready.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/JobDB/Executive.pm   | 14 +++++++++-----
 Osstest/JobDB/Standalone.pm  |  4 ++--
 Osstest/TestSupport.pm       |  2 +-
 schema/steps-logfile-add.sql |  2 +-
 4 files changed, 13 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm
index fbbb5ac..e1e2052 100644
--- a/Osstest/JobDB/Executive.pm
+++ b/Osstest/JobDB/Executive.pm
@@ -242,15 +242,17 @@  END
     logm("starting $flight started=$now") if $count>0;
 }
 
-sub step_start ($$) { #method
-    my ($jd,$testid,$script) = @_;
+sub step_start ($$;$$) { #method
+    my ($jd,$testid,$logfile,$script) = @_;
     my $snq = $dbh_tests->prepare(<<END);
         SELECT max(stepno) AS maxstep FROM steps
             WHERE flight=? AND job=?
 END
     my $createq = $dbh_tests->prepare(<<END);
-        INSERT INTO steps (flight,job,stepno, step,status, testid,started)
-            VALUES (?,?,?, ?,'running', ?,?)
+        INSERT INTO steps (flight,job,stepno,step,
+                           logfile,
+                           status,testid,started)
+            VALUES (?,?,?,?, ?, 'running',?,?)
 END
     if (!defined $script) {
 	$script = $0;
@@ -262,7 +264,9 @@  END
 	($stepno) = $snq->fetchrow_array();
 	$stepno //= 0;
 	$stepno++;
-	$createq->execute($flight,$job,$stepno, $script, $testid,time);
+	$createq->execute($flight,$job,$stepno,$script,
+			  $logfile // "$stepno.$script.log",
+			  $testid,time);
     });
     logm("---------- substep $stepno $testid running ----------");
 }
diff --git a/Osstest/JobDB/Standalone.pm b/Osstest/JobDB/Standalone.pm
index af93196..d9a90fc 100644
--- a/Osstest/JobDB/Standalone.pm
+++ b/Osstest/JobDB/Standalone.pm
@@ -88,8 +88,8 @@  sub current_flight ($) {
 
 sub job_ensure_started ($) { }
 
-sub step_start ($$;$) {
-    my ($jd,$testid,$script) = @_;
+sub step_start ($$;$$) {
+    my ($jd,$testid,$logfile,$script) = @_;
     logm("========== $flight.$job step $testid running ==========");
 }
 
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 5a951e5..a05dd97 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -248,7 +248,7 @@  sub complete_testid ($) {
 sub substep_start ($;$) {
     my ($testid,$script) = @_;
     complete_testid(\$testid);
-    $mjobdb->step_start($testid,$script);
+    $mjobdb->step_start($testid,undef,$script);
 }
 
 sub substep_finish ($$) {
diff --git a/schema/steps-logfile-add.sql b/schema/steps-logfile-add.sql
index 5e37b10..abc89b9 100644
--- a/schema/steps-logfile-add.sql
+++ b/schema/steps-logfile-add.sql
@@ -1,4 +1,4 @@ 
--- ##OSSTEST## 003 Preparatory
+-- ##OSSTEST## 003 Needed
 --
 -- Previously, the logfile name was inferred from "stepno" and
 -- "testid".  We want to be able to set it explicitly for substeps.