xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: ian.jackson@eu.citrix.com, xen-devel@lists.xen.org
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH OSSTEST v2 1/3] cs-adjust-flight: Add job-status to report job stats
Date: Fri, 2 Oct 2015 13:05:47 +0100	[thread overview]
Message-ID: <1443787549-7467-1-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1443787531.11707.80.camel@citrix.com>

The return code of sg-run-job does not reflect the state of the job,
which is instead written to the database. For the benefit of running
tests in a loop until failure add a command to retrieve the status to
stdout.

Since this new op is not a change adjust the doc comment accordingly.

While there add a doc string for the undocumented "branch" subcommand
of cs-adjust-flight.

Add a get-job-status command to the standalone helper script.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
v2: Replaces "standalone: Add get-job-status to pick status out of
standalone.db" with a variant using cs-adjust-flight
---
 cs-adjust-flight | 23 +++++++++++++++++++++--
 standalone       | 40 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 59 insertions(+), 4 deletions(-)

diff --git a/cs-adjust-flight b/cs-adjust-flight
index 834e2c8..4e071c8 100755
--- a/cs-adjust-flight
+++ b/cs-adjust-flight
@@ -3,9 +3,9 @@
 # destination flight must already exist
 #
 # args:
-#   <dst-flight> [<change> ...]
+#   <dst-flight> [<op> ...]
 #
-# <change>:
+# <op>:
 #   copy <flight>
 #   copy-jobs <flight> <job-spec>
 #   jobs-list <job-spec>
@@ -16,6 +16,8 @@
 #   runvar-perlop <job-spec> <var-spec> <perl-expr>
 #   recipe-set <job-spec> <new-value>
 #   intended-blessing <intended-blessing>
+#   branch <new-branch>
+#   job-status <job-spec>
 #
 # <foo-spec>:
 #   <foo-name>
@@ -341,6 +343,23 @@ sub change__branch {
     verbose "$dstflight branch set to $branch\n";
 }
 
+sub change__job_status {
+    die unless @changes >= 1;
+    my $jobs = shift @changes;
+
+    my $q = $dbh_tests->prepare(<<END);
+        SELECT status
+          FROM jobs
+         WHERE flight = ? AND job = ?
+END
+    for_jobs($dstflight, $jobs, sub {
+	my ($job) = @_;
+	$q->execute($dstflight, $job);
+	my ($s) = $q->fetchrow_array();
+	print "$job $s\n";
+    });
+}
+
 sub changes () {
     debug("CHANGES...\n");
 
diff --git a/standalone b/standalone
index f64462e..b362b38 100755
--- a/standalone
+++ b/standalone
@@ -35,6 +35,11 @@ Operations:
   hosts next time. Otherwise osstest will complain if you change the
   host(s) which a job is running on on successive runs.
 
+* get-job-status [cf] [JOB]
+
+  Prints the status (pass, fail, running, etc) of the given job to
+  stdout.
+
 Options:
 
 -c FILE, --config=FILE        Use FILE as configuration file
@@ -140,8 +145,9 @@ if [ $reuse -eq 0 ]; then
     read
 fi
 
-if [ ! -f standalone.db ] ; then
-    echo "No standalone.db? Run standalone-reset." >&2
+db="standalone.db"
+if [ ! -f $db ] ; then
+    echo "No $db? Run standalone-reset." >&2
     exit 1
 fi
 
@@ -199,6 +205,22 @@ with_logging() {
     fi
 }
 
+job_status() {
+    flight=$1; shift
+    job=$1; shift
+
+    status=$(OSSTEST_CONFIG=$config \
+		./cs-adjust-flight $flight job-status $job)
+
+    case "$status" in
+	$job\ *) echo ${status#$job };;
+	*)
+	    echo >&2 "ERROR: $status"
+	    exit 1
+	    ;;
+    esac
+}
+
 # other potential ops:
 # - run standalone reset
 
@@ -304,6 +326,20 @@ case $op in
 	OSSTEST_JOB=$job \
 	    with_logging logs/$flight/$job.$ts.log ./$ts $hosts $@
 	;;
+
+    get-job-status)
+	need_flight;
+
+	if [ $# -ne 1 ] ; then
+	    echo "get-job-status: Need job" >&2
+	    exit 1
+	fi
+
+	job=$1; shift
+
+	job_status $flight $job
+
+	;;
     *)
 	echo "Unknown op $op" ; exit 1 ;;
 esac
-- 
2.5.3

  reply	other threads:[~2015-10-02 12:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-02 12:05 [PATCH OSSTEST v2 0/3] Misc standalone wrapper improvements Ian Campbell
2015-10-02 12:05 ` Ian Campbell [this message]
2015-10-05 10:48   ` [PATCH OSSTEST v2 1/3] cs-adjust-flight: Add job-status to report job stats Ian Jackson
2015-10-05 13:53     ` Ian Campbell
2015-10-02 12:05 ` [PATCH OSSTEST v2 2/3] standalone: Check job status at end of run-job Ian Campbell
2015-10-02 12:05 ` [PATCH OSSTEST v2 3/3] standalone: Make it possible to pass options to run-test Ian Campbell
2015-10-05 10:50   ` Ian Jackson
2015-10-05 13:47     ` Ian Campbell

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=1443787549-7467-1-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).