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"
21 ACTUALFEATURES="odl-infrautils-ready,${CONTROLLERFEATURES}"
25 # Some versions of jenkins job builder result in feature list containing spaces
26 # and ending in newline. Remove all that.
27 ACTUALFEATURES=`echo "${ACTUALFEATURES}" | tr -d '\n \r'`
28 echo "ACTUALFEATURES: ${ACTUALFEATURES}"
30 # In the case that we want to install features via karaf shell, a space separated list of
31 # ACTUALFEATURES IS NEEDED
32 SPACE_SEPARATED_FEATURES=$(echo "${ACTUALFEATURES}" | tr ',' ' ')
33 echo "SPACE_SEPARATED_FEATURES: ${SPACE_SEPARATED_FEATURES}"
35 if [ -f "${WORKSPACE}/test/csit/scriptplans/${TESTPLAN}" ]; then
36 echo "scriptplan exists!!!"
37 echo "Changing the scriptplan path..."
38 cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
40 for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
41 echo "Executing ${line}..."
42 # shellcheck source=${line} disable=SC1091
47 cat > ${WORKSPACE}/configuration-script.sh <<EOF
49 source /tmp/common-functions.sh ${BUNDLEFOLDER}
51 echo "Changing to /tmp"
54 echo "Downloading the distribution..."
55 wget --progress=dot:mega '${ACTUAL_BUNDLE_URL}'
57 echo "Extracting the new controller..."
60 echo "Adding external repositories..."
61 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}
64 if [[ "$USEFEATURESBOOT" == "True" ]]; then
65 echo "Configuring the startup features..."
66 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" ${FEATURESCONF}
69 FEATURE_TEST_STRING="features-integration-test"
70 if [[ "$KARAF_VERSION" == "karaf4" ]]; then
71 FEATURE_TEST_STRING="features-test"
74 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}
77 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
78 echo "Enable the l3.fwd in custom.properties..."
79 echo "ovsdb.l3.fwd.enabled=yes" >> ${CUSTOMPROP}
83 configure_karaf_log "${KARAF_VERSION}" "${CONTROLLERDEBUGMAP}"
85 set_java_vars "${JAVA_HOME}" "${CONTROLLERMEM}"
87 echo "Listing all open ports on controller system..."
90 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
92 # Copy shard file if exists
93 if [ -f /tmp/custom_shard_config.txt ]; then
94 echo "Custom shard config exists!!!"
95 echo "Copying the shard config..."
96 cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
99 echo "Configuring cluster"
100 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 \$2
102 echo "Dump akka.conf"
105 echo "Dump modules.conf"
108 echo "Dump module-shards.conf"
109 cat ${MODULESHARDSCONF}
113 # cat > ${WORKSPACE}/configuration-script.sh <<EOF
115 # Create the startup script to be run on controller.
116 cat > ${WORKSPACE}/startup-script.sh <<EOF
118 echo "Redirecting karaf console output to karaf_console.log"
119 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
120 mkdir -p /tmp/${BUNDLEFOLDER}/data/log
122 echo "Starting controller..."
123 /tmp/${BUNDLEFOLDER}/bin/start
126 # cat > ${WORKSPACE}/startup-script.sh <<EOF
128 cat > ${WORKSPACE}/post-startup-script.sh <<EOF
130 if [[ "$USEFEATURESBOOT" != "True" ]]; then
132 # wait up to 60s for karaf port 8101 to be opened, polling every 5s
134 until [[ \$loop_count -ge 12 ]]; do
135 netstat -na | grep 8101 && break;
136 loop_count=\$[\$loop_count+1];
140 echo "going to feature:install --no-auto-refresh ${SPACE_SEPARATED_FEATURES} one at a time"
141 for feature in ${SPACE_SEPARATED_FEATURES}; do
142 sshpass -p karaf ssh -o StrictHostKeyChecking=no \
143 -o UserKnownHostsFile=/dev/null \
145 -p 8101 karaf@localhost \
146 feature:install --no-auto-refresh \$feature;
149 echo "ssh to karaf console to list -i installed features"
150 sshpass -p karaf ssh -o StrictHostKeyChecking=no \
151 -o UserKnownHostsFile=/dev/null \
153 -p 8101 karaf@localhost \
157 echo "Waiting for controller to come up..."
160 RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
162 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
163 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)"
166 if ([[ \$RESP == *"200"* ]] && ([[ "${ENABLE_HAPROXY_FOR_NEUTRON}" != "yes" ]] || [[ \$SHARD == *'"status":200'* ]])); then
167 echo Controller is UP
169 elif (( "\$COUNT" > "600" )); then
170 echo Timeout Controller DOWN
171 echo "Dumping first 500K bytes of karaf log..."
172 head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
173 echo "Dumping last 500K bytes of karaf log..."
174 tail --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
175 echo "Listing all open ports on controller system"
179 COUNT=\$(( \${COUNT} + 1 ))
181 if [[ \$((\$COUNT % 5)) == 0 ]]; then
182 echo already waited \${COUNT} seconds...
187 echo "Listing all open ports on controller system..."
190 function exit_on_log_file_message {
191 echo "looking for \"\$1\" in log file"
192 if grep --quiet "\$1" "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"; then
193 echo ABORTING: found "\$1"
194 echo "Dumping first 500K bytes of karaf log..."
195 head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
196 echo "Dumping last 500K bytes of karaf log..."
197 tail --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
202 exit_on_log_file_message 'BindException: Address already in use'
203 exit_on_log_file_message 'server is unhealthy'
206 # cat > ${WORKSPACE}/post-startup-script.sh <<EOF
208 [ "$NUM_OPENSTACK_SITES" ] || NUM_OPENSTACK_SITES=1
209 NUM_ODLS_PER_SITE=$((NUM_ODL_SYSTEM / NUM_OPENSTACK_SITES))
210 for i in `seq 1 ${NUM_OPENSTACK_SITES}`
212 # Get full list of ODL nodes for this site
214 for j in `seq 1 ${NUM_ODLS_PER_SITE}`
216 odl_ip=ODL_SYSTEM_$(((i - 1) * NUM_ODLS_PER_SITE + j))_IP
217 odl_node_list="${odl_node_list} ${!odl_ip}"
220 for j in `seq 1 ${NUM_ODLS_PER_SITE}`
222 odl_ip=ODL_SYSTEM_$(((i - 1) * NUM_ODLS_PER_SITE + j))_IP
223 # Copy over the config script to controller and execute it (parameters are used only for cluster)
224 echo "Execute the configuration script on controller ${!odl_ip} for index $j with node list ${odl_node_list}"
225 scp ${WORKSPACE}/configuration-script.sh ${!odl_ip}:/tmp
226 ssh ${!odl_ip} "bash /tmp/configuration-script.sh ${j} '${odl_node_list}'"
230 echo "Locating config plan to use..."
231 configplan_filepath="${WORKSPACE}/test/csit/configplans/${STREAMTESTPLAN}"
232 if [ ! -f "${configplan_filepath}" ]; then
233 configplan_filepath="${WORKSPACE}/test/csit/configplans/${TESTPLAN}"
236 if [ -f "${configplan_filepath}" ]; then
237 echo "configplan exists!!!"
238 echo "Changing the configplan path..."
239 cat ${configplan_filepath} | sed "s:integration:${WORKSPACE}:" > configplan.txt
241 for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' configplan.txt ); do
242 echo "Executing ${line}..."
243 # shellcheck source=${line} disable=SC1091
248 # Copy over the startup script to controller and execute it.
249 for i in `seq 1 ${NUM_ODL_SYSTEM}`
251 CONTROLLERIP=ODL_SYSTEM_${i}_IP
252 echo "Execute the startup script on controller ${!CONTROLLERIP}"
253 scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp
254 ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
258 for i in `seq 1 ${NUM_ODL_SYSTEM}`
260 CONTROLLERIP=ODL_SYSTEM_${i}_IP
261 echo "Execute the post startup script on controller ${!CONTROLLERIP}"
262 scp ${WORKSPACE}/post-startup-script.sh ${!CONTROLLERIP}:/tmp
263 ssh ${!CONTROLLERIP} "bash /tmp/post-startup-script.sh $(( seed_index++ ))"
264 if [ $(( $i % (${NUM_ODL_SYSTEM} / ${NUM_OPENSTACK_SITES}) )) == 0 ]; then
269 echo "Cool down for ${COOLDOWN_PERIOD} seconds :)..."
270 sleep ${COOLDOWN_PERIOD}
272 echo "Generating controller variables..."
273 for i in `seq 1 ${NUM_ODL_SYSTEM}`
275 CONTROLLERIP=ODL_SYSTEM_${i}_IP
276 odl_variables=${odl_variables}" -v ${CONTROLLERIP}:${!CONTROLLERIP}"
277 echo "Lets's take the karaf thread dump"
278 ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_before.log
279 pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_before.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
280 echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
281 ssh ${!CONTROLLERIP} "jstack ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_before.log || true
284 if [ ${NUM_OPENSTACK_SYSTEM} -gt 0 ]; then
285 echo "Exiting without running tests to deploy openstack for testing"
289 echo "Generating mininet variables..."
290 for i in `seq 1 ${NUM_TOOLS_SYSTEM}`
292 MININETIP=TOOLS_SYSTEM_${i}_IP
293 tools_variables=${tools_variables}" -v ${MININETIP}:${!MININETIP}"
296 echo "Locating test plan to use..."
297 testplan_filepath="${WORKSPACE}/test/csit/testplans/${STREAMTESTPLAN}"
298 if [ ! -f "${testplan_filepath}" ]; then
299 testplan_filepath="${WORKSPACE}/test/csit/testplans/${TESTPLAN}"
302 echo "Changing the testplan path..."
303 cat "${testplan_filepath}" | sed "s:integration:${WORKSPACE}:" > testplan.txt
306 # Use the testplan if specific SUITES are not defined.
307 if [ -z "${SUITES}" ]; then
308 SUITES=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
311 workpath="${WORKSPACE}/test/csit/suites"
312 for suite in ${SUITES}; do
313 fullsuite="${workpath}/${suite}"
314 if [ -z "${newsuites}" ]; then
315 newsuites+=${fullsuite}
317 newsuites+=" "${fullsuite}
323 echo "Starting Robot test suites ${SUITES} ..."
324 pybot -N ${TESTPLAN} --removekeywords wuks -c critical -e exclude -e skip_if_${DISTROSTREAM} -v BUNDLEFOLDER:${BUNDLEFOLDER} -v WORKSPACE:/tmp \
325 -v JAVA_HOME:${JAVA_HOME} -v BUNDLE_URL:${ACTUAL_BUNDLE_URL} -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
326 -v CONTROLLER:${ODL_SYSTEM_IP} -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} -v ODL_SYSTEM_1_IP:${ODL_SYSTEM_IP} \
327 -v CONTROLLER_USER:${USER} -v ODL_SYSTEM_USER:${USER} \
328 -v TOOLS_SYSTEM_IP:${TOOLS_SYSTEM_IP} -v TOOLS_SYSTEM_2_IP:${TOOLS_SYSTEM_2_IP} -v TOOLS_SYSTEM_3_IP:${TOOLS_SYSTEM_3_IP} \
329 -v TOOLS_SYSTEM_4_IP:${TOOLS_SYSTEM_4_IP} -v TOOLS_SYSTEM_5_IP:${TOOLS_SYSTEM_5_IP} -v TOOLS_SYSTEM_6_IP:${TOOLS_SYSTEM_6_IP} \
330 -v TOOLS_SYSTEM_USER:${USER} -v JDKVERSION:${JDKVERSION} -v ODL_STREAM:${DISTROSTREAM} -v NUM_ODL_SYSTEM:${NUM_ODL_SYSTEM} \
331 -v MININET:${TOOLS_SYSTEM_IP} -v MININET1:${TOOLS_SYSTEM_2_IP} -v MININET2:${TOOLS_SYSTEM_3_IP} \
332 -v MININET3:${TOOLS_SYSTEM_4_IP} -v MININET4:${TOOLS_SYSTEM_5_IP} -v MININET5:${TOOLS_SYSTEM_6_IP} \
333 -v MININET_USER:${USER} -v USER_HOME:${HOME} ${TESTOPTIONS} ${SUITES} || true
334 # FIXME: Sort (at least -v) options alphabetically.
336 echo "Examining the files in data/log and checking filesize"
337 ssh ${ODL_SYSTEM_IP} "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"
338 ssh ${ODL_SYSTEM_IP} "du -hs /tmp/${BUNDLEFOLDER}/data/log/*"
340 for i in `seq 1 ${NUM_ODL_SYSTEM}`
342 CONTROLLERIP=ODL_SYSTEM_${i}_IP
343 echo "Lets's take the karaf thread dump again..."
344 ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_after.log
345 pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_after.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
346 echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
347 ssh ${!CONTROLLERIP} "jstack ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_after.log || true
349 set +e # We do not want to create red dot just because something went wrong while fetching logs.
350 ssh "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
354 # FIXME: Unify the copy process between various scripts.
356 for i in `seq 1 ${NUM_ODL_SYSTEM}`
358 CONTROLLERIP=ODL_SYSTEM_${i}_IP
359 echo "Compressing karaf.log ${i}"
360 ssh ${!CONTROLLERIP} gzip --best /tmp/${BUNDLEFOLDER}/data/log/karaf.log
361 echo "Fetching compressed karaf.log ${i}"
362 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"
363 # TODO: Should we compress the output log file as well?
364 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"
366 # FIXME: Put member index in filename, instead of directory name.
367 mkdir -p "gclogs-${i}"
368 scp "${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/data/log/*.log" "gclogs-${i}/" && ssh ${!CONTROLLERIP} rm -f "/tmp/${BUNDLEFOLDER}/data/log/*.log"
371 echo "Examine copied files"
374 true # perhaps Jenkins is testing last exit code
376 # vim: ts=4 sw=4 sts=4 et ft=sh :