X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Fapex%2Fapex-iso-verify.sh;h=f34937619ed81a56eca514e34b06368d3048903f;hb=d29c3e495aee81b96f653b6a4b5ee72a9bf33976;hp=900a3eb2ccf21202b4fa03b9a38b2b8871fe9782;hpb=181ab495cc73197aa4bafb25e629a3a257967821;p=releng.git diff --git a/jjb/apex/apex-iso-verify.sh b/jjb/apex/apex-iso-verify.sh index 900a3eb2c..f34937619 100755 --- a/jjb/apex/apex-iso-verify.sh +++ b/jjb/apex/apex-iso-verify.sh @@ -8,7 +8,19 @@ echo "Starting the Apex iso verify." echo "--------------------------------------------------------" echo -source $BUILD_DIRECTORY/../opnfv.properties +if [ "$BRANCH" == 'master' ]; then + echo "Skipping Apex iso verify for master branch" + exit 0 +fi + +# Must be RPMs/ISO +echo "Downloading latest properties file" + +# get the properties file in order to get info regarding artifacts +curl --fail -s -o opnfv.properties http://$GS_URL/latest.properties + +# source the file so we get OPNFV vars +source opnfv.properties if ! rpm -q virt-install > /dev/null; then sudo yum -y install virt-install @@ -27,76 +39,37 @@ fi # Make sure a pre-existing iso-verify isn't there rm_apex_iso_verify +#make sure there is not an existing console log file for the VM +sudo rm -f /var/log/libvirt/qemu/apex-iso-verify-console.log + # run an install from the iso # This streams a serial console to tcp port 3737 on localhost sudo virt-install -n apex-iso-verify -r 4096 --vcpus 4 --os-variant=rhel7 \ - --accelerate -v --noautoconsole --nographics \ + --accelerate -v --noautoconsole \ --disk path=/var/lib/libvirt/images/apex-iso-verify.qcow2,size=30,format=qcow2 \ - -l $BUILD_DIRECTORY/release/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso \ + -l /tmp/apex-iso/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso \ --extra-args 'console=ttyS0 console=ttyS0,115200n8 serial inst.ks=file:/iso-verify.ks inst.stage2=hd:LABEL=OPNFV\x20CentOS\x207\x20x86_64:/' \ - --initrd-inject $BUILD_DIRECTORY/../ci/iso-verify.ks \ - --serial tcp,host=:3737,protocol=raw - -# Attach to tcpport 3737 and echo the output to stdout -# watch for a 5 min time out, a power off message or a tcp disconnect -python << EOP -#!/usr/bin/env python - -import sys -import socket -from time import sleep -from time import time - - -TCP_IP = '127.0.0.1' -TCP_PORT = 3737 -BUFFER_SIZE = 1024 - -try: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.connect((TCP_IP, TCP_PORT)) -except Exception, e: - print "Failed to connect to the iso-verofy vm's serial console" - print "this probably means that the VM failed to start" - raise e - -activity = time() -data = s.recv(BUFFER_SIZE) -last_data = data -while time() - activity < 300: - try: - if data != last_data: - activity = time() - last_data = data - data = s.recv(BUFFER_SIZE) - sys.stdout.write(data) - if 'Powering off' in data: - break - sleep(.5) - except socket.error, e: - # for now assuming that the connection was closed - # which is good, means the vm finished installing - # printing the error output just in case we need to debug - print "VM console connection lost: %s" % msg - break -s.close() - -if time() - activity > 300: - print "failing due to console inactivity" - exit(1) -else: - print "Success!" -EOP - -# save the python return code for after cleanup -python_rc=$? + --initrd-inject ci/iso-verify.ks \ + --serial file,path=/var/log/libvirt/qemu/apex-iso-verify-console.log + +echo "Waiting for install to finish..." +sleep 10 +end_time=$(($SECONDS+1500)) +while ! [[ `sudo tail -n1 /var/log/libvirt/qemu/apex-iso-verify-console.log` =~ 'Power down' ]]; do + if [ $SECONDS -gt $end_time ] || ! sudo virsh list --all | grep apex-iso-verify | grep running > /dev/null; then + sudo cat /var/log/libvirt/qemu/apex-iso-verify-console.log + sudo virsh list --all + echo "Error: Failed to find power down message after install" + exit 1 + fi + sleep 10 +done + +sudo cat /var/log/libvirt/qemu/apex-iso-verify-console.log # clean up rm_apex_iso_verify -# Exit with the RC of the Python job -exit $python_rc - echo echo "--------------------------------------------------------" echo "Done!"