Skip to contentSkip to conversation

selecthost: Default pdu to "unsupported" rather than nothing

PATCH New Ian Jackson 1 participant 8 messages Apr 10, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/8 selecthost: Default pdu to "unsupported" rather than nothing

---
 Osstest/TestSupport.pm |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Osstest/TestSupport.pm +1 -1
index 4ced6c0..a498ddd 100644
@@ -814,7 +814,7 @@ sub serial_fetch_logs ($) {
 sub power_cycle_host_setup ($) {
     my ($ho) = @_;
     my $methobjs = [ ];
-    foreach my $meth (split /\;\s*/, $ho->{Power}) {
+    foreach my $meth (split /\;\s*/, ($ho->{Power} // 'unsupported')) {
 	push @$methobjs, get_host_method_object($ho,'PDU',$meth);
     }
     $ho->{PowerMethobjs} = $methobjs;
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

PATCH 2/8 selecthost: Honour IDENT_hostflagadjust runvar

This allows runvars to override hostflags from the resource database or configuration.

---
 Osstest/TestSupport.pm |    8 ++++++++
 1 file changed, 8 insertions(+)
Osstest/TestSupport.pm +8 -0
index a498ddd..88b0a65 100644
@@ -966,6 +966,14 @@ sub selecthost ($) {
 
     $ho->{Flags} = $mhostdb->get_flags($ho);
 
+    foreach my $adj (split /,/, ($r{"${ident}_hostflagadjust"} // '')) {
+	if ($adj =~ s/^!//) {
+	    delete $ho->{Flags}{$adj};
+	} else {
+	    $ho->{Flags}{$adj} = 1;
+	}
+    }
+
     #----- fqdn -----
 
     my $defaultfqdn = $name;
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

PATCH 3/8 mg-allocate: Redirect a few messages to stderr

In reply to Ian Jackson

These were, anomalously, printed to stdout. We are going to want to reserve stdout for programmatically-useful output.

---
 mg-allocate |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mg-allocate +2 -2
index 7b1eb62..f895af2 100755
@@ -430,8 +430,8 @@ sub plan () {
 	my @reqlist;
 	foreach my $poss (@possmatrix) {
 	    my $tplanned= plan_search
-		($plan, sub { print " @_\n"; }, $duration, $poss);
-	    printf " possibility Start=%d %s\n",
+		($plan, sub { print STDERR " @_\n"; }, $duration, $poss);
+	    printf STDERR " possibility Start=%d %s\n",
 	        $tplanned->{Start}, showposs($poss);
 	    if (!$planned || $tplanned->{Start} < $planned->{Start}) {
 		$planned = $tplanned;
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#3 lore raw

PATCH 4/8 mg-allocate: Provide --stdout-output

In reply to Ian Jackson

This prints RESTYPE/RESNAME/SHAREIX to stdout, after allocation is successful (outside the db retry loop). This means that a programmatic caller can now tell what was allocated, even if the spec was complex.

---
 mg-allocate |    8 ++++++++
 1 file changed, 8 insertions(+)
mg-allocate +8 -0
index f895af2..287823a 100755
@@ -93,6 +93,7 @@ our $donate_spec;
 our $donate_taskid;
 our @steal_specs;
 our %steal_taskids;
+our $stdout_output;
 
 sub alloc_prep () {
     $tid= findtask();
@@ -329,6 +330,7 @@ END
     }
     return ($ok, { Allocate => $allocate,
 		   Shareix => $got_shareix,
+		   Report => "$restype/$resname/$got_shareix",
 		   Info => "$resname ($restype/$resname/$got_shareix)"
 	    });
 }
@@ -352,6 +354,10 @@ sub loggot {
 	  "DEALLOCATED").
 	 ": ".$_->{Info})
 	foreach @got;
+    if ($stdout_output) {
+	print $_->{Report}, "\n" or die $!
+	    foreach @got;
+    }
 }
 
 sub execute (;$) {
@@ -515,6 +521,8 @@ while (@ARGV && $ARGV[0] =~ m/^[-0-9]/) {
 	} elsif (s/^--steal$/-/) {
 	    die "--steal needs task\n" unless @ARGV;
 	    push @steal_specs, shift @ARGV;
+	} elsif (s/^--stdout-output$/-/) {
+	    $stdout_output = 1;
         } else {
             die "bad option \`$_'";
         }
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#4 lore raw

PATCH 5/8 ts-hosts-allocate-Executive: Honour OSSTEST_NOALLOCATE

In reply to Ian Jackson

This allows host allocation to be skipped even though the rest of the job is being run.

---
 ts-hosts-allocate-Executive |    5 +++++
 1 file changed, 5 insertions(+)
ts-hosts-allocate-Executive +5 -0
index 0b83365..9417226 100755
@@ -50,6 +50,11 @@ while (@ARGV and $ARGV[0] =~ m/^-/) {
     }
 }
 
+if ($ENV{'OSSTEST_NOALLOCATE'}) {
+    logm("OSSTEST_NOALLOCATE set, doing nothing.");
+    exit 0;
+}
+
 # initialised by setup:
 our $taskid;
 our %magictaskid;
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#5 lore raw

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

In reply to Ian Jackson

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

---
 mg-repro-setup |  200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 200 insertions(+)
 create mode 100755 mg-repro-setup
mg-repro-setup new file +200 -0
new file mode 100755
index 0000000..c673cb6
@@ -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.*)"
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#6 lore raw

PATCH 7/8 serial logs capture: chomp parameters to the perl script

In reply to Ian Jackson

For reasons that aren't clear, perl's glob operator ignores the \n. We can gloss over that for now, but let's chomp it in case they fix that.

---
 Osstest/Serial/sympathy.pm |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Osstest/Serial/sympathy.pm +2 -2
index 0d09576..84a1e09 100644
@@ -106,8 +106,8 @@ sub fetch_logs {
         use strict qw(refs vars);
         use IO::File;
         $|=1;
-        my $started= <DATA>;  defined $started or die $!;
-        my $logpat= <DATA>;   defined $logpat or die $!;
+        my $started= <DATA>;  chomp $started or die $!;
+        my $logpat= <DATA>;   chomp $logpat or die $!;
 
         my %done;
         for (;;) {
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#7 lore raw

PATCH 8/8 serial logs capture: Detect errors from glob

In reply to Ian Jackson

Empirically, if glob cannot do its work, it sets $! and returns an empty list.

---
 Osstest/Serial/sympathy.pm |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Osstest/Serial/sympathy.pm +4 -1
index 84a1e09..7461e07 100644
@@ -112,7 +112,10 @@ sub fetch_logs {
         my %done;
         for (;;) {
             my $anydone= 0;
-            foreach my $logfile (glob $logpat) {
+            $!=0;
+            my @logfiles = glob $logpat;
+            die "$logpat (@logfiles) $!" if $!;
+            foreach my $logfile (@logfiles) {
                 my $lh= new IO::File $logfile, 'r';
                 if (!defined $lh) {
                     $!==&ENOENT or warn "$logfile $!";
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel