Skip to contentSkip to conversation

Fix substep (eg XTF) logfile links

PATCH New Ian Jackson 1 participant 18 messages Jun 30, 2017

lore
Share & tools
lore
#0 lore raw

cover Fix substep (eg XTF) logfile links

It kept irritating me that the links to the substeps of xtf-run do not work. To fix this, it is necessary for the database to contain the right information - ie, a schema change.

After this series, substep logfile names are recorded and reported properly, and you can click on them.

At some point in the future, when enough browsers honour `#line=', it might be worth adding that - that would be another column, probably. For now, the links for each step just go to the top of the logfile.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw

PATCH 1/17 Developer docs: A rune for flight comparision

Something like this rune can be useful for comparing testids of different flights.

---
 NOTES.flight-comparison | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 NOTES.flight-comparison
NOTES.flight-comparison new file +22 -0
new file mode 100644
index 0000000..ea290f8
@@ -0,0 +1,22 @@
+select
+  l.job, l.stepno, l.testid, l.status,
+  r.job, r.stepno, r.testid, r.status
+from
+  (select * from steps where flight=110909) l
+  full outer join
+  (select * from steps where flight=110951) r
+on
+  regexp_replace(l.testid,'\([0-9]*\)$','') =
+  regexp_replace(r.testid,'\([0-9]*\)$','')
+      and
+  l.job=r.job
+      and
+  (l.stepno=r.stepno or l.stepno+1=r.stepno)
+where
+  coalesce(r.testid,'') != 'syslog-server'
+      and
+  (l.testid is null or r.testid is null or l.status!=r.status)
+order by
+  coalesce(l.job, r.job),
+  l.stepno, r.stepno,
+  l.testid, r.testid;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

PATCH 2/17 schema updates: Fix typo in developer doc

In reply to Ian Jackson
---
 schema/README.updates | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
schema/README.updates +1 -1
index 25bc11a..c5abc36 100644
@@ -109,7 +109,7 @@ on it.  There are typically two schema changes:
 5. Commit: code to populate new column; changing `add' to status
    Needed and `constraint' to status Ready.
 
-6. Optionally commit: code which read new column, but which tolerates
+6. Optionally commit: code which reads new column, but which tolerates
    it containing NULL/DEFAULT.  (`add' is already Needed.)
 
 7. If necessary commit: idempotent utility script to populate missing
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#3 lore raw

PATCH 3/17 schema updates: Document how to remove a used column

In reply to Ian Jackson
---
 schema/README.updates | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
schema/README.updates +26 -0
index c5abc36..ca1d37e 100644
@@ -147,6 +147,32 @@ finish is needed', this will usually involve passing an appropriate
 `-o' option.
 
 
+Update order for Cleanup
+------------------------
+
+This is for when we want to get rid of some old information in the
+database.  Sometimes the information will have been replaced eg via
+a Populate-then-Rely change, as described above.
+
+There are typically two schema changes:
+
+* To allow the new information to be left blank (eg for the column to
+  be NULL).  Call this `unconstrain'; it is an `Explicit conditional'
+  change.
+
+* To drop the information entirely.  I will call this `drop'.
+  It is `Code first'.
+
+1. Commit: new schema updates `unconstrain', status `Unfinished'
+   and `drop', status `Unfinished'.
+
+2. Commit code which tolerates the information being missing;
+   changing `unconstrain' to Ready.
+
+3. Commit code which no longer writes the information; changing
+   `unconstrain' to Needed and `drop' to Ready.
+
+
 Statuses and rules for push and db update
 -----------------------------------------
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#4 lore raw

PATCH 4/17 schema updates: mg-schema-test-database: Cope with applied updates

In reply to Ian Jackson

The schema_updates table contents are written by the call to mg-schema-update. Trying to copy the contents from the source db correctly fails with duplicate key errors. So don't do that.

---
 mg-schema-test-database | 3 +++
 1 file changed, 3 insertions(+)
mg-schema-test-database +3 -0
index 0517ca3..641aadb 100755
@@ -467,6 +467,9 @@ END
 END
 
 	for table in $tables; do
