standalone: refactor out some useful bits of standalone-reset
PATCH 1/2 standalone: refactor out some useful bits of standalone-reset
I sometimes want just these bits.
I went with a new "sa" prefix, but I left standalone-reset alone since it is already reasonably well known.
--- README | 3 +++ sa-forget-flight | 39 +++++++++++++++++++++++++++++++++++++++ sa-init-db | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ standalone-reset | 30 ++---------------------------- 4 files changed, 100 insertions(+), 28 deletions(-) create mode 100755 sa-forget-flight create mode 100755 sa-init-db
README +3 -0
@@ -158,6 +158,9 @@ sg-*: ? ts-*: Test Step scripts. +sa-*: Standalone mode. + + Jobs ====
sa-forget-flight new file +39 -0
@@ -0,0 +1,39 @@ +#!/bin/bash + +# This is part of "osstest", an automated testing framework for Xen. +# Copyright (C) 2014 Citrix Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +set -e + +usage(){ + cat <<END +usage: ./sa-forget-flight [database] [flight] +END +} + +if [ $# -ne 2 ] ; then + usage >&2 + exit 1 +fi + +db="$1" +flight="$1" + +sqlite3 "$db" <<END + DELETE FROM runvars WHERE flight='$flight'; + DELETE FROM jobs WHERE flight='$flight'; + DELETE FROM flights WHERE flight='$flight'; +END
sa-init-db new file +56 -0
56 lines not on this page · raw message
standalone-reset +2 -28
@@ -131,35 +131,9 @@ case $# in esac if test -f standalone.db; then - sqlite3 standalone.db <<END - DELETE FROM runvars WHERE flight='$flight'; - DELETE FROM jobs WHERE flight='$flight'; - DELETE FROM flights WHERE flight='$flight'; -END + ./sa-forget-flight standalone.db "$flight" else - sqlite3 standalone.db <<END - CREATE TABLE flights ( - flight TEXT PRIMARY KEY, - blessing TEXT, - intended TEXT, - branch TEXT - ); - CREATE TABLE jobs ( - flight TEXT NOT NULL, - job TEXT NOT NULL, - recipe TEXT NOT NULL, - status TEXT NOT NULL, - PRIMARY KEY(flight,job) - ); - CREATE TABLE runvars ( - flight TEXT NOT NULL, - job TEXT NOT NULL, - name TEXT NOT NULL, - val TEXT NOT NULL, - synth BOOLEAN NOT NULL, - PRIMARY KEY(flight,job,name) - ); -END + ./sa-db-init standalone.db fi : ${BUILD_LVEXTEND_MAX:=50}
Signature · 1 line
1.8.5.2
PATCH 2/2 standalone mode convenience frontend
I can never remember all the various env vars which I can/should set so this tool provides a command line veneer over the basics.
It also does some sanity checks for things which keep tripping me up (inability to read apache logs, lack of ssh-agent) which fail in more or less obscure ways.
--- standalone | 231 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100755 standalone
standalone new file +231 -0
@@ -0,0 +1,231 @@ +#!/bin/bash + +set -e + +usage() { + cat >&2 <<EOF +usage: standalone [operations] [options...] + +Operations: + +* make-flight [cf] [BRANCH] + + Create a flight testing the named branch. + +* set-paths [cf] [JOB] + + Setup dist path runvars for JOB from existing build results. Useful + after recreating a flight to avoid the need to rebuild. + +* run-job [cfhrR] [JOB] + + Run the named JOB. + + Required options: -h HOST + +* run-test [cfhrR] [JOB] [TEST] + + Run the named TEST as part of JOB. + + Required options: -h HOST + +Options: + +-c FILE, --config=FILE Use FILE as configuration file +-f FLIGHT, --flight=FLIGHT Operate on FLIGHT +-h HOST, --host=HOST Test host +-r, --reuse Do not wipe test host (default) +-R, --noreuse, --noreinstall Wipe the test host (if job or test does so) + +--help This message + +EOF +} + +if [ $# -lt 1 ] ; then + echo "Need an operation" >&2 + usage + exit 1 +fi + +op=$1 ; shift + +if [ x$op = x--help ] ; then + usage + exit 0 +fi + +TEMP=$(getopt -o c:f:h:rR --long config:,flight:,host:,reuse,noreuse,reinstall,help -- "$@") + +eval set -- "$TEMP" + +config= +flight="standalone" +host= +reuse=1 # Don't blow away machines by default + +while true ; do + case "$1" in + -c|--config) config=$2; shift 2;; + -f|--flight) flight=$2; shift 2;; + -h|--host) host=$2; shift 2;; + -r|--reuse) reuse=1; shift 1;; + -R|--noreuse|--reinstall)reuse=0;shift 1;; + --help) usage; exit 0;; + --) shift ; break ;; + *) echo "Internal error!" ; exit 1 ;; + + esac +done + +if [ ! -r /var/log/apache2/access.log ] ; then + echo "WARNING: Cannot read apache logs. Some tests may fail" >&2 +fi + +if ! ssh-add -l >/dev/null ] ; then + echo "WARNING: Unable to access ssh-agent. Some tests may fail" >&2 +fi + +if [ $reuse -eq 0 ]; then + echo "WARNING: Will blow away machine..." + echo "Press ENTER to confirm." + read +fi + +if [ ! -f standalone.db ] ; then + echo "No standalone.db? Run standalone-reset." >&2 + exit 1 +fi + +need_flight() { + if [ -z "$flight" ] ; then + echo "run-job: Need a flight" >&2 + exit 1 + fi +} +need_host() { + if [ -z "$host" ] ; then + echo "run-job: Need a host" >&2 + exit 1 + fi +} + +ensure_logs() { + if [ ! -d "logs" ] ; then + mkdir "logs" + fi + if [ ! -d "logs/$flight" ] ; then + mkdir "logs/$flight" + fi +} + +# other potential ops: +# - run standalone reset + +case $op in + help) + usage + exit 0 + ;; + + make-flight) + need_flight + + if [ $# -lt 1 ] ; then + echo "make-flight: Need branch" >&2 + exit 1 + fi + + branch=$1; shift + + env DAILY_BRANCH_PREEXEC_HOOK=exit\ 0 \ + OSSTEST_USE_HEAD=y \ + BRANCHES_ALWAYS="$branch" \ + OSSTEST_FLIGHT=$flight \ + OSSTEST_CONFIG=$config \ + OSSTEST_NO_BASELINE=y \ + ./cr-daily-branch $@ $branch + ;; + + set-paths) + need_flight + + if [ $# -lt 1 ] ; then + echo "set-paths: Need job" >&2 + exit 1 + fi + +#build-amd64 path_dist build/dist.tar.gz +#build-amd64 path_kerndist build/kerndist.tar.gz +#build-amd64-pvops path_kerndist build/kerndist.tar.gz +#build-amd64 path_xendist build/xendist.tar.gz + + job=$1; shift + + for d in '' xen kern ; do + runvar="path_${d}dist" + path="build/${d}dist.tar.gz" + if [ -f "logs/$flight/$job/$path" ] ; then + ./cs-adjust-flight -v $flight runvar-set $job $runvar $path + fi + done + + if [ -f "logs/$flight/$job/build/kerndist.tar.gz" ] ; then + KERNEL_VER=$(tar tzf logs/$flight/$job/build/kerndist.tar.gz |\ + sed -n -e 's,^lib/modules/\(.*\)/modules.dep$,\1,p') + if [ -n "$KERNEL_VER" ]; then + ./cs-adjust-flight -v $flight \ + runvar-set $job kernel_ver $KERNEL_VER + fi + fi + ;; + + run-job) + need_flight; need_host + + if [ $# -lt 1 ] ; then + echo "run-job: Need job" >&2 + exit 1 + fi + + job=$1; shift + + ensure_logs + + env OSSTEST_CONFIG=$config \ + OSSTEST_FLIGHT=$flight \ + OSSTEST_HOST_HOST=$host \ + OSSTEST_HOST_REUSE=$reuse \ + ./sg-run-job $job 2>&1 | tee logs/$flight/$job.log + rc=${PIPESTATUS[0]} + if [ $rc -ne 0 ] ; then + echo "FAILED rc=${rc}" >&2 + fi + ;; + run-test) + need_flight; need_host + + if [ $# -lt 2 ] ; then + echo "run-test: Need job + test" >&2 + exit 1 + fi + + job=$1; shift + ts=$1; shift + + ensure_logs + + env OSSTEST_CONFIG=$config \ + OSSTEST_FLIGHT=$flight \ + OSSTEST_CONFIG=$config \ + OSSTEST_HOST_REUSE=$reuse \ + OSSTEST_JOB=$job \ + ./$ts host=$host $@ 2>&1 | tee logs/$flight/$job.$ts.log + rc=${PIPESTATUS[0]} + if [ $rc -ne 0 ] ; then + echo "FAILED rc=${rc}" >&2 + fi + ;; + *) + echo "Unknown op $op" ; exit 1 ;; +esac
Signature · 1 line
1.8.5.2
Re: [PATCH OSSTEST 2/2] standalone mode convenience frontend
Ian Campbell writes ("[PATCH OSSTEST 2/2] standalone mode convenience frontend"):
Quoted 6 lines
I can never remember all the various env vars which I can/should set so this tool provides a command line veneer over the basics.
It also does some sanity checks for things which keep tripping me up (inability to read apache logs, lack of ssh-agent) which fail in more or less obscure ways.
This seems useful. I have only a couple of trivial style comments.
standalone line 147
Quoted 7 lines
standalone new file +7
-0+ env DAILY_BRANCH_PREEXEC_HOOK=exit\ 0 \ + OSSTEST_USE_HEAD=y \ + BRANCHES_ALWAYS="$branch" \ + OSSTEST_FLIGHT=$flight \ + OSSTEST_CONFIG=$config \ + OSSTEST_NO_BASELINE=y \ + ./cr-daily-branch $@ $branch
The use of "env" here is unnecessary.
...
standalone line 203
Quoted 5 lines
standalone new file +5
-0+ ./sg-run-job $job 2>&1 | tee logs/$flight/$job.log + rc=${PIPESTATUS[0]} + if [ $rc -ne 0 ] ; then + echo "FAILED rc=${rc}" >&2 + fi
These 4.5 lines occur twice in this file. Perhaps another subroutine to handle the logging ?
Thanks,
Ian.
Re: [PATCH OSSTEST 2/2] standalone mode convenience frontend
Quoted 19 lines · Ian Jackson
Ian Campbell writes ("[PATCH OSSTEST 2/2] standalone mode convenience frontend"):
Quoted 6 lines
I can never remember all the various env vars which I can/should set so this tool provides a command line veneer over the basics.
It also does some sanity checks for things which keep tripping me up (inability to read apache logs, lack of ssh-agent) which fail in more or less obscure ways.
This seems useful. I have only a couple of trivial style comments.
standalone line 147
Quoted 7 lines
standalone new file +7
-0+ env DAILY_BRANCH_PREEXEC_HOOK=exit\ 0 \ + OSSTEST_USE_HEAD=y \ + BRANCHES_ALWAYS="$branch" \ + OSSTEST_FLIGHT=$flight \ + OSSTEST_CONFIG=$config \ + OSSTEST_NO_BASELINE=y \ + ./cr-daily-branch $@ $branch
Quoted 1 line
The use of "env" here is unnecessary.
Yes, I wonder what was happening to cause me to think I needed it...
Quoted 9 lines
...
standalone line 203
Quoted 5 lines
standalone new file +5
-0+ ./sg-run-job $job 2>&1 | tee logs/$flight/$job.log + rc=${PIPESTATUS[0]} + if [ $rc -ne 0 ] ; then + echo "FAILED rc=${rc}" >&2 + fiThese 4.5 lines occur twice in this file. Perhaps another subroutine to handle the logging ?
Sure. Unless the subroutine call is going to muck with ${PIPSTATUS[0]} somehow -- I need to check that.
Ian.
Re: [PATCH OSSTEST 2/2] standalone mode convenience frontend
Ian Campbell writes ("Re: [PATCH OSSTEST 2/2] standalone mode convenience frontend"):
Quoted 10 lines · Ian Jackson
Quoted 8 lines
standalone line 203
Quoted 5 lines
standalone new file +5
-0+ ./sg-run-job $job 2>&1 | tee logs/$flight/$job.log + rc=${PIPESTATUS[0]} + if [ $rc -ne 0 ] ; then + echo "FAILED rc=${rc}" >&2 + fiThese 4.5 lines occur twice in this file. Perhaps another subroutine to handle the logging ?
Quoted 2 lines
Sure. Unless the subroutine call is going to muck with ${PIPSTATUS[0]} somehow -- I need to check that.
I was thinking of a subroutine you'd use like this:
BLAH1=1 BLAH2=2 BLAH3=3 with-logging ./sg-run-job $job
Ian.
Re: [PATCH OSSTEST 2/2] standalone mode convenience frontend
Ian Jackson writes ("Re: [PATCH OSSTEST 2/2] standalone mode convenience frontend"):
Quoted 7 lines
Ian Campbell writes ("Re: [PATCH OSSTEST 2/2] standalone mode convenience frontend"):
Quoted 2 lines
Sure. Unless the subroutine call is going to muck with ${PIPSTATUS[0]} somehow -- I need to check that.
I was thinking of a subroutine you'd use like this:
BLAH1=1 BLAH2=2 BLAH3=3 with-logging ./sg-run-job $job
Or rather
BLAH1=1 BLAH2=2 BLAH3=3 with-logging logs/$flight/$job.log ./sg-run-job $job
or some such.
Ian.
Re: [PATCH OSSTEST 2/2] standalone mode convenience frontend
Quoted 7 lines · Ian Jackson
Ian Jackson writes ("Re: [PATCH OSSTEST 2/2] standalone mode convenience frontend"):
Quoted 6 lines
Ian Campbell writes ("Re: [PATCH OSSTEST 2/2] standalone mode convenience frontend"):
Quoted 2 lines
Sure. Unless the subroutine call is going to muck with ${PIPSTATUS[0]} somehow -- I need to check that.
I was thinking of a subroutine you'd use like this:
Quoted 7 lines
Quoted 1 line
BLAH1=1 BLAH2=2 BLAH3=3 with-logging ./sg-run-job $jobOr rather
BLAH1=1 BLAH2=2 BLAH3=3 with-logging logs/$flight/$job.log ./sg-run-job $jobor some such.
Right, I'd have probably got that once I came to actually type it in...
Ian.
Re: [PATCH OSSTEST 2/2] standalone mode convenience frontend
In reply to Ian JacksonQuoted 11 lines · Ian Jackson
Ian Campbell writes ("Re: [PATCH OSSTEST 2/2] standalone mode convenience frontend"):
Quoted 10 lines · Ian Jackson
Quoted 8 lines
standalone line 203
Quoted 5 lines
standalone new file +5
-0+ ./sg-run-job $job 2>&1 | tee logs/$flight/$job.log + rc=${PIPESTATUS[0]} + if [ $rc -ne 0 ] ; then + echo "FAILED rc=${rc}" >&2 + fiThese 4.5 lines occur twice in this file. Perhaps another subroutine to handle the logging ?
Quoted 6 lines
Quoted 2 lines
Sure. Unless the subroutine call is going to muck with ${PIPSTATUS[0]} somehow -- I need to check that.
I was thinking of a subroutine you'd use like this:
BLAH1=1 BLAH2=2 BLAH3=3 with-logging ./sg-run-job $job
Ah, yes, that does look good. I'll do that.
Ian.
Ian Campbell writes ("[PATCH OSSTEST 1/2] standalone: refactor out some useful bits of standalone-reset"):
Quoted 1 line
I sometimes want just these bits.
...
Quoted 5 lines
sa-forget-flight new file +0
-0
...
Quoted 1 line
+usage: ./sa-forget-flight [database] [flight]
ITYM "<database> <flight>". They're not optional AFAICT.
Ian.
Quoted 9 lines · Ian Jackson
Ian Campbell writes ("[PATCH OSSTEST 1/2] standalone: refactor out some useful bits of standalone-reset"):
Quoted 1 line
I sometimes want just these bits.
...
Quoted 5 lines
sa-forget-flight new file +0
-0...
Quoted 3 lines
Quoted 1 line
+usage: ./sa-forget-flight [database] [flight]
ITYM "<database> <flight>". They're not optional AFAICT.
YIDM "<database> <flight>".
Also you didn't spot the deliberate mistake:
db="$1"
flight="$1";-)
(this is in my "ui" branch so I'm not routinely actually using it yet...)
Ian.