Use https to save a redirect
[releng/builder.git] / jjb / integration / integration-deploy-controller-run-test.sh
index 20a536a4553ec25d2813478b3963123fe5e31bf6..baae769d8d977cc143397103db6951a0e68b5945 100755 (executable)
@@ -1,10 +1,11 @@
+#!/bin/bash
 #@IgnoreInspection BashAddShebang
 # Activate robotframework virtualenv
 # ${ROBOT_VENV} comes from the integration-install-robotframework.sh
 # script.
 # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091
 #@IgnoreInspection BashAddShebang
 # Activate robotframework virtualenv
 # ${ROBOT_VENV} comes from the integration-install-robotframework.sh
 # script.
 # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091
-source ${ROBOT_VENV}/bin/activate
-source /tmp/common-functions.sh ${BUNDLEFOLDER}
+source "${ROBOT_VENV}/bin/activate"
+source /tmp/common-functions.sh "${BUNDLEFOLDER}"
 
 echo "#################################################"
 echo "##         Configure Cluster and Start         ##"
 
 echo "#################################################"
 echo "##         Configure Cluster and Start         ##"
@@ -17,6 +18,8 @@ nodes_list=$(get_nodes_list)
 
 run_plan "script"
 
 
 run_plan "script"
 
+add_jvm_support
+
 create_configuration_script
 
 create_startup_script
 create_configuration_script
 
 create_startup_script
@@ -31,96 +34,73 @@ copy_and_run_startup_script
 
 copy_and_run_post_startup_script
 
 
 copy_and_run_post_startup_script
 
-create_controller_variables
+dump_controller_threads
 
 
-if [ ${NUM_OPENSTACK_SYSTEM} -gt 0 ]; then
+if [ "${NUM_OPENSTACK_SYSTEM}" -gt 0 ]; then
    echo "Exiting without running tests to deploy openstack for testing"
    exit
 fi
 
 echo "Generating mininet variables..."
    echo "Exiting without running tests to deploy openstack for testing"
    exit
 fi
 
 echo "Generating mininet variables..."
-for i in `seq 1 ${NUM_TOOLS_SYSTEM}`
+for i in $(seq 1 "${NUM_TOOLS_SYSTEM}")
 do
 do
-    MININETIP=TOOLS_SYSTEM_${i}_IP
+    MININETIP="TOOLS_SYSTEM_${i}_IP"
     tools_variables=${tools_variables}" -v ${MININETIP}:${!MININETIP}"
 done
 
     tools_variables=${tools_variables}" -v ${MININETIP}:${!MININETIP}"
 done
 
-echo "Locating test plan to use..."
-testplan_filepath="${WORKSPACE}/test/csit/testplans/${STREAMTESTPLAN}"
-if [ ! -f "${testplan_filepath}" ]; then
-    testplan_filepath="${WORKSPACE}/test/csit/testplans/${TESTPLAN}"
-fi
-
-echo "Changing the testplan path..."
-cat "${testplan_filepath}" | sed "s:integration:${WORKSPACE}:" > testplan.txt
-cat testplan.txt
-
-# Use the testplan if specific SUITES are not defined.
-if [ -z "${SUITES}" ]; then
-    SUITES=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
-else
-    newsuites=""
-    workpath="${WORKSPACE}/test/csit/suites"
-    for suite in ${SUITES}; do
-        fullsuite="${workpath}/${suite}"
-        if [ -z "${newsuites}" ]; then
-            newsuites+=${fullsuite}
-        else
-            newsuites+=" "${fullsuite}
-        fi
-    done
-    SUITES=${newsuites}
-fi
+get_test_suites SUITES
 
 echo "Starting Robot test suites ${SUITES} ..."
 
 echo "Starting Robot test suites ${SUITES} ..."
