Merge "Add missing common-packer variables"
[releng/builder.git] / jjb / integration / integration-deploy-openstack-run-test.sh
index 184863696e3833f14526fe127a68187d7c296b4f..a91acfaad4d0d76ffe341551d2c7947e65d51866 100644 (file)
@@ -1,4 +1,4 @@
-#@IgnoreInspection BashAddShebang
+#!/bin/bash
 # Activate robotframework virtualenv
 # ${ROBOT_VENV} comes from the integration-install-robotframework.sh
 # script.
@@ -248,9 +248,9 @@ minimize_polling=True
 
 [ml2]
 # Needed for VLAN provider tests - because our provider networks are always encapsulated in VXLAN (br-physnet1)
-# MTU(1440) + VXLAN(50) + VLAN(4) = 1494 < MTU eth0/br-physnet1(1500)
-physical_network_mtus = ${PUBLIC_PHYSICAL_NETWORK}:1440
-path_mtu = 1490
+# MTU(1400) + VXLAN(50) + VLAN(4) = 1454 < MTU eth0/br-physnet1(1458)
+physical_network_mtus = ${PUBLIC_PHYSICAL_NETWORK}:1400
+path_mtu = 1458
 
 # workaround for port-status not working due to https://bugs.opendaylight.org/show_bug.cgi?id=9092
 [ml2_odl]
