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=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}
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}/${BUNDLE_VERSION}/xml/features,mvn:org.apache.karaf.decanter/apache-karaf-decanter/1.0.0/xml/features,%g" ${FEATURESCONF}
73 if [[ ! -z "${REPO_URL}" ]]; then
74 sed -ie "s%featuresRepositories =%featuresRepositories = ${REPO_URL},%g" ${FEATURESCONF}
78 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
79 echo "Enable the l3.fwd in custom.properties..."
80 echo "ovsdb.l3.fwd.enabled=yes" >> ${CUSTOMPROP}
84 configure_karaf_log "${KARAF_VERSION}" "${CONTROLLERDEBUGMAP}"
86 set_java_vars "${JAVA_HOME}" "${CONTROLLERMEM}" "${MEMCONF}"
88 echo "Listing all open ports on controller system..."
91 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
93 # Copy shard file if exists
94 if [ -f /tmp/custom_shard_config.txt ]; then
95 echo "Custom shard config exists!!!"
96 echo "Copying the shard config..."
97 cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
100 echo "Configuring cluster"
101 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 \$2
103 echo "Dump akka.conf"
106 echo "Dump modules.conf"
109 echo "Dump module-shards.conf"
110 cat ${MODULESHARDSCONF}
114 # cat > ${WORKSPACE}/configuration-script.sh <<EOF
116 # Create the startup script to be run on controller.
117 cat > ${WORKSPACE}/startup-script.sh <<EOF
119 echo "Redirecting karaf console output to karaf_console.log"
120 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
121 mkdir -p /tmp/${BUNDLEFOLDER}/data/log
123 echo "Starting controller..."
124 /tmp/${BUNDLEFOLDER}/bin/start
127 # cat > ${WORKSPACE}/startup-script.sh <<EOF
129 cat > ${WORKSPACE}/post-startup-script.sh <<EOF
131 if [[ "$USEFEATURESBOOT" != "True" ]]; then
133 # wait up to 60s for karaf port 8101 to be opened, polling every 5s
135 until [[ \$loop_count -ge 12 ]]; do
136 netstat -na | grep 8101 && break;
137 loop_count=\$[\$loop_count+1];
141 echo "going to feature:install --no-auto-refresh ${SPACE_SEPARATED_FEATURES} one at a time"
142 for feature in ${SPACE_SEPARATED_FEATURES}; do
143 sshpass -p karaf ssh -o StrictHostKeyChecking=no \
144 -o UserKnownHostsFile=/dev/null \
146 -p 8101 karaf@localhost \
147 feature:install --no-auto-refresh \$feature;
150 echo "ssh to karaf console to list -i installed features"
151 sshpass -p karaf ssh -o StrictHostKeyChecking=no \
152 -o UserKnownHostsFile=/dev/null \
154 -p 8101 karaf@localhost \
158 echo "Waiting up to 3 minutes for controller to come up, checking every 5 seconds..."
161 grep 'org.opendaylight.infrautils.ready-impl.*System ready' /tmp/${BUNDLEFOLDER}/data/log/karaf.log
164 echo "Controller is UP"
169 # if we ended up not finding ready status in the above loop, we can output some debugs
170 grep 'org.opendaylight.infrautils.ready-impl.*System ready' /tmp/${BUNDLEFOLDER}/data/log/karaf.log
173 echo "Timeout Controller DOWN"
174 echo "Dumping first 500K bytes of karaf log..."
175 head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
176 echo "Dumping last 500K bytes of karaf log..."
177 tail --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
178 echo "Listing all open ports on controller system"
183 echo "Listing all open ports on controller system..."
186 function exit_on_log_file_message {
187 echo "looking for \"\$1\" in log file"
188 if grep --quiet "\$1" "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"; then
189 echo ABORTING: found "\$1"
190 echo "Dumping first 500K bytes of karaf log..."
191 head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
192 echo "Dumping last 500K bytes of karaf log..."
193 tail --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
198 exit_on_log_file_message 'BindException: Address already in use'
199 exit_on_log_file_message 'server is unhealthy'
202 # cat > ${WORKSPACE}/post-startup-script.sh <<EOF
204 [ "$NUM_OPENSTACK_SITES" ] || NUM_OPENSTACK_SITES=1
205 NUM_ODLS_PER_SITE=$((NUM_ODL_SYSTEM / NUM_OPENSTACK_SITES))
206 for i in `seq 1 ${NUM_OPENSTACK_SITES}`
208 # Get full list of ODL nodes for this site
210 for j in `seq 1 ${NUM_ODLS_PER_SITE}`
212 odl_ip=ODL_SYSTEM_$(((i - 1) * NUM_ODLS_PER_SITE + j))_IP
213 odl_node_list="${odl_node_list} ${!odl_ip}"
216 for j in `seq 1 ${NUM_ODLS_PER_SITE}`
218 odl_ip=ODL_SYSTEM_$(((i - 1) * NUM_ODLS_PER_SITE + j))_IP
219 # Copy over the config script to controller and execute it (parameters are used only for cluster)
220 echo "Execute the configuration script on controller ${!odl_ip} for index $j with node list ${odl_node_list}"
221 scp ${WORKSPACE}/configuration-script.sh ${!odl_ip}:/tmp
222 ssh ${!odl_ip} "bash /tmp/configuration-script.sh ${j} '${odl_node_list}'"
226 echo "Locating config plan to use..."
227 configplan_filepath="${WORKSPACE}/test/csit/configplans/${STREAMTESTPLAN}"
228 if [ ! -f "${configplan_filepath}" ]; then
229 configplan_filepath="${WORKSPACE}/test/csit/configplans/${TESTPLAN}"
232 if [ -f "${configplan_filepath}" ]; then
233 echo "configplan exists!!!"
234 echo "Changing the configplan path..."
235 cat ${configplan_filepath} | sed "s:integration:${WORKSPACE}:" > configplan.txt
237 for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' configplan.txt ); do
238 echo "Executing ${line}..."
239 # shellcheck source=${line} disable=SC1091
244 # Copy over the startup script to controller and execute it.
245 for i in `seq 1 ${NUM_ODL_SYSTEM}`
247 CONTROLLERIP=ODL_SYSTEM_${i}_IP
248 echo "Execute the startup script on controller ${!CONTROLLERIP}"
249 scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp
250 ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
254 for i in `seq 1 ${NUM_ODL_SYSTEM}`
256 CONTROLLERIP=ODL_SYSTEM_${i}_IP
257 echo "Execute the post startup script on controller ${!CONTROLLERIP}"
258 scp ${WORKSPACE}/post-startup-script.sh ${!CONTROLLERIP}:/tmp
259 ssh ${!CONTROLLERIP} "bash /tmp/post-startup-script.sh $(( seed_index++ ))"
260 if [ $(( $i % (${NUM_ODL_SYSTEM} / ${NUM_OPENSTACK_SITES}) )) == 0 ]; then
265 echo "Generating controller variables..."
266 for i in `seq 1 ${NUM_ODL_SYSTEM}`
268 CONTROLLERIP=ODL_SYSTEM_${i}_IP
269 odl_variables=${odl_variables}" -v ${CONTROLLERIP}:${!CONTROLLERIP}"
270 echo "Lets's take the karaf thread dump"
271 ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_before.log
272 pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_before.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
273 echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
274 ssh ${!CONTROLLERIP} "jstack ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_before.log || true
277 if [ ${NUM_OPENSTACK_SYSTEM} -gt 0 ]; then
278 echo "Exiting without running tests to deploy openstack for testing"
282 echo "Generating mininet variables..."
283 for i in `seq 1 ${NUM_TOOLS_SYSTEM}`
285 MININETIP=TOOLS_SYSTEM_${i}_IP
286 tools_variables=${tools_variables}" -v ${MININETIP}:${!MININETIP}"
289 echo "Locating test plan to use..."
290 testplan_filepath="${WORKSPACE}/test/csit/testplans/${STREAMTESTPLAN}"
291 if [ ! -f "${testplan_filepath}" ]; then
292 testplan_filepath="${WORKSPACE}/test/csit/testplans/${TESTPLAN}"
295 echo "Changing the testplan path..."
296 cat "${testplan_filepath}" | sed "s:integration:${WORKSPACE}:" > testplan.txt
299 # Use the testplan if specific SUITES are not defined.
300 if [ -z "${SUITES}" ]; then
301 SUITES=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
304 workpath="${WORKSPACE}/test/csit/suites"
305 for suite in ${SUITES}; do
306 fullsuite="${workpath}/${suite}"
307 if [ -z "${newsuites}" ]; then
308 newsuites+=${fullsuite}
310 newsuites+=" "${fullsuite}
316 echo "Starting Robot test suites ${SUITES} ..."
317 pybot -N ${TESTPLAN} \
318 --removekeywords wuks -c critical -e exclude -e skip_if_${DISTROSTREAM} \
319 -v BUNDLEFOLDER:${BUNDLEFOLDER} \
320 -v BUNDLE_URL:${ACTUAL_BUNDLE_URL} \
321 -v CONTROLLER:${ODL_SYSTEM_IP} \
322 -v CONTROLLER_USER:${USER} \
323 -v JAVA_HOME:${JAVA_HOME} \
324 -v JDKVERSION:${JDKVERSION} \
325 -v JENKINS_WORKSPACE:${WORKSPACE} \
326 -v MININET1:${TOOLS_SYSTEM_2_IP} \
327 -v MININET2:${TOOLS_SYSTEM_3_IP} \
328 -v MININET3:${TOOLS_SYSTEM_4_IP} \
329 -v MININET4:${TOOLS_SYSTEM_5_IP} \
330 -v MININET5:${TOOLS_SYSTEM_6_IP} \
331 -v MININET:${TOOLS_SYSTEM_IP} \
332 -v MININET_USER:${USER} \
333 -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
334 -v NUM_ODL_SYSTEM:${NUM_ODL_SYSTEM} \
335 -v ODL_STREAM:${DISTROSTREAM} \
336 -v ODL_SYSTEM_1_IP:${ODL_SYSTEM_IP} \
337 -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} \
338 -v ODL_SYSTEM_USER:${USER} \
339 -v TOOLS_SYSTEM_1_IP:${TOOLS_SYSTEM_IP} \
340 -v TOOLS_SYSTEM_2_IP:${TOOLS_SYSTEM_2_IP} \
341 -v TOOLS_SYSTEM_3_IP:${TOOLS_SYSTEM_3_IP} \
342 -v TOOLS_SYSTEM_4_IP:${TOOLS_SYSTEM_4_IP} \
343 -v TOOLS_SYSTEM_5_IP:${TOOLS_SYSTEM_5_IP} \
344 -v TOOLS_SYSTEM_6_IP:${TOOLS_SYSTEM_6_IP} \
345 -v TOOLS_SYSTEM_IP:${TOOLS_SYSTEM_IP} \
346 -v TOOLS_SYSTEM_USER:${USER} \
347 -v USER_HOME:${HOME} \
349 ${TESTOPTIONS} ${SUITES} || true
351 echo "Examining the files in data/log and checking filesize"
352 ssh ${ODL_SYSTEM_IP} "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"
353 ssh ${ODL_SYSTEM_IP} "du -hs /tmp/${BUNDLEFOLDER}/data/log/*"
355 for i in `seq 1 ${NUM_ODL_SYSTEM}`
357 CONTROLLERIP=ODL_SYSTEM_${i}_IP
358 echo "Lets's take the karaf thread dump again..."
359 ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_after.log
360 pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_after.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
361 echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
362 ssh ${!CONTROLLERIP} "jstack ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_after.log || true
364 set +e # We do not want to create red dot just because something went wrong while fetching logs.
365 ssh "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
369 # FIXME: Unify the copy process between various scripts.
371 for i in `seq 1 ${NUM_ODL_SYSTEM}`
373 CONTROLLERIP=ODL_SYSTEM_${i}_IP
374 echo "Compressing karaf.log ${i}"
375 ssh ${!CONTROLLERIP} gzip --best /tmp/${BUNDLEFOLDER}/data/log/karaf.log
376 echo "Fetching compressed karaf.log ${i}"
377 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"
378 # TODO: Should we compress the output log file as well?
379 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"
381 # FIXME: Put member index in filename, instead of directory name.
382 mkdir -p "gclogs-${i}"
383 scp "${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/data/log/*.log" "gclogs-${i}/" && ssh ${!CONTROLLERIP} rm -f "/tmp/${BUNDLEFOLDER}/data/log/*.log"
386 echo "Examine copied files"
389 true # perhaps Jenkins is testing last exit code
391 # vim: ts=4 sw=4 sts=4 et ft=sh :