-pybot -N ${TESTPLAN} \
-      --removekeywords wuks -c critical -e exclude -e skip_if_${DISTROSTREAM} \
-      -v BUNDLEFOLDER:${BUNDLEFOLDER} \
-      -v BUNDLE_URL:${ACTUAL_BUNDLE_URL} \
-      -v CONTROLLER:${ODL_SYSTEM_IP} \
-      -v CONTROLLER_USER:${USER} \
-      -v JAVA_HOME:${JAVA_HOME} \
-      -v JDKVERSION:${JDKVERSION} \
-      -v JENKINS_WORKSPACE:${WORKSPACE} \
-      -v MININET1:${TOOLS_SYSTEM_2_IP} \
-      -v MININET2:${TOOLS_SYSTEM_3_IP} \
-      -v MININET3:${TOOLS_SYSTEM_4_IP} \
-      -v MININET4:${TOOLS_SYSTEM_5_IP} \
-      -v MININET5:${TOOLS_SYSTEM_6_IP} \
-      -v MININET:${TOOLS_SYSTEM_IP} \
-      -v MININET_USER:${USER} \
-      -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
-      -v NUM_ODL_SYSTEM:${NUM_ODL_SYSTEM} \
-      -v NUM_TOOLS_SYSTEM:${NUM_TOOLS_SYSTEM} \
-      -v ODL_STREAM:${DISTROSTREAM} \
-      -v ODL_SYSTEM_1_IP:${ODL_SYSTEM_IP} \
-      -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} \
-      -v ODL_SYSTEM_USER:${USER} \
+# ${TESTOPTIONS}, ${SUITES} are space-separated parameters and should not be quoted.
+# shellcheck disable=SC2086
+robot -N "${TESTPLAN}" \
+      --removekeywords wuks -c critical -e exclude -e "skip_if_${DISTROSTREAM}" \
+      -v BUNDLEFOLDER:"${BUNDLEFOLDER}" \
+      -v BUNDLE_URL:"${ACTUAL_BUNDLE_URL}" \
+      -v CONTROLLER:"${ODL_SYSTEM_IP}" \
+      -v CONTROLLER_USER:"${USER}" \
+      -v GERRIT_BRANCH:"${GERRIT_BRANCH}" \
+      -v GERRIT_PROJECT:"${GERRIT_PROJECT}" \
+      -v GERRIT_REFSPEC:"${GERRIT_REFSPEC}" \
+      -v JAVA_HOME:"${JAVA_HOME}" \
+      -v JDKVERSION:"${JDKVERSION}" \
+      -v JENKINS_WORKSPACE:"${WORKSPACE}" \
+      -v MININET1:"${TOOLS_SYSTEM_2_IP}" \
+      -v MININET2:"${TOOLS_SYSTEM_3_IP}" \
+      -v MININET3:"${TOOLS_SYSTEM_4_IP}" \
+      -v MININET4:"${TOOLS_SYSTEM_5_IP}" \
+      -v MININET5:"${TOOLS_SYSTEM_6_IP}" \
+      -v MININET:"${TOOLS_SYSTEM_IP}" \
+      -v MININET_USER:"${USER}" \
+      -v NEXUSURL_PREFIX:"${NEXUSURL_PREFIX}" \
+      -v NUM_ODL_SYSTEM:"${NUM_ODL_SYSTEM}" \
+      -v NUM_TOOLS_SYSTEM:"${NUM_TOOLS_SYSTEM}" \
+      -v ODL_STREAM:"${DISTROSTREAM}" \
+      -v ODL_SYSTEM_1_IP:"${ODL_SYSTEM_IP}" \
+      -v ODL_SYSTEM_IP:"${ODL_SYSTEM_IP}" \
+      -v ODL_SYSTEM_USER:"${USER}" \
       -v SUITES:"${SUITES}" \
       -v SUITES:"${SUITES}" \
-      -v TOOLS_SYSTEM_1_IP:${TOOLS_SYSTEM_IP} \
-      -v TOOLS_SYSTEM_2_IP:${TOOLS_SYSTEM_2_IP} \
-      -v TOOLS_SYSTEM_3_IP:${TOOLS_SYSTEM_3_IP} \
-      -v TOOLS_SYSTEM_4_IP:${TOOLS_SYSTEM_4_IP} \
-      -v TOOLS_SYSTEM_5_IP:${TOOLS_SYSTEM_5_IP} \
-      -v TOOLS_SYSTEM_6_IP:${TOOLS_SYSTEM_6_IP} \
-      -v TOOLS_SYSTEM_IP:${TOOLS_SYSTEM_IP} \
-      -v TOOLS_SYSTEM_USER:${USER} \
-      -v USER_HOME:${HOME} \
+      -v TOOLS_SYSTEM_IP:"${TOOLS_SYSTEM_IP}" ${tools_variables} \
+      -v TOOLS_SYSTEM_USER:"${USER}" \
+      -v USER_HOME:"${HOME}" \
       -v WORKSPACE:/tmp \
       ${TESTOPTIONS} ${SUITES} || true
 
 echo "Examining the files in data/log and checking filesize"
       -v WORKSPACE:/tmp \
       ${TESTOPTIONS} ${SUITES} || true
 
 echo "Examining the files in data/log and checking filesize"
