1 #@IgnoreInspection BashAddShebang
2 # Activate robotframework virtualenv
3 # ${ROBOT_VENV} comes from the integration-install-robotframework.sh
5 # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091
6 source ${ROBOT_VENV}/bin/activate
7 source /tmp/common-functions.sh ${BUNDLEFOLDER}
9 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
10 echo "Configure cluster"
11 AKKACONF=/tmp/${BUNDLEFOLDER}/configuration/initial/akka.conf
12 MODULESCONF=/tmp/${BUNDLEFOLDER}/configuration/initial/modules.conf
13 MODULESHARDSCONF=/tmp/${BUNDLEFOLDER}/configuration/initial/module-shards.conf
16 if [ ${CONTROLLERSCOPE} == 'all' ]; then
17 ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
18 export CONTROLLERMEM="3072m"
20 ACTUALFEATURES="odl-infrautils-ready,${CONTROLLERFEATURES}"
23 # Some versions of jenkins job builder result in feature list containing spaces
24 # and ending in newline. Remove all that.
25 ACTUALFEATURES=`echo "${ACTUALFEATURES}" | tr -d '\n \r'`
26 echo "ACTUALFEATURES: ${ACTUALFEATURES}"
28 # In the case that we want to install features via karaf shell, a space separated list of
29 # ACTUALFEATURES IS NEEDED
30 SPACE_SEPARATED_FEATURES=$(echo "${ACTUALFEATURES}" | tr ',' ' ')
31 echo "SPACE_SEPARATED_FEATURES: ${SPACE_SEPARATED_FEATURES}"
35 cat > ${WORKSPACE}/configuration-script.sh <<EOF
37 source /tmp/common-functions.sh ${BUNDLEFOLDER}
39 echo "Changing to /tmp"
42 echo "Downloading the distribution..."
43 wget --progress=dot:mega '${ACTUAL_BUNDLE_URL}'
45 echo "Extracting the new controller..."
48 echo "Adding external repositories..."
49 sed -ie "s%org.ops4j.pax.url.mvn.repositories=%org.ops4j.pax.url.mvn.repositories=https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot@id=opendaylight-snapshot@snapshots, https://nexus.opendaylight.org/content/repositories/public@id=opendaylight-mirror, http://repo1.maven.org/maven2@id=central, http://repository.springsource.com/maven/bundles/release@id=spring.ebr.release, http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external, http://zodiac.springsource.com/maven/bundles/release@id=gemini, http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases, https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@noreleases, https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases%g" ${MAVENCONF}
52 if [[ "$USEFEATURESBOOT" == "True" ]]; then
53 echo "Configuring the startup features..."
54 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" ${FEATURESCONF}
57 FEATURE_TEST_STRING="features-integration-test"
58 if [[ "$KARAF_VERSION" == "karaf4" ]]; then
59 FEATURE_TEST_STRING="features-test"
62 sed -ie "s%\(featuresRepositories=\|featuresRepositories =\)%featuresRepositories = mvn:org.opendaylight.integration/\${FEATURE_TEST_STRING}/${BUNDLE_VERSION}/xml/features,mvn:org.apache.karaf.decanter/apache-karaf-decanter/1.0.0/xml/features,%g" ${FEATURESCONF}
63 if [[ ! -z "${REPO_URL}" ]]; then
64 sed -ie "s%featuresRepositories =%featuresRepositories = ${REPO_URL},%g" ${FEATURESCONF}
68 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
69 echo "Enable the l3.fwd in custom.properties..."
70 echo "ovsdb.l3.fwd.enabled=yes" >> ${CUSTOMPROP}
74 configure_karaf_log "${KARAF_VERSION}" "${CONTROLLERDEBUGMAP}"
76 set_java_vars "${JAVA_HOME}" "${CONTROLLERMEM}" "${MEMCONF}"
78 echo "Listing all open ports on controller system..."
81 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
83 # Copy shard file if exists
84 if [ -f /tmp/custom_shard_config.txt ]; then
85 echo "Custom shard config exists!!!"
86 echo "Copying the shard config..."
87 cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
90 echo "Configuring cluster"
91 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 \$2
96 echo "Dump modules.conf"
99 echo "Dump module-shards.conf"
100 cat ${MODULESHARDSCONF}
104 # cat > ${WORKSPACE}/configuration-script.sh <<EOF
106 # Create the startup script to be run on controller.
107 cat > ${WORKSPACE}/startup-script.sh <<EOF
109 echo "Redirecting karaf console output to karaf_console.log"
110 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
111 mkdir -p /tmp/${BUNDLEFOLDER}/data/log
113 echo "Starting controller..."
114 /tmp/${BUNDLEFOLDER}/bin/start
117 # cat > ${WORKSPACE}/startup-script.sh <<EOF
119 cat > ${WORKSPACE}/post-startup-script.sh <<EOF
121 if [[ "$USEFEATURESBOOT" != "True" ]]; then
123 # wait up to 60s for karaf port 8101 to be opened, polling every 5s
125 until [[ \$loop_count -ge 12 ]]; do
126 netstat -na | grep 8101 && break;
127 loop_count=\$[\$loop_count+1];
131 echo "going to feature:install --no-auto-refresh ${SPACE_SEPARATED_FEATURES} one at a time"
132 for feature in ${SPACE_SEPARATED_FEATURES}; do
133 sshpass -p karaf ssh -o StrictHostKeyChecking=no \
134 -o UserKnownHostsFile=/dev/null \
136 -p 8101 karaf@localhost \
137 feature:install --no-auto-refresh \$feature;
140 echo "ssh to karaf console to list -i installed features"
141 sshpass -p karaf ssh -o StrictHostKeyChecking=no \
142 -o UserKnownHostsFile=/dev/null \
144 -p 8101 karaf@localhost \
148 echo "Waiting up to 3 minutes for controller to come up, checking every 5 seconds..."
151 grep 'org.opendaylight.infrautils.ready-impl.*System ready' /tmp/${BUNDLEFOLDER}/data/log/karaf.log
154 echo "Controller is UP"
159 # if we ended up not finding ready status in the above loop, we can output some debugs
160 grep 'org.opendaylight.infrautils.ready-impl.*System ready' /tmp/${BUNDLEFOLDER}/data/log/karaf.log
163 echo "Timeout Controller DOWN"
164 echo "Dumping first 500K bytes of karaf log..."
165 head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
166 echo "Dumping last 500K bytes of karaf log..."
167 tail --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
168 echo "Listing all open ports on controller system"
173 echo "Listing all open ports on controller system..."
176 function exit_on_log_file_message {
177 echo "looking for \"\$1\" in log file"
178 if grep --quiet "\$1" "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"; then
179 echo ABORTING: found "\$1"
180 echo "Dumping first 500K bytes of karaf log..."
181 head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
182 echo "Dumping last 500K bytes of karaf log..."
183 tail --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
188 exit_on_log_file_message 'BindException: Address already in use'
189 exit_on_log_file_message 'server is unhealthy'
192 # cat > ${WORKSPACE}/post-startup-script.sh <<EOF
194 [ "$NUM_OPENSTACK_SITES" ] || NUM_OPENSTACK_SITES=1
195 NUM_ODLS_PER_SITE=$((NUM_ODL_SYSTEM / NUM_OPENSTACK_SITES))
196 for i in `seq 1 ${NUM_OPENSTACK_SITES}`
198 # Get full list of ODL nodes for this site
200 for j in `seq 1 ${NUM_ODLS_PER_SITE}`
202 odl_ip=ODL_SYSTEM_$(((i - 1) * NUM_ODLS_PER_SITE + j))_IP
203 odl_node_list="${odl_node_list} ${!odl_ip}"
206 for j in `seq 1 ${NUM_ODLS_PER_SITE}`
208 odl_ip=ODL_SYSTEM_$(((i - 1) * NUM_ODLS_PER_SITE + j))_IP
209 # Copy over the config script to controller and execute it (parameters are used only for cluster)
210 echo "Execute the configuration script on controller ${!odl_ip} for index $j with node list ${odl_node_list}"
211 scp ${WORKSPACE}/configuration-script.sh ${!odl_ip}:/tmp
212 ssh ${!odl_ip} "bash /tmp/configuration-script.sh ${j} '${odl_node_list}'"
218 # Copy over the startup script to controller and execute it.
219 for i in `seq 1 ${NUM_ODL_SYSTEM}`
221 CONTROLLERIP=ODL_SYSTEM_${i}_IP
222 echo "Execute the startup script on controller ${!CONTROLLERIP}"
223 scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp
224 ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
228 for i in `seq 1 ${NUM_ODL_SYSTEM}`
230 CONTROLLERIP=ODL_SYSTEM_${i}_IP
231 echo "Execute the post startup script on controller ${!CONTROLLERIP}"
232 scp ${WORKSPACE}/post-startup-script.sh ${!CONTROLLERIP}:/tmp
233 ssh ${!CONTROLLERIP} "bash /tmp/post-startup-script.sh $(( seed_index++ ))"
234 if [ $(( $i % (${NUM_ODL_SYSTEM} / ${NUM_OPENSTACK_SITES}) )) == 0 ]; then
239 echo "Generating controller variables..."
240 for i in `seq 1 ${NUM_ODL_SYSTEM}`
242 CONTROLLERIP=ODL_SYSTEM_${i}_IP
243 odl_variables=${odl_variables}" -v ${CONTROLLERIP}:${!CONTROLLERIP}"
244 echo "Lets's take the karaf thread dump"
245 ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_before.log
246 pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_before.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
247 echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
248 ssh ${!CONTROLLERIP} "${JAVA_HOME}/bin/jstack -l ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_before.log || true
251 if [ ${NUM_OPENSTACK_SYSTEM} -gt 0 ]; then
252 echo "Exiting without running tests to deploy openstack for testing"
256 echo "Generating mininet variables..."
257 for i in `seq 1 ${NUM_TOOLS_SYSTEM}`
259 MININETIP=TOOLS_SYSTEM_${i}_IP
260 tools_variables=${tools_variables}" -v ${MININETIP}:${!MININETIP}"
263 echo "Locating test plan to use..."
264 testplan_filepath="${WORKSPACE}/test/csit/testplans/${STREAMTESTPLAN}"
265 if [ ! -f "${testplan_filepath}" ]; then
266 testplan_filepath="${WORKSPACE}/test/csit/testplans/${TESTPLAN}"
269 echo "Changing the testplan path..."
270 cat "${testplan_filepath}" | sed "s:integration:${WORKSPACE}:" > testplan.txt
273 # Use the testplan if specific SUITES are not defined.
274 if [ -z "${SUITES}" ]; then
275 SUITES=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
278 workpath="${WORKSPACE}/test/csit/suites"
279 for suite in ${SUITES}; do
280 fullsuite="${workpath}/${suite}"
281 if [ -z "${newsuites}" ]; then
282 newsuites+=${fullsuite}
284 newsuites+=" "${fullsuite}
290 echo "Starting Robot test suites ${SUITES} ..."
291 pybot -N ${TESTPLAN} \
292 --removekeywords wuks -c critical -e exclude -e skip_if_${DISTROSTREAM} \
293 -v BUNDLEFOLDER:${BUNDLEFOLDER} \
294 -v BUNDLE_URL:${ACTUAL_BUNDLE_URL} \
295 -v CONTROLLER:${ODL_SYSTEM_IP} \
296 -v CONTROLLER_USER:${USER} \
297 -v JAVA_HOME:${JAVA_HOME} \
298 -v JDKVERSION:${JDKVERSION} \
299 -v JENKINS_WORKSPACE:${WORKSPACE} \
300 -v MININET1:${TOOLS_SYSTEM_2_IP} \
301 -v MININET2:${TOOLS_SYSTEM_3_IP} \
302 -v MININET3:${TOOLS_SYSTEM_4_IP} \
303 -v MININET4:${TOOLS_SYSTEM_5_IP} \
304 -v MININET5:${TOOLS_SYSTEM_6_IP} \
305 -v MININET:${TOOLS_SYSTEM_IP} \
306 -v MININET_USER:${USER} \
307 -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
308 -v NUM_ODL_SYSTEM:${NUM_ODL_SYSTEM} \
309 -v NUM_TOOLS_SYSTEM:${NUM_TOOLS_SYSTEM} \
310 -v ODL_STREAM:${DISTROSTREAM} \
311 -v ODL_SYSTEM_1_IP:${ODL_SYSTEM_IP} \
312 -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} \
313 -v ODL_SYSTEM_USER:${USER} \
314 -v TOOLS_SYSTEM_1_IP:${TOOLS_SYSTEM_IP} \
315 -v TOOLS_SYSTEM_2_IP:${TOOLS_SYSTEM_2_IP} \
316 -v TOOLS_SYSTEM_3_IP:${TOOLS_SYSTEM_3_IP} \
317 -v TOOLS_SYSTEM_4_IP:${TOOLS_SYSTEM_4_IP} \
318 -v TOOLS_SYSTEM_5_IP:${TOOLS_SYSTEM_5_IP} \
319 -v TOOLS_SYSTEM_6_IP:${TOOLS_SYSTEM_6_IP} \
320 -v TOOLS_SYSTEM_IP:${TOOLS_SYSTEM_IP} \
321 -v TOOLS_SYSTEM_USER:${USER} \
322 -v USER_HOME:${HOME} \
324 ${TESTOPTIONS} ${SUITES} || true
326 echo "Examining the files in data/log and checking filesize"
327 ssh ${ODL_SYSTEM_IP} "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"
328 ssh ${ODL_SYSTEM_IP} "du -hs /tmp/${BUNDLEFOLDER}/data/log/*"
330 for i in `seq 1 ${NUM_ODL_SYSTEM}`
332 CONTROLLERIP=ODL_SYSTEM_${i}_IP
333 echo "Lets's take the karaf thread dump again..."
334 ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_after.log
335 pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_after.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
336 echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
337 ssh ${!CONTROLLERIP} "${JAVA_HOME}/bin/jstack -l ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_after.log || true
339 set +e # We do not want to create red dot just because something went wrong while fetching logs.
340 ssh "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
344 # FIXME: Unify the copy process between various scripts.
346 for i in `seq 1 ${NUM_ODL_SYSTEM}`
348 CONTROLLERIP=ODL_SYSTEM_${i}_IP
349 echo "Compressing karaf.log ${i}"
350 ssh ${!CONTROLLERIP} gzip --best /tmp/${BUNDLEFOLDER}/data/log/karaf.log
351 echo "Fetching compressed karaf.log ${i}"
352 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"
353 # TODO: Should we compress the output log file as well?
354 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"
356 # FIXME: Put member index in filename, instead of directory name.
357 mkdir -p "gclogs-${i}"
358 scp "${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/data/log/*.log" "gclogs-${i}/" && ssh ${!CONTROLLERIP} rm -f "/tmp/${BUNDLEFOLDER}/data/log/*.log"
361 echo "Examine copied files"
364 true # perhaps Jenkins is testing last exit code
366 # vim: ts=4 sw=4 sts=4 et ft=sh :