Use common-functions for deploy scripts
[releng/builder.git] / jjb / integration / integration-deploy-controller-run-test.sh
1 #@IgnoreInspection BashAddShebang
2 # Activate robotframework virtualenv
3 # ${ROBOT_VENV} comes from the integration-install-robotframework.sh
4 # script.
5 # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091
6 source ${ROBOT_VENV}/bin/activate
7 source /tmp/common-functions.sh ${BUNDLEFOLDER}
8
9 echo "#################################################"
10 echo "##         Configure Cluster and Start         ##"
11 echo "#################################################"
12
13 get_features
14
15 # shellcheck disable=SC2034
16 nodes_list=$(get_nodes_list)
17
18 run_plan "script"
19
20 create_configuration_script
21
22 create_startup_script
23
24 create_post_startup_script
25
26 copy_and_run_configuration_script
27
28 run_plan "config"
29
30 copy_and_run_startup_script
31
32 copy_and_run_post_startup_script
33
34 create_controller_variables
35
36 if [ ${NUM_OPENSTACK_SYSTEM} -gt 0 ]; then
37    echo "Exiting without running tests to deploy openstack for testing"
38    exit
39 fi
40
41 echo "Generating mininet variables..."
42 for i in `seq 1 ${NUM_TOOLS_SYSTEM}`
43 do
44     MININETIP=TOOLS_SYSTEM_${i}_IP
45     tools_variables=${tools_variables}" -v ${MININETIP}:${!MININETIP}"
46 done
47
48 echo "Locating test plan to use..."
49 testplan_filepath="${WORKSPACE}/test/csit/testplans/${STREAMTESTPLAN}"
50 if [ ! -f "${testplan_filepath}" ]; then
51     testplan_filepath="${WORKSPACE}/test/csit/testplans/${TESTPLAN}"
52 fi
53
54 echo "Changing the testplan path..."
55 cat "${testplan_filepath}" | sed "s:integration:${WORKSPACE}:" > testplan.txt
56 cat testplan.txt
57
58 # Use the testplan if specific SUITES are not defined.
59 if [ -z "${SUITES}" ]; then
60     SUITES=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
61 else
62     newsuites=""
63     workpath="${WORKSPACE}/test/csit/suites"
64     for suite in ${SUITES}; do
65         fullsuite="${workpath}/${suite}"
66         if [ -z "${newsuites}" ]; then
67             newsuites+=${fullsuite}
68         else
69             newsuites+=" "${fullsuite}
70         fi
71     done
72     SUITES=${newsuites}
73 fi
74
75 echo "Starting Robot test suites ${SUITES} ..."
76 pybot -N ${TESTPLAN} \
77       --removekeywords wuks -c critical -e exclude -e skip_if_${DISTROSTREAM} \
78       -v BUNDLEFOLDER:${BUNDLEFOLDER} \
79       -v BUNDLE_URL:${ACTUAL_BUNDLE_URL} \
80       -v CONTROLLER:${ODL_SYSTEM_IP} \
81       -v CONTROLLER_USER:${USER} \
82       -v JAVA_HOME:${JAVA_HOME} \
83       -v JDKVERSION:${JDKVERSION} \
84       -v JENKINS_WORKSPACE:${WORKSPACE} \
85       -v MININET1:${TOOLS_SYSTEM_2_IP} \
86       -v MININET2:${TOOLS_SYSTEM_3_IP} \
87       -v MININET3:${TOOLS_SYSTEM_4_IP} \
88       -v MININET4:${TOOLS_SYSTEM_5_IP} \
89       -v MININET5:${TOOLS_SYSTEM_6_IP} \
90       -v MININET:${TOOLS_SYSTEM_IP} \
91       -v MININET_USER:${USER} \
92       -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
93       -v NUM_ODL_SYSTEM:${NUM_ODL_SYSTEM} \
94       -v NUM_TOOLS_SYSTEM:${NUM_TOOLS_SYSTEM} \
95       -v ODL_STREAM:${DISTROSTREAM} \
96       -v ODL_SYSTEM_1_IP:${ODL_SYSTEM_IP} \
97       -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} \
98       -v ODL_SYSTEM_USER:${USER} \
99       -v SUITES:"${SUITES}" \
100       -v TOOLS_SYSTEM_1_IP:${TOOLS_SYSTEM_IP} \
101       -v TOOLS_SYSTEM_2_IP:${TOOLS_SYSTEM_2_IP} \
102       -v TOOLS_SYSTEM_3_IP:${TOOLS_SYSTEM_3_IP} \
103       -v TOOLS_SYSTEM_4_IP:${TOOLS_SYSTEM_4_IP} \
104       -v TOOLS_SYSTEM_5_IP:${TOOLS_SYSTEM_5_IP} \
105       -v TOOLS_SYSTEM_6_IP:${TOOLS_SYSTEM_6_IP} \
106       -v TOOLS_SYSTEM_IP:${TOOLS_SYSTEM_IP} \
107       -v TOOLS_SYSTEM_USER:${USER} \
108       -v USER_HOME:${HOME} \
109       -v WORKSPACE:/tmp \
110       ${TESTOPTIONS} ${SUITES} || true
111
112 echo "Examining the files in data/log and checking filesize"
113 ssh ${ODL_SYSTEM_IP} "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"
114 ssh ${ODL_SYSTEM_IP} "du -hs /tmp/${BUNDLEFOLDER}/data/log/*"
115
116 for i in `seq 1 ${NUM_ODL_SYSTEM}`
117 do
118     CONTROLLERIP=ODL_SYSTEM_${i}_IP
119     echo "Lets's take the karaf thread dump again..."
120     ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_after.log
121     pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_after.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
122     echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
123     ssh ${!CONTROLLERIP} "${JAVA_HOME}/bin/jstack -l ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_after.log || true
124     echo "Killing ODL"
125     set +e  # We do not want to create red dot just because something went wrong while fetching logs.
126     ssh "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
127 done
128
129 sleep 5
130 # FIXME: Unify the copy process between various scripts.
131 # TODO: Use rsync.
132 for i in `seq 1 ${NUM_ODL_SYSTEM}`
133 do
134     CONTROLLERIP=ODL_SYSTEM_${i}_IP
135     echo "Compressing karaf.log ${i}"
136     ssh ${!CONTROLLERIP} gzip --best /tmp/${BUNDLEFOLDER}/data/log/karaf.log
137     echo "Fetching compressed karaf.log ${i}"
138     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"
139     # TODO: Should we compress the output log file as well?
140     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"
141     echo "Fetch GC logs"
142     # FIXME: Put member index in filename, instead of directory name.
143     mkdir -p "gclogs-${i}"
144     scp "${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/data/log/*.log" "gclogs-${i}/" && ssh ${!CONTROLLERIP} rm -f "/tmp/${BUNDLEFOLDER}/data/log/*.log"
145 done
146
147 echo "Examine copied files"
148 ls -lt
149
150 true  # perhaps Jenkins is testing last exit code
151
152 # vim: ts=4 sw=4 sts=4 et ft=sh :