Adding iso verify to Apex builds 45/32645/12
authorDan Radez <dradez@redhat.com>
Fri, 31 Mar 2017 01:34:49 +0000 (21:34 -0400)
committerDan Radez <dradez@redhat.com>
Tue, 18 Apr 2017 17:57:03 +0000 (13:57 -0400)
JIRA: APEX-377

Change-Id: I1e02fc602e8258e76f9447d05b09b17e55d0d25a
Signed-off-by: Dan Radez <dradez@redhat.com>
jjb/apex/apex-iso-verify.sh [new file with mode: 0755]
jjb/apex/apex-upload-artifact.sh
jjb/apex/apex.yml

diff --git a/jjb/apex/apex-iso-verify.sh b/jjb/apex/apex-iso-verify.sh
new file mode 100755 (executable)
index 0000000..d80de35
--- /dev/null
@@ -0,0 +1,100 @@
+#!/bin/bash
+set -o errexit
+set -o nounset
+set -o pipefail
+
+# log info to console
+echo "Starting the Apex iso verify."
+echo "--------------------------------------------------------"
+echo
+
+if ! rpm -q virt-install > /dev/null; then
+  sudo yum -y install virt-install
+fi
+
+# define a clean function
+rm_apex_iso_verify () {
+if sudo virsh list --all | grep apex-iso-verify | grep running; then
+    sudo virsh destroy apex-iso-verify
+fi
+if sudo virsh list --all | grep apex-iso-verify; then
+    sudo virsh undefine apex-iso-verify
+fi
+}
+
+# Make sure a pre-existing iso-verify isn't there
+rm_apex_iso_verify
+
+# 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 \
+ --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 \
+ --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=$?
+
+# clean up
+rm_apex_iso_verify
+
+# Exit with the RC of the Python job
+exit $python_rc
+
+echo
+echo "--------------------------------------------------------"
+echo "Done!"
index c2de7d7..4a2a64d 100755 (executable)
@@ -4,7 +4,7 @@ set -o nounset
 set -o pipefail
 
 # log info to console
-echo "Uploading the Apex artifact. This could take some time..."
+echo "Uploading the Apex $1 artifact. This could take some time..."
 echo "--------------------------------------------------------"
 echo
 
@@ -18,7 +18,7 @@ echo "Cloning releng repository..."
 [ -d releng ] && rm -rf releng
 git clone https://gerrit.opnfv.org/gerrit/releng $WORKSPACE/releng/ &> /dev/null
 #this is where we import the siging key
-if [ -f $WORKSPACE/releng/utils/gpg_import_key.sh ]; then 
+if [ -f $WORKSPACE/releng/utils/gpg_import_key.sh ]; then
   source $WORKSPACE/releng/utils/gpg_import_key.sh
 fi
 
@@ -88,17 +88,21 @@ if echo $WORKSPACE | grep promote > /dev/null; then
   uploadsnap
 elif gpg2 --list-keys | grep "opnfv-helpdesk@rt.linuxfoundation.org"; then
   echo "Signing Key avaliable"
-  signiso
-  uploadiso
-  signrpm
-  uploadrpm
+  if [ $1 == 'iso' ]; then
+    signiso
+    uploadiso
+  fi
+  if [ $1 == 'rpm' ]; then
+    signrpm
+    uploadrpm
+  fi
 else
-  uploadiso
-  uploadrpm
+  if [ $1 == 'iso' ]; then uploadiso; fi
+  if [ $1 == 'rpm' ]; then uploadrpm; fi
 fi
 
 echo
 echo "--------------------------------------------------------"
 echo "Done!"
-echo "ISO Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
-echo "RPM Artifact is available as http://$GS_URL/$(basename $OPNFV_RPM_URL)"
+if [ $1 == 'iso' ]; then echo "ISO Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"; fi
+if [ $1 == 'rpm' ]; then echo "RPM Artifact is available as http://$GS_URL/$(basename $OPNFV_RPM_URL)"; fi
index e7982ba..37bbbb6 100644 (file)
             git-revision: false
             same-node: true
             block: true
-        - 'apex-upload-artifact'
+        - 'apex-upload-rpm-artifact'
+        - trigger-builds:
+          - project: 'apex-iso-verify-{stream}'
+            predefined-parameters: |
+              BUILD_DIRECTORY=apex-build-{stream}/.build
+              OPNFV_CLEAN=yes
+            git-revision: false
+            block: true
+            same-node: true
+        - 'apex-upload-iso-artifact'
 
 - job-template:
     name: 'apex-deploy-virtual-{scenario}-{stream}'
             same-node: true
         - shell:
             !include-raw-escape: ./apex-snapshot-create.sh
-        - shell:
-            !include-raw-escape: ./apex-upload-artifact.sh
+        - 'apex-upload-snapshot-artifact'
 
 # FDIO promote
 - job-template:
             same-node: true
         - shell:
             !include-raw-escape: ./apex-snapshot-create.sh
-        - shell:
-            !include-raw-escape: ./apex-upload-artifact.sh
+        - 'apex-upload-snapshot-artifact'
 
 - job-template:
     name: 'apex-gs-clean-{stream}'
             !include-raw: ./apex-workspace-cleanup.sh
 
 - builder:
-    name: 'apex-upload-artifact'
+    name: 'apex-iso-verify'
     builders:
         - shell:
-            !include-raw: ./apex-upload-artifact.sh
+            !include-raw: ./apex-iso-verify.sh
+
+- builder:
+    name: 'apex-upload-snapshot-artifact'
+    builders:
+        - shell: ./apex-upload-artifact.sh snapshot
+
+- builder:
+    name: 'apex-upload-iso-artifact'
+    builders:
+        - shell: ./apex-upload-artifact.sh iso
+
+- builder:
+    name: 'apex-upload-rpm-artifact'
+    builders:
+        - shell: ./apex-upload-artifact.sh rpm
 
 - builder:
     name: 'apex-gs-cleanup'