standalone: Extend -h to support ident=host style specifications
PATCH 1/1 standalone: Extend -h to support ident=host style specifications
Allowing for multi-host tests.
Also make reset-host reset all hosts.
--- standalone | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-)
standalone +36 -11
@@ -31,15 +31,17 @@ Operations: * reset-host [cf] [JOB] - Allow a job which has been run before to run on a different host - next time. Otherwise osstest will complain if you change the host - which a job is running on on successive runs. + Allow a job which has been run before to run on a different host or + hosts next time. Otherwise osstest will complain if you change the + host(s) which a job is running on on successive runs. Options: -c FILE, --config=FILE Use FILE as configuration file -f FLIGHT, --flight=FLIGHT Operate on FLIGHT --h HOST, --host=HOST Test host +-h HOST, --host=HOST Test host, HOST can also be ident=HOST can + be given multiple times, not that the + order matters in some cases (e.g run-test) -r, --reuse Do not wipe test host (default) -R, --noreuse, --reinstall Wipe the test host (if job or test does so) -s, --simulate, --dry-run Dry run, printing what would be run
@@ -76,17 +78,39 @@ else config=$HOME/.xen-osstest/config fi flight="standalone" -host= +hosts= reuse=1 # Don't blow away machines by default dryrun=0 lvextendmax=50 # Leave some LVM space free for running tests nobaseline=y +add_host() { + local h=$1 + case $h in + *=*) + local ident=${h/=*} + h=${h/*=} + hosts="$ident=$h $hosts" + ;; + *) + hosts="host=$h $hosts" + ;; + esac +} + +export_hosts_environ() { + for h in $hosts ; do + local ident=${h/=*} + h=${h/*=} + eval export OSSTEST_HOST_${ident^^}=$h + done +} + while true ; do case "$1" in -c|--config) config=$2; shift 2;; -f|--flight) flight=$2; shift 2;; - -h|--host) host=$2; shift 2;; + -h|--host) add_host $2; shift 2;; -r|--reuse) reuse=1; shift 1;; -R|--noreuse|--reinstall)reuse=0;shift 1;; -s|--simulate|--dry-run)dryrun=1;shift 1;;
@@ -111,7 +135,7 @@ if ! ssh-add -l >/dev/null ] ; then fi if [ $reuse -eq 0 ]; then - echo "WARNING: Will blow away machine..." + echo "WARNING: Will blow away machine(s)..." echo "Press ENTER to confirm." read fi
@@ -142,7 +166,7 @@ need_flight() { fi } need_host() { - if [ -z "$host" ] ; then + if [ "x$hosts" = x ] ; then echo "run-job: Need a host" >&2 exit 1 fi
@@ -240,7 +264,7 @@ case $op in fi job=$1; shift - ./cs-adjust-flight -v $flight runvar-del $job host + ./cs-adjust-flight -v $flight runvar-del $job '/host$' ;; run-job)
@@ -253,9 +277,10 @@ case $op in job=$1; shift + export_hosts_environ + OSSTEST_CONFIG=$config \ OSSTEST_FLIGHT=$flight \ - OSSTEST_HOST_HOST=$host \ OSSTEST_HOST_REUSE=$reuse \ OSSTEST_SIMULATE=$dryrun \ with_logging logs/$flight/$job.log ./sg-run-job $job
@@ -275,7 +300,7 @@ case $op in OSSTEST_FLIGHT=$flight \ OSSTEST_HOST_REUSE=$reuse \ OSSTEST_JOB=$job \ - with_logging logs/$flight/$job.$ts.log ./$ts host=$host $@ + with_logging logs/$flight/$job.$ts.log ./$ts $hosts $@ ;; *) echo "Unknown op $op" ; exit 1 ;;
Signature · 1 line
2.1.4
Ian Campbell writes ("[PATCH OSSTEST] standalone: Extend -h to support ident=host style specifications"):
Quoted 1 line
Allowing for multi-host tests.
...
standalone case $op in · line 267
Quoted 3 lines
standalone +1
-1job=$1; shift - ./cs-adjust-flight -v $flight runvar-del $job host + ./cs-adjust-flight -v $flight runvar-del $job '/host$'
This regexp is slightly wrong because host runvars are all
(?:\w+_)?host$
standalone else · line 93
Quoted 1 line
standalone +1
-0+ hosts="$ident=$h $hosts"
Any reason you push it on the front rather than adding it to the end ? It _shouldn't_ matter, but what if someone specifies -h foo=X -h foo=Y ?
Ian.
Quoted 10 lines · Ian Jackson
Ian Campbell writes ("[PATCH OSSTEST] standalone: Extend -h to support ident=host style specifications"):
Quoted 1 line
Allowing for multi-host tests.
...
standalone case $op in · line 267
Quoted 3 lines
standalone +1
-1job=$1; shift - ./cs-adjust-flight -v $flight runvar-del $job host + ./cs-adjust-flight -v $flight runvar-del $job '/host$'This regexp is slightly wrong because host runvars are all
(?:\w+_)?host$
I'll update.
Quoted 3 lines
standalone else · line 93
Quoted 1 line
standalone +1
-0+ hosts="$ident=$h $hosts"Any reason you push it on the front rather than adding it to the end ?
So that it matches the order of the arguments. Which matters for the run -test case. At least it did for ts-guest-nbd-mirror which wants to be given $srvhost $clthost in that order.
Quoted 1 line
It _shouldn't_ matter, but what if someone specifies -h foo=X -h foo=Y ?
For run-test ts-* will get foo=X foo=Y on the command line. For run-job OSSTEST_HOST_FOO=X will prevail.
Perhaps export_hosts_environ should process the list in $hosts in reverse? I think that gets best of both worlds?
Ian.