[Ovirt-devel] [PATCH node-image] Fixed how autotest would exit in the middle of a run.
Darryl L. Pierce
dpierce at redhat.com
Wed Apr 15 18:05:43 UTC 2009
The ultimate cause was "virsh ttyconsole" setting the return code to 1
regardless of whether it ran successfully or not. So, for the time
being, fail-on-error has been disabled in autotest.
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
autotest.sh | 29 ++++++++++++++---------------
1 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/autotest.sh b/autotest.sh
index 0dbe934..6cba9fa 100755
--- a/autotest.sh
+++ b/autotest.sh
@@ -45,14 +45,15 @@ warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
die() { warn "$*"; exit 1; }
# trap '__st=$?; stop_log; exit $__st' 0
-trap '__st=$?; cleanup; exit $__st' 0
-trap 'cleanup; exit $?' 1 2 13 15
+trap '__st=$?; log "Exiting normally."; cleanup; exit $__st' 0
+trap '__st=$?; log "Dying a horrible death."; cleanup; exit $__st' 1 2 13 15
test -n "$1" && RESULTS=$1 || RESULTS=autotest.log
echo "Running oVirt node image Autotest"
-set -e
+# BZ#495954 needs to be fixed to uncomment this
+# set -e
# set -v
OVIRT_NODE_IMAGE_ISO=$PWD/ovirt-node-image.iso
@@ -68,7 +69,7 @@ log () {
}
cleanup () {
- destroy_node
+ log "CLEANING UP"
stop_dnsmasq
destroy_test_iface
}
@@ -173,8 +174,6 @@ define_node () {
# now define the vm
sudo virsh define $filename
- NODENAME=$nodename
- log "Defined VM: name=${NODENAME}"
if [ $? != 0 ]; then die "Unable to define virtual machine: $nodename"; fi
}
@@ -210,10 +209,6 @@ start_node () {
destroy_node () {
local nodename=$1
- if [ -z "${nodename}" ]; then
- nodename=$NODENAME
- fi
-
if [ -n "${nodename}" ]; then
log "Destroying VM: ${nodename}"
check=$(sudo virsh list --all)
@@ -279,7 +274,7 @@ pxeboot_node_vm () {
create_test_iface $bridge
define_node $xmlfile $nodename $memsize "$diskfile" "" $bridge "local bootdev='network'; local noapic='yes'"
get_mac_address $nodename "node_mac_address"
- start_dnsmasq $bridge $tftproot $node_mac_address
+ start_dnsmasq $bridge $tftproot $node_mac_address $nodename
start_node $nodename
if [ -n "$verify_method" ]; then
eval $verify_method
@@ -294,7 +289,7 @@ pxeboot_node_vm () {
log "Test ended in failure"
fi
- test $return_code == 0 && return 0 || exit 1
+ test $return_code == 0 && return 0 || return 1
}
# Launches the node as a virtual machine with a CDROM.
@@ -389,10 +384,12 @@ destroy_test_iface () {
# $1 - the iface on which dnsmasq works
# $2 - the root for tftp files
# $3 - the mac address for the node (ignored if blank)
+# $4 - the nodename
start_dnsmasq () {
local iface=$1
local tftproot=$2
local macaddress=$3
+ local nodename=$4
local pidfile=$2/dnsmasq.pid
stop_dnsmasq
@@ -405,6 +402,7 @@ start_dnsmasq () {
--dhcp-boot=tftpboot/pxelinux.0
--enable-tftp
--tftp-root=${tftproot}
+ --log-facility=/tmp/dnsmasq-${nodename}.log
--log-queries
--log-dhcp
--pid-file=${pidfile}"
@@ -414,10 +412,12 @@ start_dnsmasq () {
# start dnsmasq
eval $dns_startup
DNSMASQ_PID=$(sudo cat $pidfile)
+ log "dnsmasq start: PID=${DNSMASQ_PID}"
}
# Kills the running instance of dnsmasq.
stop_dnsmasq () {
+ log "Killing dnsmasq: DNSMASQ_PID=${DNSMASQ_PID}"
if [ -n "$DNSMASQ_PID" -a "$DNSMASQ_PID" != "0" ]; then
local check=$(ps -ef | awk "/${DNSMASQ_PID}/"' { if ($2 ~ '"${DNSMASQ_PID}"') print $2 }')
@@ -455,7 +455,7 @@ verify_pxeboot_stateless_standalone () {
local port=$(sudo virsh ttyconsole $nodename)
local logfile=$2
- log "Verifying the node is booted correctly"
+ log "Verifying ${nodename} is booted correctly"
local script='
log_file -noappend '"${logfile}"'
set timeout 60
@@ -507,7 +507,7 @@ verify_pxeboot_stateful_standalone () {
# leverage the existing stateless test
verify_pxeboot_stateless_standalone $nodename
- log "Verifying the node is booted correctly"
+ log "Verifying ${nodename} is booted correctly"
local script='
log_file -noappend '"${logfile}"'
set timeout 180
@@ -554,7 +554,6 @@ test_cdrom_stateless_standalone () {
# automated testing entry points
{
IFACE_NAME=testbr$$
- NODENAME=
NETWORK=192.168.$(echo "scale=0; print $$ % 255" | bc -l)
NODE_ADDRESS=$NETWORK.100
DNSMASQ_PID=0
--
1.6.0.6
More information about the ovirt-devel
mailing list