All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Wei Liu <wei.liu2@citrix.com>, Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [OSSTEST PATCH v3 10/25] Executive: Support substeps
Date: Tue, 6 Sep 2016 14:09:25 +0100	[thread overview]
Message-ID: <1473167380-957-11-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1473167380-957-1-git-send-email-wei.liu2@citrix.com>

From: Ian Jackson <ian.jackson@eu.citrix.com>

ts-* scripts can now create `substeps'.  For the purposes of
archaeology etc., a substep is just like a step.  But it does
correspond to a single specific ts-* invocation.

Instead, it is started and finished explicitly as required.

The whole job implementation code needs to explicitly assign a unique
stable testid to each substep.

The `script' parameter is stored in the `step' field in the database,
which is used only for reporting.  These do not need to be unique.

All substeps started are should also be finished, by the end of the
job.  If this is not done, the job will be regarded as broken (if it
is not already failed or aborted).  (But a substep might be finished
by a different ts-* script to the one that started it.)

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
v2: Permit setting the step status to `skip' too, now that this
    patch is rebased onto the step status skip support.
---
 Osstest/JobDB/Executive.pm  | 51 +++++++++++++++++++++++++++++++++++++++++++++
 Osstest/JobDB/Standalone.pm | 10 +++++++++
 Osstest/TestSupport.pm      | 11 ++++++++++
 sg-run-job                  |  6 ++++++
 tcl/JobDB-Executive.tcl     | 32 ++++++++++++++++++++++++++++
 tcl/JobDB-Standalone.tcl    |  2 ++
 6 files changed, 112 insertions(+)

diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm
index c21eba7..76f3293 100644
--- a/Osstest/JobDB/Executive.pm
+++ b/Osstest/JobDB/Executive.pm
@@ -163,6 +163,57 @@ END
     logm("starting $flight started=$now") if $count>0;
 }
 
+sub step_start ($$) { #method
+    my ($jd,$testid,$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', ?,?)
+END
+    my $stepno;
+    db_retry($flight,[qw(running)], $dbh_tests,[qw(flights)],sub {
+	$snq->execute($flight,$job);
+	($stepno) = $snq->fetchrow_array();
+	$stepno //= 0;
+	$stepno++;
+	$createq->execute($flight,$job,$stepno, $script, $testid,time);
+    });
+    logm("---------- substep $stepno $testid running ----------");
+}
+
+sub step_finish ($$) { #method
+    my ($jd,$testid,$stepstatus) = @_;
+    die "$flight.$job $testid $stepstatus" unless grep { $stepstatus eq $_ }
+	qw(pass fail skip blocked broken);
+    my $checkq = $dbh_tests->prepare(<<END);
+        SELECT stepno, status
+          FROM steps
+         WHERE flight=?
+           AND job=?
+           AND testid=?
+END
+    my $setq = $dbh_tests->prepare(<<END);
+        UPDATE steps
+           SET status=?, finished=?
+         WHERE flight=?
+           AND job=?
+           AND testid=?
+           AND stepno=?
+END
+    my ($stepno,$oldstatus);
+    db_retry($flight,[qw(running)], $dbh_tests,[qw(flights)],sub {
+	$checkq->execute($flight,$job,$testid);
+	($stepno, $oldstatus) = $checkq->fetchrow_array();
+	die "$flight.$job $testid $stepno $oldstatus ?"
+	    unless $oldstatus eq 'running';
+	$setq->execute($stepstatus,time, $flight,$job,$testid, $stepno);
+    });
+    logm("---------- substep $stepno $testid $stepstatus ----------");
+}
+
 sub host_check_allocated ($$) { #method
     my ($jd, $ho) = @_;
 
diff --git a/Osstest/JobDB/Standalone.pm b/Osstest/JobDB/Standalone.pm
index 98d0173..21ea07b 100644
--- a/Osstest/JobDB/Standalone.pm
+++ b/Osstest/JobDB/Standalone.pm
@@ -87,6 +87,16 @@ sub current_flight ($) {
 
 sub job_ensure_started ($) { }
 
+sub step_start ($$) {
+    my ($jd,$testid,$script) = @_;
+    logm("========== $flight.$job step $testid running $script ==========");
+}
+
+sub step_finish ($$) { #method
+    my ($jd,$testid,$stepstatus) = @_;
+    logm("========== $flight.$job step $testid $stepstatus ==========");
+}
+
 sub host_check_allocated ($$) { #method
     my ($jd, $ho) = @_;
 
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 7eb7bc4..04b8b3f 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -43,6 +43,7 @@ BEGIN {
                       ts_get_host_guest
 
                       fail broken logm $logm_handle $logm_prefix
+                      substep_start substep_finish
                       get_filecontents
                       report_once
 
@@ -231,6 +232,16 @@ END
                          : "($flight.$job not marked $newst)");
 }
 
+sub substep_start ($$) {
+    my ($testid,$script) = @_;
+    $mjobdb->step_start($testid,$script);
+}
+
+sub substep_finish ($$) {
+    my ($testid,$stepstatus) = @_;
+    $mjobdb->step_finish($testid,$stepstatus);
+}
+
 sub get_filecontents ($;$) {
     my ($path, $ifnoent) = @_;  # $ifnoent=undef => is error
     my $data= get_filecontents_core_quiet($path);
diff --git a/sg-run-job b/sg-run-job
index 1c154be..01c57aa 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -91,6 +91,12 @@ proc run-job {job} {
 	run-ts  !broken capture-logs      ts-logs-capture + host
     }
 
+    if {$ok} {
+        if {[jobdb::job-check-escaped-steps $flight $job]} {
+            set ok 0
+        }
+    }
+
     if {$truncate} {
        if {$ok} { setstatus truncated                                     }
        set ok 0
diff --git a/tcl/JobDB-Executive.tcl b/tcl/JobDB-Executive.tcl
index 472bab5..6225bd9 100644
--- a/tcl/JobDB-Executive.tcl
+++ b/tcl/JobDB-Executive.tcl
@@ -80,6 +80,38 @@ proc read-runvar {flight job name {val {}}} {
     return $val
 }
 
+proc job-check-escaped-steps {flight job} {
+    global runstepinfo
+    transaction flights {
+	set any 0
+
+	db-execute-array runstepinfo "
+            SELECT stepno, testid
+              FROM steps
+             WHERE flight = [pg_quote $flight]
+               AND job = [pg_quote $job]
+               AND status = 'running'
+        " {
+	    logputs stderr \
+ "$flight.$job step #$runstepinfo(stepno) $runstepinfo(testid) still running!"
+	    set any 1
+	}
+
+	if {$any} {
+	    db-execute "
+                UPDATE jobs
+		   SET status='broken'
+		 WHERE flight = [pg_quote $flight]
+		   AND job = [pg_quote $job]
+		   AND status<>'aborted'
+		   AND status<>'broken'
+		   AND status<>'fail'
+            "
+	}
+    }
+    return $any
+}
+
 proc set-flight {} {
     global flight argv env
 
diff --git a/tcl/JobDB-Standalone.tcl b/tcl/JobDB-Standalone.tcl
index 2d8b319..375e6ba 100644
--- a/tcl/JobDB-Standalone.tcl
+++ b/tcl/JobDB-Standalone.tcl
@@ -57,6 +57,8 @@ proc read-runvar {flight job name {val {}}} {
     return $val
 }
 
+proc job-check-escaped-steps {flight job} { }
+
 proc ensure-db-open {} {
     global c
     if {![catch { osstestdb version }]} { return }
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-09-06 13:16 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-06 13:09 [OSSTEST PATCH v3 00/25] Integrate XTF into OSSTest Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 01/25] Executive: Previous duration estimator: use overall time, not sum of steps Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 02/25] ts-hosts-allocate-Executive: Replace some odd commas with semicolons Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 03/25] sg-run-job: Add emacs mode comment Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 04/25] step status skip: Ignore in cs-bisection-step Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 05/25] step status skip: Ignore in report_run_getinfo Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 06/25] step status skip: Implement in sg-report-flight Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 07/25] ts-hosts-allocate-Executive: pass $plan to hid_find_possibilities Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 08/25] ts-hosts-allocate-Executive: Support diverse-CLASS hostflag Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 09/25] DO NOT APPLY make-flight-diverse-test: test case for " Wei Liu
2016-09-06 13:09 ` Wei Liu [this message]
2016-09-06 13:09 ` [OSSTEST PATCH v3 11/25] DO NOT APPLY make-flight-substep-test Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 12/25] DO NOT APPLY provide ts-substep-test Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 13/25] ts-xen-build: always compile in FEP support Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 14/25] ap-common: add xtf tree Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 15/25] DO NOT APPLY point xtf to my personal tree Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 16/25] BuildSupport: move buildcmd_stamped_logged here Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 17/25] Introduce ts-xtf-build Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 18/25] sg-run-job: create xtf build recipe Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 19/25] Introduce ts-xtf-install Wei Liu
2016-09-06 14:01   ` Ian Jackson
2016-09-06 13:09 ` [OSSTEST PATCH v3 20/25] mfi-common: create xtf build job for 4.4 onwards Wei Liu
2016-09-06 14:06   ` Ian Jackson
2016-09-08 17:00     ` Wei Liu
2016-09-08 17:41       ` Ian Jackson
2016-09-08 18:11         ` Wei Liu
2016-09-09 10:09           ` Ian Jackson
2016-09-06 13:09 ` [OSSTEST PATCH v3 21/25] Introduce ts-xtf-fep Wei Liu
2016-09-06 14:07   ` Ian Jackson
2016-09-06 13:09 ` [OSSTEST PATCH v3 22/25] Introduce ts-xtf-run Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 23/25] sg-run-job: test-xtf recipe Wei Liu
2016-09-06 13:09 ` [OSSTEST PATCH v3 24/25] make-flight: create 5 xtf jobs Wei Liu
2016-09-08 17:01   ` Wei Liu
2016-09-08 17:41     ` Ian Jackson
2016-09-06 13:09 ` [OSSTEST PATCH v3 25/25] Create XTF branch Wei Liu
2016-09-06 14:03   ` Ian Jackson
2016-09-06 19:16     ` Wei Liu
2016-09-08 14:47       ` Ian Jackson
2016-09-08 17:07         ` Wei Liu
2016-09-08 17:45           ` Ian Jackson
2016-09-08 18:07             ` Wei Liu
2016-09-09 10:04               ` Ian Jackson
2016-09-06 19:14   ` Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1473167380-957-11-git-send-email-wei.liu2@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.