@@ -435,24 +435,19 @@ function list_files () {
     ${SSH} ${ip} "sudo find /etc > /tmp/find.etc.txt"
     ${SSH} ${ip} "sudo find /opt/stack > /tmp/find.opt.stack.txt"
     ${SSH} ${ip} "sudo find /var > /tmp/find2.txt"
-    rsync --rsync-path="sudo rsync" -arv --list-only ssh ${ip}:/var/ > ${folder}/rsync.var.txt
+    ${SSH} ${ip} "sudo find /var > /tmp/find.var.txt"
+    rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/etc/ > ${folder}/rsync.etc.txt
+    rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/opt/stack/ > ${folder}/rsync.opt.stack.txt
+    rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/var/ > ${folder}/rsync.var.txt
     scp ${ip}:/tmp/find.etc.txt ${folder}
     scp ${ip}:/tmp/find.opt.stack.txt ${folder}
     scp ${ip}:/tmp/find2.txt ${folder}
+    scp ${ip}:/tmp/find.var.txt ${folder}
 }
 
 function collect_logs () {
     set +e  # We do not want to create red dot just because something went wrong while fetching logs.
 
-    for i in `seq 1 ${NUM_ODL_SYSTEM}`; do
-        CONTROLLERIP=ODL_SYSTEM_${i}_IP
-        echo "Lets's take the karaf thread dump again..."
-        KARAF_PID=$(ssh ${!CONTROLLERIP} "ps aux | grep ${KARAF_ARTIFACT} | grep -v grep | tr -s ' ' | cut -f2 -d' '")
-        ssh ${!CONTROLLERIP} "jstack $KARAF_PID"> ${WORKSPACE}/karaf_${i}_threads_after.log || true
-        echo "killing karaf process..."
-        ${SSH} "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
-    done
-
     cat > extra_debug.sh << EOF
 echo -e "/usr/sbin/lsmod | /usr/bin/grep openvswitch\n"
 /usr/sbin/lsmod | /usr/bin/grep openvswitch
@@ -473,6 +468,10 @@ env
 source /opt/stack/devstack/openrc admin admin
 echo -e "\nenv after openrc\n"
 env
+echo "\nsudo du -hs /opt/stack"
+sudo du -hs /opt/stack
+echo "\nsudo mount"
+sudo mount
 EOF
 
     # Since this log collection work is happening before the archive build macro which also
@@ -484,9 +483,17 @@ EOF
     # FIXME: Do not create .tar and gzip before copying.
     for i in `seq 1 ${NUM_ODL_SYSTEM}`; do
         CONTROLLERIP=ODL_SYSTEM_${i}_IP
+        echo "collect_logs: for opendaylight controller ip: ${!CONTROLLERIP}"
         NODE_FOLDER="odl_${i}"
         mkdir -p ${NODE_FOLDER}
-        ${SSH} ${!CONTROLLERIP} "journalctl > /tmp/journalctl.log"
+        echo "Lets's take the karaf thread dump again..."
+        ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_after.log
+        pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_after.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
+        echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
+        ssh ${!CONTROLLERIP} "jstack ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_after.log || true
+        echo "killing karaf process..."
+        ${SSH} "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
+        ${SSH} ${!CONTROLLERIP} "sudo journalctl > /tmp/journalctl.log"
         scp ${!CONTROLLERIP}:/tmp/journalctl.log ${NODE_FOLDER}
         ${SSH} ${!CONTROLLERIP} "dmesg -T > /tmp/dmesg.log"
         scp ${!CONTROLLERIP}:/tmp/dmesg.log ${NODE_FOLDER}
@@ -499,12 +506,11 @@ EOF
         grep "ROBOT MESSAGE\| ERROR " ${NODE_FOLDER}/odl${i}_karaf.log > ${NODE_FOLDER}/odl${i}_err.log
         grep "ROBOT MESSAGE\| ERROR \| WARN \|Exception" \
             ${NODE_FOLDER}/odl${i}_karaf.log > ${NODE_FOLDER}/odl${i}_err_warn_exception.log
-        # -B1 will collect one line before the match, and -A2 will collect two lines after the match. We really only
-        # need the ROBOT match, but in order to keep the context of the Exception matches we want to collect and have
-        # the ROBOT logs in the right place, we have to live with it.
-        grep -A2 -B1 -E '(ROBOT|Exception$|Exception:|Exception{)' ${NODE_FOLDER}/odl${i}_karaf.log > ${NODE_FOLDER}/odl${i}_exception.log
+        # Print ROBOT lines and print Exception lines. For exception lines also print the previous line for context
+        sed -n -e '/ROBOT MESSAGE/P' -e '$!N;/Exception/P;D' ${NODE_FOLDER}/odl${i}_karaf.log > ${NODE_FOLDER}/odl${i}_exception.log
         rm ${NODE_FOLDER}/odl${i}_karaf.log.tar
-        mv karaf_${i}_threads* ${NODE_FOLDER}
+        mv *_threads* ${NODE_FOLDER}
+        mv ps_* ${NODE_FOLDER}
         mv ${NODE_FOLDER} ${WORKSPACE}/archives/
     done
 
@@ -513,8 +519,10 @@ EOF
     # Control Node
     for i in `seq 1 ${NUM_OPENSTACK_CONTROL_NODES}`; do
         OSIP=OPENSTACK_CONTROL_NODE_${i}_IP
+        echo "collect_logs: for openstack control node ip: ${!OSIP}"
         NODE_FOLDER="control_${i}"
         mkdir -p ${NODE_FOLDER}
+        scp ${!OSIP}:/etc/dnsmasq.conf ${NODE_FOLDER}
         scp ${!OSIP}:/etc/keystone/keystone.conf ${NODE_FOLDER}
         scp ${!OSIP}:/etc/keystone/keystone-uwsgi-admin.ini ${NODE_FOLDER}
         scp ${!OSIP}:/etc/keystone/keystone-uwsgi-public.ini ${NODE_FOLDER}
@@ -537,15 +545,14 @@ EOF
         scp ${!OSIP}:/opt/stack/requirements/upper-constraints.txt ${NODE_FOLDER}
         scp ${!OSIP}:/opt/stack/tempest/etc/tempest.conf ${NODE_FOLDER}
         scp ${!OSIP}:/tmp/get_devstack.sh.txt ${NODE_FOLDER}
-        scp ${!OSIP}:/var/log/httpd/keystone_access.log ${NODE_FOLDER}
-        scp ${!OSIP}:/var/log/httpd/keystone.log ${NODE_FOLDER}
         scp ${!OSIP}:/var/log/openvswitch/ovs-vswitchd.log ${NODE_FOLDER}
         scp ${!OSIP}:/var/log/openvswitch/ovsdb-server.log ${NODE_FOLDER}
         list_files "${!OSIP}" "${NODE_FOLDER}"
         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/etc/hosts ${NODE_FOLDER}
         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/usr/lib/systemd/system/haproxy.service ${NODE_FOLDER}
         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/audit/audit.log ${NODE_FOLDER}
-        rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/dmesg.log ${NODE_FOLDER}
+        rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/httpd/keystone_access.log ${NODE_FOLDER}
+        rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/httpd/keystone.log ${NODE_FOLDER}
         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/messages ${NODE_FOLDER}
         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/rabbitmq ${NODE_FOLDER}
         rsync -avhe ssh ${!OSIP}:/opt/stack/logs/* ${NODE_FOLDER} # rsync to prevent copying of symbolic links
@@ -554,13 +561,17 @@ EOF
         scp ${!OSIP}:/tmp/extra_debug.log ${NODE_FOLDER}
         scp ${!OSIP}:/tmp/journalctl.log ${NODE_FOLDER}
         scp ${!OSIP}:/tmp/*.xz ${NODE_FOLDER}
+        ${SSH} ${!CONTROLLERIP} "dmesg -T > /tmp/dmesg.log"
+        scp ${!CONTROLLERIP}:/tmp/dmesg.log ${NODE_FOLDER}
         mv local.conf_control_${!OSIP} ${NODE_FOLDER}/local.conf
+        mv /tmp/qdhcp ${NODE_FOLDER}
         mv ${NODE_FOLDER} ${WORKSPACE}/archives/
     done
 
     # Compute Nodes
     for i in `seq 1 ${NUM_OPENSTACK_COMPUTE_NODES}`; do
         OSIP=OPENSTACK_COMPUTE_NODE_${i}_IP
+        echo "collect_logs: for openstack compute node ip: ${!OSIP}"
         NODE_FOLDER="compute_${i}"
         mkdir -p ${NODE_FOLDER}
         scp ${!OSIP}:/etc/nova/nova.conf ${NODE_FOLDER}
@@ -576,7 +587,6 @@ EOF
         list_files "${!OSIP}" "${NODE_FOLDER}"
         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/etc/hosts ${NODE_FOLDER}
         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/audit/audit.log ${NODE_FOLDER}
-        rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/dmesg.log ${NODE_FOLDER}
         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/libvirt ${NODE_FOLDER}
         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/messages ${NODE_FOLDER}
         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/nova-agent.log ${NODE_FOLDER}
@@ -586,6 +596,8 @@ EOF
         scp ${!OSIP}:/tmp/extra_debug.log ${NODE_FOLDER}
         scp ${!OSIP}:/tmp/journalctl.log ${NODE_FOLDER}
         scp ${!OSIP}:/tmp/*.xz ${NODE_FOLDER}/
+        ${SSH} ${!OSIP} "dmesg -T > /tmp/dmesg.log"
+        scp ${!OSIP}:/tmp/dmesg.log ${NODE_FOLDER}
         mv local.conf_compute_${!OSIP} ${NODE_FOLDER}/local.conf
         mv ${NODE_FOLDER} ${WORKSPACE}/archives/
     done
@@ -785,6 +797,8 @@ echo "127.0.0.1   localhost \${HOSTNAME}" >> /tmp/hosts
 echo "::1         localhost \${HOSTNAME}" >> /tmp/hosts
 sudo mv /tmp/hosts /etc/hosts
 sudo mkdir /opt/stack
+echo "Create RAM disk for /opt/stack"
+sudo mount -t tmpfs -o size=2G tmpfs /opt/stack
 sudo chmod 777 /opt/stack
 cd /opt/stack
 echo "git clone https://git.openstack.org/openstack-dev/devstack --branch ${OPENSTACK_BRANCH}"
@@ -871,14 +885,14 @@ done
 # AccessRefused: (0, 0): (403) ACCESS_REFUSED - Login was refused using authentication mechanism AMQPLAIN. For details see the broker logfile.
 # Compare that timestamp to this log in the control stack.log: sudo rabbitmqctl set_permissions -p nova_cell1 stackrabbit
 # If the n-cpu.log is earlier than the control stack.log timestamp then the failure condition is likely hit.
-
-echo "Wait a maximum of 30m until rabbitmq is ready to allow the controller to create nova_cell1 before the computes need it"
-retry 30 60 "is_rabbitmq_ready ${OPENSTACK_CONTROL_NODE_1_IP}"
+WAIT_FOR_RABBITMQ_MINUTES=60
+echo "Wait a maximum of ${WAIT_FOR_RABBITMQ_MINUTES}m until rabbitmq is ready to allow the controller to create nova_cell1 before the computes need it"
+retry ${WAIT_FOR_RABBITMQ_MINUTES} 60 "is_rabbitmq_ready ${OPENSTACK_CONTROL_NODE_1_IP}"
 rc=$?
 if ((${rc} == 0)); then
     echo "rabbitmq is ready, starting ${NUM_OPENSTACK_COMPUTE_NODES} compute(s)"
 else
-    echo "rabbitmq was not ready in "
+    echo "rabbitmq was not ready in ${WAIT_FOR_RABBITMQ_MINUTES}m"
     collect_logs
     exit 1
 fi
@@ -1083,6 +1097,10 @@ for i in `seq 1 ${NUM_OPENSTACK_SITES}`; do
         sudo ip netns exec pnf_ns ifconfig pnf_veth1 up ${EXTNET_PNF_IP}/24;
         sudo ovs-vsctl add-port ${PUBLIC_BRIDGE} pnf_veth0;
     "
+    # Control Node - set VXLAN TEP IP for Genius Auto TZ
+    ${SSH} ${!CONTROLIP} "
+        sudo ovs-vsctl set O . external_ids:tep-ip=${!CONTROLIP};
+    "
 
     # Control Node - external net internet address simulation
     ${SSH} ${!CONTROLIP} "
@@ -1103,6 +1121,10 @@ for i in `seq 1 ${NUM_OPENSTACK_SITES}`; do
         ${SSH} $compute_ip "
             sudo ovs-vsctl add-port $PUBLIC_BRIDGE $CONTROLPORT -- set interface $CONTROLPORT type=vxlan options:local_ip=$compute_ip options:remote_ip=${!CONTROLIP} options:dst_port=9876 options:key=flow
         "
+         #Compute Node - set VXLAN TEP IP for Genius Auto TZ
+        ${SSH} $compute_ip "
+            sudo ovs-vsctl set O . external_ids:tep-ip=${compute_ip};
+        "
     done
 done
 
@@ -1139,7 +1161,7 @@ else
     workpath="${WORKSPACE}/test/csit/suites"
     for suite in ${SUITES}; do
         fullsuite="${workpath}/${suite}"
-        if [ -z ${newsuites} ]; then
+        if [ -z "${newsuites}" ]; then
             newsuites+=${fullsuite}
         else
             newsuites+=" "${fullsuite}
@@ -1167,12 +1189,19 @@ source /tmp/os_netvirt_client_rc
 
 echo "Starting Robot test suites ${SUITES} ..."
 # please add pybot -v arguments on a single line and alphabetized
+suite_num=0
 for suite in ${SUITES}; do
-    log_name_ext=$(basename ${suite} | cut -d. -f1)
-    pybot -N ${TESTPLAN} --removekeywords wuks -c critical -e exclude -e skip_if_${DISTROSTREAM} \
-    --log log_${log_name_ext}.html --report None --output output_${log_name_ext}.xml \
+    # prepend a incrmental counter to the suite name so that the full robot log combining all the suites as is done
+    # in the rebot step below will list all the suites in chronological order as rebot seems to alphabatize them
+    let "suite_num = suite_num + 1"
+    suite_index="$(printf %02d ${suite_num})"
+    suite_name="$(basename ${suite} | cut -d. -f1)"
+    log_name="${suite_index}_${suite_name}"
+    pybot -N ${log_name} --removekeywords wuks -c critical -e exclude -e skip_if_${DISTROSTREAM} \
+    --log log_${log_name}.html --report None --output output_${log_name}.xml \
     -v BUNDLEFOLDER:${BUNDLEFOLDER} \
     -v BUNDLE_URL:${ACTUAL_BUNDLE_URL} \
+    -v CONTROLLERFEATURES:${CONTROLLERFEATURES} \
     -v CONTROLLER_USER:${USER} \
     -v DEVSTACK_DEPLOY_PATH:/opt/stack/devstack \
     -v HA_PROXY_IP:${HA_PROXY_IP} \
@@ -1219,7 +1248,7 @@ for suite in ${SUITES}; do
     ${TESTOPTIONS} ${suite} || true
 done
 #rebot exit codes seem to be different
-rebot --output ${WORKSPACE}/output.xml --log None --report None output_*.xml || true
+rebot --output ${WORKSPACE}/output.xml --log log_full.html --report None -N openstack output_*.xml || true
 
 echo "Examining the files in data/log and checking file size"
 ssh ${ODL_SYSTEM_IP} "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"