+		case $table in
+		schema_updates)	continue ;;
+		esac
 		case " $ftables " in
 		*" $table "*)	condition="flight >= $minflight" ;;
 		*)		condition="1=1" ;;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#5 lore raw

PATCH 5/17 schema updates: Be willing to apply Ready changes

In reply to Ian Jackson

If the oldest code declares itself Ready for this change, or (implausibly) Needed, then it is OK to push.

---
 mg-schema-update | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mg-schema-update +1 -1
index 43f313a..44e4283 100755
@@ -102,7 +102,7 @@ sub getstate () {
 	    if (!$there) {
 		$out->{Todo} = 1;
 		$out->{Msg} = "would break any old code";
-	    } elsif ($tst =~ m/Harmless|Preparatory/) {
+	    } elsif ($tst =~ m/Harmless|Preparatory|Ready|Needed/) {
 		$out->{Todo} = 2;
 		$out->{Msg} = "specified revision can cope";
 	    } else {
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#6 lore raw

PATCH 6/17 db updates: Make all INSERTs (except into steps) name columns explicitly

In reply to Ian Jackson

This makes the code more robust against schema updates. Specifically, if any columns were to be deleted, these runes would break. (Also if any column was inserted other than after the existing columns, although this is not something Postgres can currently do AIUI.)

Affected tables are:
flights_harness_touched
jobs
resources
runvars
steps

---
 Osstest/JobDB/Executive.pm |  4 +++-
 Osstest/TestSupport.pm     | 12 +++++++++---
 cs-adjust-flight           |  7 ++++---
 cs-bisection-step          |  3 ++-
 mg-allocate                |  2 +-
 mg-hosts                   |  1 +
 tcl/JobDB-Executive.tcl    |  4 +++-
 7 files changed, 23 insertions(+), 10 deletions(-)
Osstest/JobDB/Executive.pm +3 -1
index 45aabd4..0d1b3be 100644
@@ -191,7 +191,9 @@ END
 
     if (!$already) {
         $dbh_tests->do(<<END, {}, $fl,$rev);
-            INSERT INTO flights_harness_touched VALUES (?,?)
+            INSERT INTO flights_harness_touched
+                        (flight, harness)
+                 VALUES (?,?)
 END
     }
 }
Osstest/TestSupport.pm +9 -3
index e6599db..f10d56e 100644
@@ -309,7 +309,9 @@ sub store_runvar ($$) {
 		  WHERE flight=? AND job=? AND name=? AND synth='t'
 END
         $dbh_tests->do(<<END,{}, $flight,$job, $param,$value);
-            INSERT INTO runvars VALUES (?,?,?,?,'t')
+            INSERT INTO runvars
+                        (flight, job, name, val, synth)
+                 VALUES (?,?,?,?,'t')
 END
     });
     $r{$param}= get_runvar($param, "$flight.$job");
@@ -368,7 +370,9 @@ END
 		  WHERE flight=? AND job=? AND name=? AND synth='t'
 END
 	$dbh_tests->do(<<END, undef, $flight, $job, $param, $value+1);
-            INSERT INTO runvars VALUES (?,?,?,?,'t')
+            INSERT INTO runvars
+                        (flight, job, name, val, synth)
+                 VALUES (?,?,?,?,'t')
 END
     });
     logm("runvar increment: $param=$value");
@@ -1775,7 +1779,9 @@ END
             logm("select_ether $prefix:... $ether (first in flight)");
         }
         $dbh_tests->do(<<END, {}, $flight,$job,$vn,$ether);
-            INSERT INTO runvars VALUES (?,?,?,?,'t')
+            INSERT INTO runvars
+                        (flight, job, name, val, synth)
+                 VALUES (?,?,?,?,'t')
 END
         my $chkrow= $dbh_tests->selectrow_hashref(<<END,{}, $flight);
 	    SELECT val, count(*) FROM runvars WHERE flight=?