-ssh ${ODL_SYSTEM_IP} "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"
-ssh ${ODL_SYSTEM_IP} "du -hs /tmp/${BUNDLEFOLDER}/data/log/*"
+# shellcheck disable=SC2029
+ssh "${ODL_SYSTEM_IP}" "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"
+# shellcheck disable=SC2029
+ssh "${ODL_SYSTEM_IP}" "du -hs /tmp/${BUNDLEFOLDER}/data/log/*"
 
 
-for i in `seq 1 ${NUM_ODL_SYSTEM}`
+for i in $(seq 1 "${NUM_ODL_SYSTEM}")
 do
 do
-    CONTROLLERIP=ODL_SYSTEM_${i}_IP
-    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' ')
+    CONTROLLERIP="ODL_SYSTEM_${i}_IP"
+    echo "Let'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}"
     echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
-    ssh ${!CONTROLLERIP} "${JAVA_HOME}/bin/jstack -l ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_after.log || true
+    # shellcheck disable=SC2029
+    ssh "${!CONTROLLERIP}" "${JAVA_HOME}/bin/jstack -l ${pid}" > "${WORKSPACE}/karaf_${i}_${pid}_threads_after.log" || true
     echo "Killing ODL"
     set +e  # We do not want to create red dot just because something went wrong while fetching logs.
     ssh "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
     echo "Killing ODL"
     set +e  # We do not want to create red dot just because something went wrong while fetching logs.
     ssh "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
@@ -129,19 +109,19 @@ done
 sleep 5
 # FIXME: Unify the copy process between various scripts.
 # TODO: Use rsync.
 sleep 5
 # FIXME: Unify the copy process between various scripts.
 # TODO: Use rsync.
-for i in `seq 1 ${NUM_ODL_SYSTEM}`
+for i in $(seq 1 "${NUM_ODL_SYSTEM}")
 do
 do
-    CONTROLLERIP=ODL_SYSTEM_${i}_IP
+    CONTROLLERIP="ODL_SYSTEM_${i}_IP"
     echo "Compressing karaf.log ${i}"
     echo "Compressing karaf.log ${i}"
-    ssh ${!CONTROLLERIP} gzip --best /tmp/${BUNDLEFOLDER}/data/log/karaf.log
+    ssh "${!CONTROLLERIP}" gzip --best "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
     echo "Fetching compressed karaf.log ${i}"
     echo "Fetching compressed karaf.log ${i}"
-    scp "${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/data/log/karaf.log.gz" "odl${i}_karaf.log.gz" && ssh ${!CONTROLLERIP} rm -f "/tmp/${BUNDLEFOLDER}/data/log/karaf.log.gz"
+    scp "${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/data/log/karaf.log.gz" "odl${i}_karaf.log.gz" && ssh "${!CONTROLLERIP}" rm -f "/tmp/${BUNDLEFOLDER}/data/log/karaf.log.gz"
     # TODO: Should we compress the output log file as well?
     # TODO: Should we compress the output log file as well?
-    scp "${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log" "odl${i}_karaf_console.log" && ssh ${!CONTROLLERIP} rm -f "/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
+    scp "${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log" "odl${i}_karaf_console.log" && ssh "${!CONTROLLERIP}" rm -f "/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
     echo "Fetch GC logs"
     # FIXME: Put member index in filename, instead of directory name.
     mkdir -p "gclogs-${i}"
     echo "Fetch GC logs"
     # FIXME: Put member index in filename, instead of directory name.
     mkdir -p "gclogs-${i}"
-    scp "${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/data/log/*.log" "gclogs-${i}/" && ssh ${!CONTROLLERIP} rm -f "/tmp/${BUNDLEFOLDER}/data/log/*.log"
+    scp "${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/data/log/*.log" "gclogs-${i}/" && ssh "${!CONTROLLERIP}" rm -f "/tmp/${BUNDLEFOLDER}/data/log/*.log"
 done
 
 echo "Examine copied files"
 done
 
 echo "Examine copied files"