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}"
33 if [ -f "${WORKSPACE}/test/csit/scriptplans/${TESTPLAN}" ]; then
34 echo "scriptplan exists!!!"
35 echo "Changing the scriptplan path..."
36 cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
38 for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
39 echo "Executing ${line}..."
40 # shellcheck source=${line} disable=SC1091
45 cat > ${WORKSPACE}/configuration-script.sh <<EOF
47 source /tmp/common-functions.sh ${BUNDLEFOLDER}
49 echo "Changing to /tmp"
52 echo "Downloading the distribution..."
53 wget --progress=dot:mega '${ACTUAL_BUNDLE_URL}'
55 echo "Extracting the new controller..."
58 echo "Adding external repositories..."
59 sed -ie "s%org.ops4j.pax.url.mvn.repositories=%org.ops4j.pax.url.mvn.repositories=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}
62 if [[ "$USEFEATURESBOOT" == "True" ]]; then
63 echo "Configuring the startup features..."
64 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" ${FEATURESCONF}
67 FEATURE_TEST_STRING="features-integration-test"
68 if [[ "$KARAF_VERSION" == "karaf4" ]]; then
69 FEATURE_TEST_STRING="features-test"
72 sed -ie "s%\(featuresRepositories=\|featuresRepositories =\)%featuresRepositories = mvn:org.opendaylight.integration/\${FEATURE_TEST_STRING}/${BUNDLEVERSION}/xml/features,mvn:org.apache.karaf.decanter/apache-karaf-decanter/1.0.0/xml/features,%g" ${FEATURESCONF}
75 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
76 echo "Enable the l3.fwd in custom.properties..."
77 echo "ovsdb.l3.fwd.enabled=yes" >> ${CUSTOMPROP}
81 configure_karaf_log "${KARAF_VERSION}" "${CONTROLLERDEBUGMAP}"
83 set_java_vars "${JAVA_HOME}" "${CONTROLLERMEM}" "${MEMCONF}"
85 echo "Listing all open ports on controller system..."
88 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
90 # Copy shard file if exists
91 if [ -f /tmp/custom_shard_config.txt ]; then
92 echo "Custom shard config exists!!!"
93 echo "Copying the shard config..."
94 cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
97 echo "Configuring cluster"
98 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 \$2
100 echo "Dump akka.conf"
103 echo "Dump modules.conf"
106 echo "Dump module-shards.conf"
107 cat ${MODULESHARDSCONF}
111 # cat > ${WORKSPACE}/configuration-script.sh <<EOF
113 # Create the startup script to be run on controller.
114 cat > ${WORKSPACE}/startup-script.sh <<EOF
116 echo "Redirecting karaf console output to karaf_console.log"
117 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
118 mkdir -p /tmp/${BUNDLEFOLDER}/data/log
120 echo "Starting controller..."
121 /tmp/${BUNDLEFOLDER}/bin/start
124 # cat > ${WORKSPACE}/startup-script.sh <<EOF
126 cat > ${WORKSPACE}/post-startup-script.sh <<EOF
128 if [[ "$USEFEATURESBOOT" != "True" ]]; then
130 # wait up to 60s for karaf port 8101 to be opened, polling every 5s
132 until [[ \$loop_count -ge 12 ]]; do
133 netstat -na | grep 8101 && break;
134 loop_count=\$[\$loop_count+1];
138 echo "going to feature:install --no-auto-refresh ${SPACE_SEPARATED_FEATURES} one at a time"
139 for feature in ${SPACE_SEPARATED_FEATURES}; do
140 sshpass -p karaf ssh -o StrictHostKeyChecking=no \
141 -o UserKnownHostsFile=/dev/null \
143 -p 8101 karaf@localhost \
144 feature:install --no-auto-refresh \$feature;
147 echo "ssh to karaf console to list -i installed features"
148 sshpass -p karaf ssh -o StrictHostKeyChecking=no \
149 -o UserKnownHostsFile=/dev/null \
151 -p 8101 karaf@localhost \
155 if [ "${DISTROSTREAM}" == "carbon" ] || [ "${DISTROSTREAM}" == "nitrogen" ];
157 echo "only oxygen and above have the infrautils.ready feature, so using REST API to /modules or /shards to determine if the controller is ready.";
162 RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
165 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
166 SHARD="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/jolokia/read/org.opendaylight.controller:Category=Shards,name=\member-\$1-shard-inventory-config,type=DistributedConfigDatastore)"
170 if ([[ \$RESP == *"200"* ]] && ([[ "${ENABLE_HAPROXY_FOR_NEUTRON}" != "yes" ]] || [[ \$SHARD == *'"status":200'* ]])); then
171 echo "Controller is UP"
174 elif (( "\$COUNT" > "600" )); then
175 echo Timeout Controller DOWN
176 echo "Dumping first 500K bytes of karaf log..."
177 head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
178 echo "Dumping last 500K bytes of karaf log..."
179 tail --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
180 echo "Listing all open ports on controller system"
185 COUNT=\$(( \${COUNT} + 1 ))
188 if [[ \$((\$COUNT % 5)) == 0 ]]; then
189 echo already waited \${COUNT} seconds...
195 echo "Waiting up to 3 minutes for controller to come up, checking every 5 seconds..."
198 grep 'org.opendaylight.infrautils.ready-impl.*System ready' /tmp/${BUNDLEFOLDER}/data/log/karaf.log
201 echo "Controller is UP"
206 # if we ended up not finding ready status in the above loop, we can output some debugs
207 grep 'org.opendaylight.infrautils.ready-impl.*System ready' /tmp/${BUNDLEFOLDER}/data/log/karaf.log
210 echo "Timeout Controller DOWN"
211 echo "Dumping first 500K bytes of karaf log..."
212 head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
213 echo "Dumping last 500K bytes of karaf log..."
214 tail --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
215 echo "Listing all open ports on controller system"
221 echo "Listing all open ports on controller system..."
224 function exit_on_log_file_message {
225 echo "looking for \"\$1\" in log file"
226 if grep --quiet "\$1" "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"; then
227 echo ABORTING: found "\$1"
228 echo "Dumping first 500K bytes of karaf log..."
229 head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
230 echo "Dumping last 500K bytes of karaf log..."
231 tail --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
236 exit_on_log_file_message 'BindException: Address already in use'
237 exit_on_log_file_message 'server is unhealthy'
240 # cat > ${WORKSPACE}/post-startup-script.sh <<EOF
242 [ "$NUM_OPENSTACK_SITES" ] || NUM_OPENSTACK_SITES=1
243 NUM_ODLS_PER_SITE=$((NUM_ODL_SYSTEM / NUM_OPENSTACK_SITES))
244 for i in `seq 1 ${NUM_OPENSTACK_SITES}`
246 # Get full list of ODL nodes for this site
248 for j in `seq 1 ${NUM_ODLS_PER_SITE}`
250 odl_ip=ODL_SYSTEM_$(((i - 1) * NUM_ODLS_PER_SITE + j))_IP
251 odl_node_list="${odl_node_list} ${!odl_ip}"
254 for j in `seq 1 ${NUM_ODLS_PER_SITE}`
256 odl_ip=ODL_SYSTEM_$(((i - 1) * NUM_ODLS_PER_SITE + j))_IP
257 # Copy over the config script to controller and execute it (parameters are used only for cluster)
258 echo "Execute the configuration script on controller ${!odl_ip} for index $j with node list ${odl_node_list}"
259 scp ${WORKSPACE}/configuration-script.sh ${!odl_ip}:/tmp
260 ssh ${!odl_ip} "bash /tmp/configuration-script.sh ${j} '${odl_node_list}'"
264 echo "Locating config plan to use..."
265 configplan_filepath="${WORKSPACE}/test/csit/configplans/${STREAMTESTPLAN}"
266 if [ ! -f "${configplan_filepath}" ]; then
267 configplan_filepath="${WORKSPACE}/test/csit/configplans/${TESTPLAN}"
270 if [ -f "${configplan_filepath}" ]; then
271 echo "configplan exists!!!"
272 echo "Changing the configplan path..."
273 cat ${configplan_filepath} | sed "s:integration:${WORKSPACE}:" > configplan.txt
275 for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' configplan.txt ); do
276 echo "Executing ${line}..."
277 # shellcheck source=${line} disable=SC1091
282 # Copy over the startup script to controller and execute it.
283 for i in `seq 1 ${NUM_ODL_SYSTEM}`
285 CONTROLLERIP=ODL_SYSTEM_${i}_IP
286 echo "Execute the startup script on controller ${!CONTROLLERIP}"
287 scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp
288 ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
292 for i in `seq 1 ${NUM_ODL_SYSTEM}`
294 CONTROLLERIP=ODL_SYSTEM_${i}_IP
295 echo "Execute the post startup script on controller ${!CONTROLLERIP}"
296 scp ${WORKSPACE}/post-startup-script.sh ${!CONTROLLERIP}:/tmp
297 ssh ${!CONTROLLERIP} "bash /tmp/post-startup-script.sh $(( seed_index++ ))"
298 if [ $(( $i % (${NUM_ODL_SYSTEM} / ${NUM_OPENSTACK_SITES}) )) == 0 ]; then
303 echo "Generating controller variables..."
304 for i in `seq 1 ${NUM_ODL_SYSTEM}`
306 CONTROLLERIP=ODL_SYSTEM_${i}_IP
307 odl_variables=${odl_variables}" -v ${CONTROLLERIP}:${!CONTROLLERIP}"
308 echo "Lets's take the karaf thread dump"
309 ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_before.log
310 pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_before.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
311 echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
312 ssh ${!CONTROLLERIP} "jstack ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_before.log || true
315 if [ ${NUM_OPENSTACK_SYSTEM} -gt 0 ]; then
316 echo "Exiting without running tests to deploy openstack for testing"
320 echo "Generating mininet variables..."
321 for i in `seq 1 ${NUM_TOOLS_SYSTEM}`
323 MININETIP=TOOLS_SYSTEM_${i}_IP
324 tools_variables=${tools_variables}" -v ${MININETIP}:${!MININETIP}"
327 echo "Locating test plan to use..."
328 testplan_filepath="${WORKSPACE}/test/csit/testplans/${STREAMTESTPLAN}"
329 if [ ! -f "${testplan_filepath}" ]; then
330 testplan_filepath="${WORKSPACE}/test/csit/testplans/${TESTPLAN}"
333 echo "Changing the testplan path..."
334 cat "${testplan_filepath}" | sed "s:integration:${WORKSPACE}:" > testplan.txt
337 # Use the testplan if specific SUITES are not defined.
338 if [ -z "${SUITES}" ]; then
339 SUITES=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
342 workpath="${WORKSPACE}/test/csit/suites"
343 for suite in ${SUITES}; do
344 fullsuite="${workpath}/${suite}"
345 if [ -z "${newsuites}" ]; then
346 newsuites+=${fullsuite}
348 newsuites+=" "${fullsuite}
354 echo "Starting Robot test suites ${SUITES} ..."
355 pybot -N ${TESTPLAN} \
356 --removekeywords wuks -c critical -e exclude -e skip_if_${DISTROSTREAM} \
357 -v BUNDLEFOLDER:${BUNDLEFOLDER} \
358 -v BUNDLE_URL:${ACTUAL_BUNDLE_URL} \
359 -v CONTROLLER:${ODL_SYSTEM_IP} \
360 -v CONTROLLER_USER:${USER} \
361 -v JAVA_HOME:${JAVA_HOME} \
362 -v JDKVERSION:${JDKVERSION} \
363 -v MININET1:${TOOLS_SYSTEM_2_IP} \
364 -v MININET2:${TOOLS_SYSTEM_3_IP} \
365 -v MININET3:${TOOLS_SYSTEM_4_IP} \
366 -v MININET4:${TOOLS_SYSTEM_5_IP} \
367 -v MININET5:${TOOLS_SYSTEM_6_IP} \
368 -v MININET:${TOOLS_SYSTEM_IP} \
369 -v MININET_USER:${USER} \
370 -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
371 -v NUM_ODL_SYSTEM:${NUM_ODL_SYSTEM} \
372 -v ODL_STREAM:${DISTROSTREAM} \
373 -v ODL_SYSTEM_1_IP:${ODL_SYSTEM_IP} \
374 -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} \
375 -v ODL_SYSTEM_USER:${USER} \
376 -v TOOLS_SYSTEM_2_IP:${TOOLS_SYSTEM_2_IP} \
377 -v TOOLS_SYSTEM_3_IP:${TOOLS_SYSTEM_3_IP} \
378 -v TOOLS_SYSTEM_4_IP:${TOOLS_SYSTEM_4_IP} \
379 -v TOOLS_SYSTEM_5_IP:${TOOLS_SYSTEM_5_IP} \
380 -v TOOLS_SYSTEM_6_IP:${TOOLS_SYSTEM_6_IP} \
381 -v TOOLS_SYSTEM_IP:${TOOLS_SYSTEM_IP} \
382 -v TOOLS_SYSTEM_USER:${USER} \
383 -v USER_HOME:${HOME} \
385 ${TESTOPTIONS} ${SUITES} || true
387 echo "Examining the files in data/log and checking filesize"
388 ssh ${ODL_SYSTEM_IP} "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"
389 ssh ${ODL_SYSTEM_IP} "du -hs /tmp/${BUNDLEFOLDER}/data/log/*"
391 for i in `seq 1 ${NUM_ODL_SYSTEM}`
393 CONTROLLERIP=ODL_SYSTEM_${i}_IP
394 echo "Lets's take the karaf thread dump again..."
395 ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_after.log
396 pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_after.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
397 echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
398 ssh ${!CONTROLLERIP} "jstack ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_after.log || true
400 set +e # We do not want to create red dot just because something went wrong while fetching logs.
401 ssh "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
405 # FIXME: Unify the copy process between various scripts.
407 for i in `seq 1 ${NUM_ODL_SYSTEM}`
409 CONTROLLERIP=ODL_SYSTEM_${i}_IP
410 echo "Compressing karaf.log ${i}"
411 ssh ${!CONTROLLERIP} gzip --best /tmp/${BUNDLEFOLDER}/data/log/karaf.log
412 echo "Fetching compressed karaf.log ${i}"
413 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"
414 # TODO: Should we compress the output log file as well?
415 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"
417 # FIXME: Put member index in filename, instead of directory name.
418 mkdir -p "gclogs-${i}"
419 scp "${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/data/log/*.log" "gclogs-${i}/" && ssh ${!CONTROLLERIP} rm -f "/tmp/${BUNDLEFOLDER}/data/log/*.log"
422 echo "Examine copied files"
425 true # perhaps Jenkins is testing last exit code
427 # vim: ts=4 sw=4 sts=4 et ft=sh :