xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH OSSTEST 0/3] Misc standalone wrapper improvements
@ 2015-09-29  9:37 Ian Campbell
  2015-09-29  9:37 ` [PATCH OSSTEST 1/3] standalone: Add get-job-status to pick status out of standalone.db Ian Campbell
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Ian Campbell @ 2015-09-29  9:37 UTC (permalink / raw)
  To: Ian.Jackson, xen-devel

I found these useful for debugging a recent issue.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH OSSTEST 1/3] standalone: Add get-job-status to pick status out of standalone.db
  2015-09-29  9:37 [PATCH OSSTEST 0/3] Misc standalone wrapper improvements Ian Campbell
@ 2015-09-29  9:37 ` Ian Campbell
  2015-09-29 14:04   ` Ian Jackson
  2015-09-29  9:37 ` [PATCH OSSTEST 2/3] standalone: Check job status at end of run-job Ian Campbell
  2015-09-29  9:37 ` [PATCH OSSTEST 3/3] standalone: Rotate logs rather than clobbering them Ian Campbell
  2 siblings, 1 reply; 9+ messages in thread
From: Ian Campbell @ 2015-09-29  9:37 UTC (permalink / raw)
  To: ian.jackson, xen-devel; +Cc: Ian Campbell

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.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 standalone | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/standalone b/standalone
index 60b6666..0a5d96f 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
 
@@ -198,6 +204,14 @@ with_logging() {
     fi
 }
 
+job_status() {
+    flight=$1; shift
+    job=$1; shift
+
+    sqlite3 $db \
+        "SELECT status FROM jobs WHERE flight='$flight' AND job='$job'"
+}
+
 # other potential ops:
 # - run standalone reset
 
@@ -303,6 +317,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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH OSSTEST 2/3] standalone: Check job status at end of run-job.
  2015-09-29  9:37 [PATCH OSSTEST 0/3] Misc standalone wrapper improvements Ian Campbell
  2015-09-29  9:37 ` [PATCH OSSTEST 1/3] standalone: Add get-job-status to pick status out of standalone.db Ian Campbell
@ 2015-09-29  9:37 ` Ian Campbell
  2015-09-29 14:04   ` Ian Jackson
  2015-09-29  9:37 ` [PATCH OSSTEST 3/3] standalone: Rotate logs rather than clobbering them Ian Campbell
  2 siblings, 1 reply; 9+ messages in thread
From: Ian Campbell @ 2015-09-29  9:37 UTC (permalink / raw)
  To: ian.jackson, xen-devel; +Cc: Ian Campbell

Check if the job passed and if not (so status is fail, broken, running
etc) then return an error.

This is convenient for scripting.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 standalone | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/standalone b/standalone
index 0a5d96f..e85457d 100755
--- a/standalone
+++ b/standalone
@@ -299,6 +299,11 @@ case $op in
 	OSSTEST_HOST_REUSE=$reuse \
 	OSSTEST_SIMULATE=$dryrun \
 	    with_logging logs/$flight/$job.log ./sg-run-job $job
+
+	status=`job_status $flight $job`
+	echo "$flight.$job status = $status" >&2
+	if [ "x$status" != xpass ] ; then exit 1; fi
+
 	;;
     run-test)
 	need_flight; need_host
-- 
2.5.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH OSSTEST 3/3] standalone: Rotate logs rather than clobbering them
  2015-09-29  9:37 [PATCH OSSTEST 0/3] Misc standalone wrapper improvements Ian Campbell
  2015-09-29  9:37 ` [PATCH OSSTEST 1/3] standalone: Add get-job-status to pick status out of standalone.db Ian Campbell
  2015-09-29  9:37 ` [PATCH OSSTEST 2/3] standalone: Check job status at end of run-job Ian Campbell
@ 2015-09-29  9:37 ` Ian Campbell
  2015-09-29 14:04   ` Ian Jackson
  2 siblings, 1 reply; 9+ messages in thread
From: Ian Campbell @ 2015-09-29  9:37 UTC (permalink / raw)
  To: ian.jackson, xen-devel; +Cc: Ian Campbell

Keep 300, for no better reason than cr-for-branches does.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 standalone | 1 +
 1 file changed, 1 insertion(+)

diff --git a/standalone b/standalone
index e85457d..c3ff9e2 100755
--- a/standalone
+++ b/standalone
@@ -196,6 +196,7 @@ ensure_logs() {
 with_logging() {
     local log=$1; shift
     ensure_logs
+    savelog -c 300 "$log" >/dev/null
     $@ 2>&1 | tee "$log"
     rc=${PIPESTATUS[0]}
     if [ $rc -ne 0 ] ; then
-- 
2.5.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH OSSTEST 2/3] standalone: Check job status at end of run-job.
  2015-09-29  9:37 ` [PATCH OSSTEST 2/3] standalone: Check job status at end of run-job Ian Campbell