cs-adjust-flight +4 -3
index 03257a6..0be104e 100755
@@ -196,11 +196,11 @@ sub copy_jobs ($$) {
     my ($srcflight, $jobs) = @_;
     prep_rm_jobs();
     my @job_copy_qs = map { $dbh_tests->prepare($_) }
-        ("INSERT INTO jobs".
+        ("INSERT INTO jobs (flight, job, recipe, status)".
          "     SELECT ?, job, recipe, 'queued'".
          "       FROM jobs".
          "      WHERE flight = ? AND job = ?",
-         "INSERT INTO runvars".
+         "INSERT INTO runvars (flight, job, name, val, synth)".
          "     SELECT ?, job, name, val, 'f'".
          "       FROM runvars".
          "      WHERE flight = ? AND job = ? AND NOT synth");
@@ -246,7 +246,8 @@ sub change__copy_jobs {
 our $runvar_rm_q = $dbh_tests->prepare
     ("DELETE FROM runvars WHERE flight = ? AND job = ? AND name = ?");
 our $runvar_insert_q = $dbh_tests->prepare
-    ("INSERT INTO runvars VALUES (?, ?, ?, ?, 'f')");
+    ("INSERT INTO runvars (flight, job, name, val, synth)".
+     " VALUES (?, ?, ?, ?, 'f')");
 
 sub runvar_set ($$$;$) {
     my ($job, $name, $val, $xwhat) = @_;
cs-bisection-step +2 -1
index 76f5010..13ccd7a 100755
@@ -1255,7 +1255,8 @@ END
             " from $copyflight)\n";
 
         $dbh_tests->do(<<END, {}, $popflight,$popjob,$recipe);
-            INSERT INTO jobs VALUES (?, ?, ?, 'queued')
+            INSERT INTO jobs (flight, job, recipe, status)
+                      VALUES (?, ?, ?, 'queued')
 END
         $dbh_tests->do(<<END, {}, $popflight,$popjob);
             INSERT INTO runvars (
mg-allocate +1 -1
index 4f02ce5..dadac3c 100755
@@ -180,7 +180,7 @@ sub alloc_1rescand ($$) {
 
     if ($allocate && $restype eq 'share-flight' && $shareix == $tid) {
 	$dbh_tests->do(<<END,{},
-            INSERT INTO resources
+            INSERT INTO resources (restype, resname, shareix, owntaskid)
                  (SELECT ? AS restype,
                          ? AS resname,
                          ? AS shareix,
mg-hosts +1 -0
index bd67a0a..5cdece5 100755
@@ -178,6 +178,7 @@ sub cmd_create_like () {
         foreach my $dst (l($dsts)) {
             $dbh_tests->do(<<END,{}, $dst,$src);
                 INSERT INTO resources
+                       (restype, resname, shareix, owntaskid)
                 SELECT restype,
                        ? AS resname,
                        0 AS shareix,
tcl/JobDB-Executive.tcl +3 -1
index 6b9bcb0..414a77e 100644
@@ -282,7 +282,9 @@ proc spawn-step-begin {flight job ts stepnovar} {
 		set stepno 1
 	    }
 	    db-execute "
-		INSERT INTO steps
+		INSERT INTO steps (flight, job, stepno,
+                                   step, status,
+                                   testid)
 		    VALUES ([pg_quote $flight], [pg_quote $job], $stepno,
 			    [pg_quote $ts], 'running',
 			    'STARTING')
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#7 lore raw

PATCH 7/17 step logfiles: Break out $logfilename in two places

In reply to Ian Jackson

No functional change.

---
 determine-failure-reasons | 4 ++--
 sg-report-flight          | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)
determine-failure-reasons +2 -2
index ecff332..a3b2100 100755
@@ -52,8 +52,8 @@ sub gethosts ($) {
 }
 
 while (my $step= $stepsq->fetchrow_hashref) {
-    $step->{Log}= "$c{Logs}/$step->{flight}/$step->{job}/".
-        "$step->{stepno}.$step->{step}.log";
+    my $logfile = "$step->{stepno}.$step->{step}.log";
+    $step->{Log}= "$c{Logs}/$step->{flight}/$step->{job}/".$logfile;
 
     if (!stat $step->{Log}) {
         die "$step->{Log} $!" unless $!==&ENOENT;
sg-report-flight +2 -1
index fd8a68b..ec30ed0 100755
@@ -1167,8 +1167,9 @@ END
 		: ('#ffff00',250);
 	}
 	my $ch = "bgcolor=\"$bgc\"";
+	my $logfilename= "$s->{stepno}.$s->{step}.log";
 	my $h = "<a href=\"".encode_entities($s->{job}).
-	    "/$s->{stepno}.".encode_entities($s->{step}).".log\">";
+	    "/".encode_entities($logfilename)."\">";
 	#print H "[$s->{stepno}] ";
 	$h .= encode_entities($sum_core);
 	$h .= "</a>";
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#8 lore raw

PATCH 8/17 step logfiles: Standalone mode: Do not print uninformative $script value

In reply to Ian Jackson

Right now, this is sometimes wrong; even if it were right, it's not going to be interesting in the transcript since the actual script name is obvious from context.

Now this function does not care if $script is undef.

While we're here, fix the prototype (which is mostly commentary here, as it is not used for method calls).

---
 Osstest/JobDB/Standalone.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Osstest/JobDB/Standalone.pm +2 -2
index 4842e69..af93196 100644
@@ -88,9 +88,9 @@ sub current_flight ($) {
 
 sub job_ensure_started ($) { }
 
-sub step_start ($$) {
+sub step_start ($$;$) {
     my ($jd,$testid,$script) = @_;
-    logm("========== $flight.$job step $testid running $script ==========");
+    logm("========== $flight.$job step $testid running ==========");
 }
 
 sub step_finish ($$) { #method
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#9 lore raw

PATCH 9/17 substep logfiles: Move defaulting of $script into Executive

In reply to Ian Jackson

We are going to want to default this here in a more sophisticated way, but we can't do that if it's already been defaulted from $0 earlier.

The other consumer of this default was in JobDB/Standalone, but we have just changed that to ignore it. So, no functional change.

---
 Osstest/JobDB/Executive.pm | 4 ++++
 Osstest/TestSupport.pm     | 4 ----
 2 files changed, 4 insertions(+), 4 deletions(-)
Osstest/JobDB/Executive.pm +4 -0
index 0d1b3be..fbbb5ac 100644
@@ -252,6 +252,10 @@ END
         INSERT INTO steps (flight,job,stepno, step,status, testid,started)
             VALUES (?,?,?, ?,'running', ?,?)
 END
+    if (!defined $script) {
+	$script = $0;
+	$script =~ s{^.*/}{};
+    }
     my $stepno;
     db_retry($flight,[qw(running)], $dbh_tests,[qw(flights)],sub {
 	$snq->execute($flight,$job);
Osstest/TestSupport.pm +0 -4
index f10d56e..5a951e5 100644
@@ -248,10 +248,6 @@ sub complete_testid ($) {
 sub substep_start ($;$) {
     my ($testid,$script) = @_;
     complete_testid(\$testid);
-    if (!defined $script) {
-	$script = $0;
-	$script =~ s{^.*/}{};
-    }
     $mjobdb->step_start($testid,$script);
 }
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#10 lore raw

PATCH 10/17 step logfiles: Provide new column

In reply to Ian Jackson

We will write things into it, and use it, soon.

This is the start of a "Populate-then-rely" schema change, as described in schema/README.updates. Specifically, the steps:
1. Commit: new schema update `add', status Preparatory
2. Commit: new schema update `constraint', status Unfinished

---
 schema/steps-logfile-add.sql        |  8 ++++++++
 schema/steps-logfile-constraint.sql | 10 ++++++++++
 2 files changed, 18 insertions(+)
 create mode 100644 schema/steps-logfile-add.sql
 create mode 100644 schema/steps-logfile-constraint.sql
schema/steps-logfile-add.sql new file +8 -0
new file mode 100644
index 0000000..5e37b10
@@ -0,0 +1,8 @@
+-- ##OSSTEST## 003 Preparatory
+--
+-- Previously, the logfile name was inferred from "stepno" and
+-- "testid".  We want to be able to set it explicitly for substeps.
+--
+-- This change is compatible with old code.
+
+ALTER TABLE steps ADD COLUMN logfile TEXT;
schema/steps-logfile-constraint.sql new file +10 -0
new file mode 100644
index 0000000..100bb31
@@ -0,0 +1,10 @@
+-- ##OSSTEST## 004 Unfinished
+--
+-- Previously, the logfile name was inferred from "stepno" and
+-- "testid".  Newer code will need it to be set explicitly.
+
+UPDATE steps
+   SET logfile = stepno || '.' || step || '.log'
+ WHERE logfile is null;
+
+ALTER TABLE steps ALTER COLUMN logfile SET NOT NULL;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#11 lore raw

PATCH 11/17 substep logfiles: Populate new logfile column, at all, for substeps

In reply to Ian Jackson

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.

---
 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(-)
Osstest/JobDB/Executive.pm +9 -5
index fbbb5ac..e1e2052 100644
@@ -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 ----------");
 }
Osstest/JobDB/Standalone.pm +2 -2
index af93196..d9a90fc 100644
@@ -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 ==========");
 }
 
Osstest/TestSupport.pm +1 -1
index 5a951e5..a05dd97 100644
@@ -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 ($$) {
schema/steps-logfile-add.sql +1 -1
index 5e37b10..abc89b9 100644
@@ -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.
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#12 lore raw

PATCH 12/17 substep logfiles: Set logfile and step columns correctly for substeps

In reply to Ian Jackson

If we are running under sg-run-job, OSSTEST_TESTID will be set to the testid of the parent step (ie, the step created by sg-run-job which relates to the execution of the whole script).

Unless the caller has specified otherwise, the log and script are the same as for the parent step.

---
 Osstest/JobDB/Executive.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Osstest/JobDB/Executive.pm +13 -0
index e1e2052..a7a6696 100644
@@ -254,6 +254,19 @@ END
                            status,testid,started)
             VALUES (?,?,?,?, ?, 'running',?,?)
 END
+    my $parent_testid = $ENV{OSSTEST_TESTID};
+    if ((!defined $logfile || !defined $script) && defined $parent_testid) {
+	my $parentq = $dbh_tests->prepare(<<END);
+            SELECT logfile, step FROM steps
+             WHERE flight=? AND job=? AND testid=?
+END
+	db_retry($flight,[qw(running)], $dbh_tests,[],sub {
+            $parentq->execute($flight,$job,$parent_testid);
+            my $row = $parentq->fetchrow_hashref();
+	    $logfile //= $row->{logfile};
+	    $script //= $row->{script};
+	});
+    }
     if (!defined $script) {
 	$script = $0;
 	$script =~ s{^.*/}{};
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#13 lore raw

PATCH 13/17 step logfiles: Honour new logfile column

In reply to Ian Jackson

There are the following places in the tree where we construct the logfile name from stepno and step:

 * tcl/JobDB-Executive            main decision about logfile name  } OK
 * JobDB::Executive               final fallback for new steps      } keep
 * steps-logfile-constraint.sql   default for old data              }

* sg-report-flight (twice) } both read stepno and step from the db;
* determine-failure-reasons } here we teach them to try logfile first

Now substep logs will have correct links in the job output, as soon as the logfile column has the right data.

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

6. Optionally commit: code which reads new column, but which tolerates it containing NULL/DEFAULT. (`add' is already Needed.)

---
 determine-failure-reasons | 2 +-
 sg-report-flight          | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)
determine-failure-reasons +1 -1
index a3b2100..89c67e6 100755
@@ -52,7 +52,7 @@ sub gethosts ($) {
 }
 
 while (my $step= $stepsq->fetchrow_hashref) {
-    my $logfile = "$step->{stepno}.$step->{step}.log";
+    my $logfile = $step->{logfile} // "$step->{stepno}.$step->{step}.log";
     $step->{Log}= "$c{Logs}/$step->{flight}/$step->{job}/".$logfile;
 
     if (!stat $step->{Log}) {
sg-report-flight +3 -2
index ec30ed0..4e3560e 100755
@@ -1001,7 +1001,8 @@ END
         printf H "<td>%s</td>", show_abs_time $step->{started};
 
         my $st= $step->{status};
-        my $logfilename= "$step->{stepno}.$step->{step}.log";
+        my $logfilename= $step->{logfile}
+	    // "$step->{stepno}.$step->{step}.log";
         printf H "<td bgcolor='%s'><a href='%s'>%s</a></td>",
 	    (html_status2_colour_priority($st))[0],
             encode_entities(uri_escape($logfilename)),
@@ -1167,7 +1168,7 @@ END
 		: ('#ffff00',250);
 	}
 	my $ch = "bgcolor=\"$bgc\"";
-	my $logfilename= "$s->{stepno}.$s->{step}.log";
+	my $logfilename= $s->{logfile} // "$s->{stepno}.$s->{step}.log";
 	my $h = "<a href=\"".encode_entities($s->{job}).
 	    "/".encode_entities($logfilename)."\">";
 	#print H "[$s->{stepno}] ";
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#14 lore raw

PATCH 14/17 step logfiles: Make substep_* take $logfile, not $script

In reply to Ian Jackson

The $script parameter was used by Standalone to print a message, but this is no longer done.

It is used by Executive as the value for the "step" column in the steps table, which shows up as "script" in the output from sg-report-flight. But, when running under sg-run-job, JobDB::Executive already has a better source of the script name: the parent step (as reported in OSSTEST_TESTID). When not running under sg-run-job the use of $0 is good enough.

Finally, it is used by Executive as a logfile name. But when running under sg-run-job, JobDB::Executive gets the right logfile name anyway (as above); and when not running under sg-run-job there is no default logfile.

Conversely, substeps might organise their own logfile.

So abolish $script from the TestSupport substep API. Replace it in substep_start and substep_eval with a $logfile parameter.

Update all call sites to no longer pass $script. None make their own logfiles, so none pass the new parameter $logfile.

---
 Osstest/TestSupport.pm | 10 +++++-----
 ts-examine-serial-post |  2 +-
 ts-xtf-run             |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)
Osstest/TestSupport.pm +5 -5
index a05dd97..6e19b28 100644
@@ -246,9 +246,9 @@ sub complete_testid ($) {
 }
 
 sub substep_start ($;$) {
-    my ($testid,$script) = @_;
+    my ($testid,$logfile) = @_;
     complete_testid(\$testid);
-    $mjobdb->step_start($testid,undef,$script);
+    $mjobdb->step_start($testid,$logfile);
 }
 
 sub substep_finish ($$) {
@@ -258,10 +258,10 @@ sub substep_finish ($$) {
 }
 
 sub substep_eval ($$;$) {
-    # substep_eval(TESTID, [SCRIPTNAME], sub { ... });
+    # substep_eval(TESTID, [LOGFILE], sub { ... });
     my $fn = pop @_;
-    my ($testid,$script) = @_;
-    substep_start($testid,$script);
+    my ($testid,$logfile) = @_;
+    substep_start($testid,$logfile);
     eval { $fn->(); };
     if (length $@) {
 	logm("substep ($testid) failed: $@");
ts-examine-serial-post +1 -1
index 2d5c103..77d8e5d 100755
@@ -44,7 +44,7 @@ sub cookies () {
 	my $key = $1;
 	my $substep = "examine-serial/$key";
 	my $ci = { K => $key, C => $r{$rv}, Substep => $substep };
-	substep_start($ci->{Substep}, 'ts-examine-serial-post');
+	substep_start($ci->{Substep});
 	push @cookies, $ci;
     }
 }
ts-xtf-run +1 -1
index cef45c8..5b136a6 100755
@@ -62,7 +62,7 @@ sub do_one_test ($) {
     my $ret;
     my $osstest_result;
 
-    substep_start($tid, $cmd);
+    substep_start($tid);
 
     if (!eval {
             $output = target_cmd_output_root($ho, <<END, 600);
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#15 lore raw

PATCH 15/17 step logfiles: sg-run-job: Break out step-log-leafname

In reply to Ian Jackson

No functional change.

---
 tcl/JobDB-Executive.tcl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tcl/JobDB-Executive.tcl +5 -1
index 414a77e..ed636e4 100644
@@ -437,12 +437,16 @@ proc preserve-task {seconds} {
     exec setsid sleep $seconds > /dev/null < /dev/null 2> /dev/null &
 }
 
+proc step-log-leafname {stepno ts} {
+    return $stepno.$ts.log
+}
+
 proc step-log-filename {flight job stepno ts} {
     global c
     set logdir $c(Logs)/$flight/$job
     file mkdir $c(Logs)/$flight
     file mkdir $logdir
-    return $logdir/$stepno.$ts.log
+    return $logdir/[step-log-leafname $stepno $ts]
 }
 
 }; # namespace eval jobdb
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#16 lore raw

PATCH 16/17 step logfiles: Populate logfile column with logfile name

In reply to Ian Jackson

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

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

---
 schema/steps-logfile-constraint.sql | 2 +-
 tcl/JobDB-Executive.tcl             | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)
schema/steps-logfile-constraint.sql +1 -1
index 100bb31..462941e 100644
@@ -1,4 +1,4 @@
--- ##OSSTEST## 004 Unfinished
+-- ##OSSTEST## 004 Ready
 --
 -- Previously, the logfile name was inferred from "stepno" and
 -- "testid".  Newer code will need it to be set explicitly.
tcl/JobDB-Executive.tcl +3 -2
index ed636e4..0734018 100644
@@ -281,12 +281,13 @@ proc spawn-step-begin {flight job ts stepnovar} {
 	    } else {
 		set stepno 1
 	    }
+	    set logfile [step-log-leafname $stepno $ts]
 	    db-execute "
 		INSERT INTO steps (flight, job, stepno,
-                                   step, status,
+                                   step, logfile, status,
                                    testid)
 		    VALUES ([pg_quote $flight], [pg_quote $job], $stepno,
-			    [pg_quote $ts], 'running',
+			    [pg_quote $ts], [pg_quote $logfile], 'running',
 			    'STARTING')
 	    "
 	} emsg]} {
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#17 lore raw

PATCH 17/17 step logfiles: Rely on new logfile column

In reply to Ian Jackson

These are the three places which read logfile from the db, but had a fallback to a computation involving stepno and step.

But, after steps-logfile-constraint, the logfile column is NOT NULL (and populated with computed default data if need be) so this is not needed any more

This is part of a "Populate-then-rely" schema change, as described in schema/README.updates. Specifically, the step:
10. Optionally commit: code which relies on new column, and does not necessarily tolerate NULL/DEFAULT; changing `constraint' to Needed.

---
 determine-failure-reasons           | 2 +-
 schema/steps-logfile-constraint.sql | 2 +-
 sg-report-flight                    | 5 ++---
 3 files changed, 4 insertions(+), 5 deletions(-)
determine-failure-reasons +1 -1
index 89c67e6..42791c3 100755
@@ -52,7 +52,7 @@ sub gethosts ($) {
 }
 
 while (my $step= $stepsq->fetchrow_hashref) {
-    my $logfile = $step->{logfile} // "$step->{stepno}.$step->{step}.log";
+    my $logfile = $step->{logfile};
     $step->{Log}= "$c{Logs}/$step->{flight}/$step->{job}/".$logfile;
 
     if (!stat $step->{Log}) {
schema/steps-logfile-constraint.sql +1 -1
index 462941e..b261fd0 100644
@@ -1,4 +1,4 @@
--- ##OSSTEST## 004 Ready
+-- ##OSSTEST## 004 Needed
 --
 -- Previously, the logfile name was inferred from "stepno" and
 -- "testid".  Newer code will need it to be set explicitly.
sg-report-flight +2 -3
index 4e3560e..135f0d4 100755
@@ -1001,8 +1001,7 @@ END
         printf H "<td>%s</td>", show_abs_time $step->{started};
 
         my $st= $step->{status};
-        my $logfilename= $step->{logfile}
-	    // "$step->{stepno}.$step->{step}.log";
+        my $logfilename= $step->{logfile};
         printf H "<td bgcolor='%s'><a href='%s'>%s</a></td>",
 	    (html_status2_colour_priority($st))[0],
             encode_entities(uri_escape($logfilename)),
@@ -1168,7 +1167,7 @@ END
 		: ('#ffff00',250);
 	}
 	my $ch = "bgcolor=\"$bgc\"";
-	my $logfilename= $s->{logfile} // "$s->{stepno}.$s->{step}.log";
+	my $logfilename= $s->{logfile};
 	my $h = "<a href=\"".encode_entities($s->{job}).
 	    "/".encode_entities($logfilename)."\">";
 	#print H "[$s->{stepno}] ";
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel