Use gerrit patch for coe csit
[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 GERRIT_BRANCH:${GERRIT_BRANCH} \
83       -v GERRIT_REFSPEC:${GERRIT_REFSPEC} \
84       -v JAVA_HOME:${JAVA_HOME} \
85       -v JDKVERSION:${JDKVERSION} \
86       -v JENKINS_WORKSPACE:${WORKSPACE} \
87       -v MININET1:${TOOLS_SYSTEM_2_IP} \
88       -v MININET2:${TOOLS_SYSTEM_3_IP} \
89       -v MININET3:${TOOLS_SYSTEM_4_IP} \
90       -v MININET4:${TOOLS_SYSTEM_5_IP} \
91       -v MININET5:${TOOLS_SYSTEM_6_IP} \
92       -v MININET:${TOOLS_SYSTEM_IP} \
93       -v MININET_USER:${USER} \
94       -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
95       -v NUM_ODL_SYSTEM:${NUM_ODL_SYSTEM} \
96       -v NUM_TOOLS_SYSTEM:${NUM_TOOLS_SYSTEM} \
97       -v ODL_STREAM:${DISTROSTREAM} \
98       -v ODL_SYSTEM_1_IP:${ODL_SYSTEM_IP} \
99       -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} \
100       -v ODL_SYSTEM_USER:${USER} \
101       -v SUITES:"${SUITES}" \
102       -v TOOLS_SYSTEM_1_IP:${TOOLS_SYSTEM_IP} \
103       -v TOOLS_SYSTEM_2_IP:${TOOLS_SYSTEM_2_IP} \
104       -v TOOLS_SYSTEM_3_IP:${TOOLS_SYSTEM_3_IP} \
105       -v TOOLS_SYSTEM_4_IP:${TOOLS_SYSTEM_4_IP} \
106       -v TOOLS_SYSTEM_5_IP:${TOOLS_SYSTEM_5_IP} \
107       -v TOOLS_SYSTEM_6_IP:${TOOLS_SYSTEM_6_IP} \
108       -v TOOLS_SYSTEM_IP:${TOOLS_SYSTEM_IP} \
109       -v TOOLS_SYSTEM_USER:${USER} \
110       -v USER_HOME:${HOME} \
111       -v WORKSPACE:/tmp \
112       ${TESTOPTIONS} ${SUITES} || true
113
114 echo "Examining the files in data/log and checking filesize"
115 ssh ${ODL_SYSTEM_IP} "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"
116 ssh ${ODL_SYSTEM_IP} "du -hs /tmp/${BUNDLEFOLDER}/data/log/*"
117
118 for i in `seq 1 ${NUM_ODL_SYSTEM}`
119 do
120     CONTROLLERIP=ODL_SYSTEM_${i}_IP
121     echo "Lets's take the karaf thread dump again..."
122     ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_after.log
123     pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_after.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
124     echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
125     ssh ${!CONTROLLERIP} "${JAVA_HOME}/bin/jstack -l ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_after.log || true
126     echo "Killing ODL"
127     set +e  # We do not want to create red dot just because something went wrong while fetching logs.
128     ssh "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
129 done
130
131 sleep 5
132 # FIXME: Unify the copy process between various scripts.
133 # TODO: Use rsync.
134 for i in `seq 1 ${NUM_ODL_SYSTEM}`
135 do
136     CONTROLLERIP=ODL_SYSTEM_${i}_IP
137     echo "Compressing karaf.log ${i}"
138     ssh ${!CONTROLLERIP} gzip --best /tmp/${BUNDLEFOLDER}/data/log/karaf.log
139     echo "Fetching compressed karaf.log ${i}"
140     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"
141     # TODO: Should we compress the output log file as well?
142     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"
143     echo "Fetch GC logs"
144     # FIXME: Put member index in filename, instead of directory name.
145     mkdir -p "gclogs-${i}"
146     scp "${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/data/log/*.log" "gclogs-${i}/" && ssh ${!CONTROLLERIP} rm -f "/tmp/${BUNDLEFOLDER}/data/log/*.log"
147 done
148
149 echo "Examine copied files"
150 ls -lt
151
152 true  # perhaps Jenkins is testing last exit code
153
154 # vim: ts=4 sw=4 sts=4 et ft=sh :