@ 2015-09-29 14:04   ` Ian Jackson
  0 siblings, 0 replies; 9+ messages in thread
From: Ian Jackson @ 2015-09-29 14:04 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[PATCH OSSTEST 2/3] standalone: Check job status at end of run-job."):
> Check if the job passed and if not (so status is fail, broken, running
> etc) then return an error.
> 
> This is convenient for scripting.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH OSSTEST 1/3] standalone: Add get-job-status to pick status out of standalone.db
  2015-09-29  9:37 ` [PATCH OSSTEST 1/3] standalone: Add get-job-status to pick status out of standalone.db Ian Campbell
@ 2015-09-29 14:04   ` Ian Jackson
  2015-09-29 14:20     ` Ian Campbell
  0 siblings, 1 reply; 9+ messages in thread
From: Ian Jackson @ 2015-09-29 14:04 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[PATCH OSSTEST 1/3] standalone: Add get-job-status to pick status out of standalone.db"):
> 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.

Maybe this would be better as a cs-* utility, useable on production
instances too ?

Ian.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH OSSTEST 3/3] standalone: Rotate logs rather than clobbering them
  2015-09-29  9:37 ` [PATCH OSSTEST 3/3] standalone: Rotate logs rather than clobbering them Ian Campbell
@ 2015-09-29 14:04   ` Ian Jackson
  0 siblings, 0 replies; 9+ messages in thread
From: Ian Jackson @ 2015-09-29 14:04 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[PATCH OSSTEST 3/3] standalone: Rotate logs rather than clobbering them"):
> Keep 300, for no better reason than cr-for-branches does.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH OSSTEST 1/3] standalone: Add get-job-status to pick status out of standalone.db
  2015-09-29 14:04   ` Ian Jackson
@ 2015-09-29 14:20     ` Ian Campbell
  2015-09-29 15:02       ` Ian Jackson
  0 siblings, 1 reply; 9+ messages in thread
From: Ian Campbell @ 2015-09-29 14:20 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

On Tue, 2015-09-29 at 15:04 +0100, Ian Jackson wrote:
> Ian Campbell writes ("[PATCH OSSTEST 1/3] standalone: Add get-job-status
> to pick status out of standalone.db"):
> > 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.
> 
> Maybe this would be better as a cs-* utility, useable on production
> instances too ?

Could do, although actually it turns out that the functionality in patch #2
(i.e. having standalone check the error) was the thing which I really
needed for what I was doing (scripting a loop running the job over and over
till it failed).

If cs-job-status still seems useful then I can certainly add that. I'd
probably keep the convenience wrapper in standalone unless you object.

Ian.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH OSSTEST 1/3] standalone: Add get-job-status to pick status out of standalone.db
  2015-09-29 14:20     ` Ian Campbell
@ 2015-09-29 15:02       ` Ian Jackson
  0 siblings, 0 replies; 9+ messages in thread
From: Ian Jackson @ 2015-09-29 15:02 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("Re: [PATCH OSSTEST 1/3] standalone: Add get-job-status to pick status out of standalone.db"):
> If cs-job-status still seems useful then I can certainly add that. I'd
> probably keep the convenience wrapper in standalone unless you object.

Right.  Yes, I think cs-job-status would be useful.  It could perhaps
be a sub-op in cs-adjust-flight.

Ian.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-09-29 15:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-29  9:37 [PATCH OSSTEST 0/3] Misc standalone wrapper improvements Ian Campbell
2015-09-29  9:37 ` [PATCH OSSTEST 1/3] standalone: Add get-job-status to pick status out of standalone.db Ian Campbell
2015-09-29 14:04   ` Ian Jackson
2015-09-29 14:20     ` Ian Campbell
2015-09-29 15:02       ` Ian Jackson
2015-09-29  9:37 ` [PATCH OSSTEST 2/3] standalone: Check job status at end of run-job Ian Campbell
2015-09-29 14:04   ` Ian Jackson
2015-09-29  9:37 ` [PATCH OSSTEST 3/3] standalone: Rotate logs rather than clobbering them Ian Campbell
2015-09-29 14:04   ` Ian Jackson

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).