[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 6/8] mg-repro-setup: New script for setting up repros automatically



Given a previously failed job, this will:
 * Create a flight for the repro attempt
 * (Optionally) allocate a host to the user's personal task
 * (Optionally) wipe the host
 * Install the version of Xen and Linux used by that flight
 * Run the job until the specified step finishes
 * Email the user

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 mg-repro-setup |  200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 200 insertions(+)
 create mode 100755 mg-repro-setup

diff --git a/mg-repro-setup b/mg-repro-setup
new file mode 100755
index 0000000..c673cb6
--- /dev/null
+++ b/mg-repro-setup
@@ -0,0 +1,200 @@
+#!/bin/bash
+
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2017 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/>.
+
+
+usage () { cat <<END
+
+./mg-repro-setup [OPTION...] EXAMPLE-FLIGHT JOB TESTID [HOSTSPEC...]
+
+ Creates a new flight containg a copy of JOB from EXAMPLE-FLIGHT
+ adjusted to use the same builds as JOB (ie, no rebuilds),
+ and runs it until TESTID has completed.
+
+ HOSTSPEC is
+   [host=][reuse:]<hostname>       host must be allocated, skip host-install
+   [host=]wipe:<hostname>          host must be allocated, wipe it
+   [host=]alloc:<resource-spec>    mg-allocate and wipe
+   none:                           no hosts (should be only HOSTPSEC)
+
+ OPTIONs
+   -t<duration>         estimated duration (default = 28d)
+   --rogue              bypass queuing system and allocate now
+   -r<var>=<value>      set runvar
+   -r!<var>             delete runvar
+   -B<blessing>                default is 'play'
+   -E... -f... -P       as for mg-execute-fligght
+
+END
+
+}
+
+badusage () { echo >&2 "bad usage"; usage >&2; exit 126; }
+
+set -e -o posix
+
+mgexecflags=()
+adjustsets=()
+adjusts=()
+allocs=()
+logfile=tmp/mg-repro-setup.log
+duration=28d
+blessing=play
+
+while true; do
+       case "$1" in
+       -*)                     ;;
+       *)              break   ;;
+       esac
+       arg=$1; shift
+        case "$arg" in
+        -[E]?*|-P)     mgexecflags+=("$arg")           ;;
+        -B?*)          blessing=${arg#-B}              ;;
+        -f?*)          refflight=${arg#-f}             ;;
+       -t?*)           duration=${arg#-t}              ;;
+       --rogue)        duration=''                     ;;
+       -l*)            logfile=${arg#-l}               ;;
+       -r!*)           adjustsets+=("${arg#-r}")       ;;
+       -r*=*)          adjustsets+=("${arg#-r}")       ;;
+       --)             break                           ;;
+       *)              badusage                        ;;
+       esac
+done
+
+case $# in
+0|1|2|3)       badusage        ;;
+esac
+
+example_flight=$1      ; shift
+job=$1                 ; shift
+testid=$1              ; shift
+
+: ${refflight:=$example_flight}
+
+delrunvar () {
+       adjusts+=(runvar-del "$job" "$1")
+}
+adjrunvar () {
+       delrunvar "$1"
+       adjusts+=(runvar-set "$job" "$1" "$2")
+}
+
+for arg in "${adjustsets[@]}"; do
+       case "$arg" in
+       !*)     delrunvar "${arg#!}"                    ;;
+       *=*)    adjrunvar "${arg%%=*}" "{$arg#*=}"      ;;
+       *)      bad-adjuistset-pattern                  ;;
+       esac
+done
+
+while [ $# -ne 0 ]; do
+       arg=$1; shift
+
+       case "$arg" in
+       none:)
+               # provided so we can repro a job with no hosts
+               ;;
+       *:*)    # [IDENT=]MODE:SPEC
+               identmode=${arg%%:*}
+               spec=${arg#*:}
+               ;;
+       *=*)    # IDENT=SPEC
+               identmode=${arg%%=*}=reuse
+               spec=${arg#*=}
+               ;;
+       *)      # SPEC
+               identmode=reuse
+               spec=$arg
+               ;;
+       esac
+       case "$identmode" in # [IDENT=]MODE
+       *=*)    # IDENT=MODE
+               ident=${identmode%%=*}
+               mode=${identmode#*=}
+               ;;
+       *)
+               ident=host
+               mode=$identmode
+               ;;
+       esac
+
+       case "$mode" in
+       wipe|alloc)     ;;
+       *)              adjrunvar ${ident}_hostflagadjust no-reinstall ;;
+       esac
+
+       case "$mode" in
+       alloc)          alloc_specs+=("$spec")
+                       alloc_idents+=($ident)
+                       ;;
+       *)              adjrunvar $ident $spec
+                       ;;
+       esac
+done
+
+progressf () { printf >&2 "$@"; }
+progress () { progressf "%s\n" "$1"; }
+
+progress "logging to $logfile"
+savelog "$logfile"
+exec 3>"$logfile"
+
+OSSTEST_TASK=$(perl -e '
+       use Osstest;
+       use Osstest::Executive;
+       csreadconfig();
+       findtask();
+       printf "%s\n", $ENV{'OSSTEST_TASK'} or die $!;
+')
+export OSSTEST_TASK
+
+flight=$(./cs-adjust-flight new:$blessing)
+progress "new flight is $flight"
+
+if [ "${alloc_idents[*]}" ]; then
+       progress "allocating ${alloc_idents[*]} ..."
+       alloc_output=tmp/$flight.allocations
+       ./mg-allocate --stdout-output >$alloc_output $duration 2>&3 \
+               "${alloc_specs[@]}"
+       exec <$alloc_output
+       progressf "allocated"
+       for ident in ${alloc_idents[*]}; do
+               read host || not-enough-alloc-idents-from-allocate
+               case "$host" in
+               host/*/0)       host=${host#host/}; host=${host%/0}     ;;
+               esac
+               adjrunvar $ident "$host"
+               progressf " %s" "$host"
+       done
+       progressf "\n"
+fi
+
+progress "setting up flight ..."
+
+adjrunvar truncate_testid $testid
+
+./cs-adjust-flight $flight                                             \
+       copy-jobs $example_flight $job                                  \
+       runvar-build-set . '/buildjob$' '^[^\.]+$' $example_flight      \
+       "${adjusts[@]}"
+
+progress "executing ..."
+
+OSSTEST_NOALLOCATE=1 \
+./mg-execute-flight -B$blessing -f$refflight "${mgexecflags[@]}" $flight
+
+progress "complete (see tmp/$flight.*)"
-- 
1.7.10.4


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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.