Disable blocking on buildable queue (Functest)
[releng.git] / jjb / apex / apex-iso-verify.sh
1 #!/bin/bash
2 set -o errexit
3 set -o nounset
4 set -o pipefail
5
6 # log info to console
7 echo "Starting the Apex iso verify."
8 echo "--------------------------------------------------------"
9 echo
10
11 if [ "$BRANCH" != 'stable/fraser' ]; then
12   echo "Skipping Apex iso verify for ${BRANCH} branch"
13   exit 0
14 fi
15
16 # Must be RPMs/ISO
17 echo "Downloading latest properties file"
18
19 # get the properties file in order to get info regarding artifacts
20 curl --fail -s -o opnfv.properties http://$GS_URL/latest.properties
21
22 # source the file so we get OPNFV vars
23 source opnfv.properties
24
25 if ! rpm -q virt-install > /dev/null; then
26   sudo yum -y install virt-install
27 fi
28
29 # define a clean function
30 rm_apex_iso_verify () {
31 if sudo virsh list --all | grep apex-iso-verify | grep running; then
32     sudo virsh destroy apex-iso-verify
33 fi
34 if sudo virsh list --all | grep apex-iso-verify; then
35     sudo virsh undefine apex-iso-verify
36 fi
37 }
38
39 # Make sure a pre-existing iso-verify isn't there
40 rm_apex_iso_verify
41
42 #make sure there is not an existing console log file for the VM
43 sudo rm -f /var/log/libvirt/qemu/apex-iso-verify-console.log
44
45 # run an install from the iso
46 # This streams a serial console to tcp port 3737 on localhost
47 sudo virt-install -n apex-iso-verify -r 4096 --vcpus 4 --os-variant=rhel7 \
48  --accelerate -v --noautoconsole \
49  --disk path=/var/lib/libvirt/images/apex-iso-verify.qcow2,size=30,format=qcow2 \
50  -l /tmp/apex-iso/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso \
51  --extra-args 'console=ttyS0 console=ttyS0,115200n8 serial inst.ks=file:/iso-verify.ks inst.stage2=hd:LABEL=OPNFV\x20CentOS\x207\x20x86_64:/' \
52  --initrd-inject ci/iso-verify.ks \
53  --serial file,path=/var/log/libvirt/qemu/apex-iso-verify-console.log
54
55 echo "Waiting for install to finish..."
56 sleep 10
57 end_time=$(($SECONDS+1500))
58 while ! [[ `sudo tail -n1 /var/log/libvirt/qemu/apex-iso-verify-console.log` =~ 'Power down' ]]; do
59   if [ $SECONDS -gt $end_time ] || ! sudo virsh list --all | grep apex-iso-verify | grep running > /dev/null; then
60     sudo cat /var/log/libvirt/qemu/apex-iso-verify-console.log
61     sudo virsh list --all
62     echo "Error: Failed to find power down message after install"
63     exit 1
64   fi
65   sleep 10
66 done
67
68 sudo cat /var/log/libvirt/qemu/apex-iso-verify-console.log
69
70 # clean up
71 rm_apex_iso_verify
72
73 echo
74 echo "--------------------------------------------------------"
75 echo "Done!"