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 nodes_list=$(get_nodes_list)
37 cat > ${WORKSPACE}/configuration-script.sh <<EOF
39 source /tmp/common-functions.sh ${BUNDLEFOLDER}
41 echo "Changing to /tmp"
44 echo "Downloading the distribution..."
45 wget --progress=dot:mega '${ACTUAL_BUNDLE_URL}'
47 echo "Extracting the new controller..."
50 echo "Adding external repositories..."
51 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}
54 if [[ "$USEFEATURESBOOT" == "True" ]]; then
55 echo "Configuring the startup features..."
56 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" ${FEATURESCONF}
59 FEATURE_TEST_STRING="features-integration-test"
60 if [[ "$KARAF_VERSION" == "karaf4" ]]; then
61 FEATURE_TEST_STRING="features-test"
64 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}
65 if [[ ! -z "${REPO_URL}" ]]; then
66 sed -ie "s%featuresRepositories =%featuresRepositories = ${REPO_URL},%g" ${FEATURESCONF}
70 configure_karaf_log "${KARAF_VERSION}" "${CONTROLLERDEBUGMAP}"
72 set_java_vars "${JAVA_HOME}" "${CONTROLLERMEM}" "${MEMCONF}"
74 echo "Listing all open ports on controller system..."
77 # Copy shard file if exists
78 if [ -f /tmp/custom_shard_config.txt ]; then
79 echo "Custom shard config exists!!!"
80 echo "Copying the shard config..."
81 cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
84 echo "Configuring cluster"
85 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}
90 echo "Dump modules.conf"
93 echo "Dump module-shards.conf"
94 cat ${MODULESHARDSCONF}
97 # cat > ${WORKSPACE}/configuration-script.sh <<EOF
99 # Create the startup script to be run on controller.
100 cat > ${WORKSPACE}/startup-script.sh <<EOF
102 echo "Redirecting karaf console output to karaf_console.log"
103 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
104 mkdir -p /tmp/${BUNDLEFOLDER}/data/log
106 echo "Starting controller..."
107 /tmp/${BUNDLEFOLDER}/bin/start
110 # cat > ${WORKSPACE}/startup-script.sh <<EOF
112 cat > ${WORKSPACE}/post-startup-script.sh <<EOF
114 if [[ "$USEFEATURESBOOT" != "True" ]]; then
116 # wait up to 60s for karaf port 8101 to be opened, polling every 5s
118 until [[ \$loop_count -ge 12 ]]; do
119 netstat -na | grep 8101 && break;
120 loop_count=\$[\$loop_count+1];
124 echo "going to feature:install --no-auto-refresh ${SPACE_SEPARATED_FEATURES} one at a time"
125 for feature in ${SPACE_SEPARATED_FEATURES}; do
126 sshpass -p karaf ssh -o StrictHostKeyChecking=no \
127 -o UserKnownHostsFile=/dev/null \
129 -p 8101 karaf@localhost \
130 feature:install --no-auto-refresh \$feature;
133 echo "ssh to karaf console to list -i installed features"
134 sshpass -p karaf ssh -o StrictHostKeyChecking=no \
135 -o UserKnownHostsFile=/dev/null \
137 -p 8101 karaf@localhost \
141 echo "Waiting up to 3 minutes for controller to come up, checking every 5 seconds..."
144 grep 'org.opendaylight.infrautils.ready-impl.*System ready' /tmp/${BUNDLEFOLDER}/data/log/karaf.log
147 echo "Controller is UP"
152 # if we ended up not finding ready status in the above loop, we can output some debugs
153 grep 'org.opendaylight.infrautils.ready-impl.*System ready' /tmp/${BUNDLEFOLDER}/data/log/karaf.log
156 echo "Timeout Controller DOWN"
157 echo "Dumping first 500K bytes of karaf log..."
158 head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
159 echo "Dumping last 500K bytes of karaf log..."
160 tail --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
161 echo "Listing all open ports on controller system"
166 echo "Listing all open ports on controller system..."
169 function exit_on_log_file_message {
170 echo "looking for \"\$1\" in log file"
171 if grep --quiet "\$1" "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"; then
172 echo ABORTING: found "\$1"
173 echo "Dumping first 500K bytes of karaf log..."
174 head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
175 echo "Dumping last 500K bytes of karaf log..."
176 tail --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
181 exit_on_log_file_message 'BindException: Address already in use'
182 exit_on_log_file_message 'server is unhealthy'
185 # cat > ${WORKSPACE}/post-startup-script.sh <<EOF
187 # Copy over the configuration script and configuration files to each controller
188 # Execute the configuration script on each controller.
189 for i in `seq 1 ${NUM_ODL_SYSTEM}`
191 CONTROLLERIP=ODL_SYSTEM_${i}_IP
192 echo "Configuring member-${i} with IP address ${!CONTROLLERIP}"
193 scp ${WORKSPACE}/configuration-script.sh ${!CONTROLLERIP}:/tmp/
194 ssh ${!CONTROLLERIP} "bash /tmp/configuration-script.sh ${i}"
199 # Copy over the startup script to controller and execute it.
200 for i in `seq 1 ${NUM_ODL_SYSTEM}`
202 CONTROLLERIP=ODL_SYSTEM_${i}_IP
203 echo "Execute the startup script on controller ${!CONTROLLERIP}"
204 scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp
205 ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
209 for i in `seq 1 ${NUM_ODL_SYSTEM}`
211 CONTROLLERIP=ODL_SYSTEM_${i}_IP
212 echo "Execute the post startup script on controller ${!CONTROLLERIP}"
213 scp ${WORKSPACE}/post-startup-script.sh ${!CONTROLLERIP}:/tmp
214 ssh ${!CONTROLLERIP} "bash /tmp/post-startup-script.sh $(( seed_index++ ))"
215 if [ $(( $i % (${NUM_ODL_SYSTEM} / ${NUM_OPENSTACK_SITES}) )) == 0 ]; then
220 echo "Generating controller variables..."
221 for i in `seq 1 ${NUM_ODL_SYSTEM}`
223 CONTROLLERIP=ODL_SYSTEM_${i}_IP
224 odl_variables=${odl_variables}" -v ${CONTROLLERIP}:${!CONTROLLERIP}"
225 echo "Lets's take the karaf thread dump"
226 ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_before.log
227 pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_before.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
228 echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
229 ssh ${!CONTROLLERIP} "${JAVA_HOME}/bin/jstack -l ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_before.log || true
232 if [ ${NUM_OPENSTACK_SYSTEM} -gt 0 ]; then
233 echo "Exiting without running tests to deploy openstack for testing"
237 echo "Generating mininet variables..."
238 for i in `seq 1 ${NUM_TOOLS_SYSTEM}`
240 MININETIP=TOOLS_SYSTEM_${i}_IP
241 tools_variables=${tools_variables}" -v ${MININETIP}:${!MININETIP}"
244 echo "Locating test plan to use..."
245 testplan_filepath="${WORKSPACE}/test/csit/testplans/${STREAMTESTPLAN}"
246 if [ ! -f "${testplan_filepath}" ]; then
247 testplan_filepath="${WORKSPACE}/test/csit/testplans/${TESTPLAN}"
250 echo "Changing the testplan path..."
251 cat "${testplan_filepath}" | sed "s:integration:${WORKSPACE}:" > testplan.txt
254 # Use the testplan if specific SUITES are not defined.
255 if [ -z "${SUITES}" ]; then
256 SUITES=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
259 workpath="${WORKSPACE}/test/csit/suites"
260 for suite in ${SUITES}; do
261 fullsuite="${workpath}/${suite}"
262 if [ -z "${newsuites}" ]; then
263 newsuites+=${fullsuite}
265 newsuites+=" "${fullsuite}
271 echo "Starting Robot test suites ${SUITES} ..."
272 pybot -N ${TESTPLAN} \
273 --removekeywords wuks -c critical -e exclude -e skip_if_${DISTROSTREAM} \
274 -v BUNDLEFOLDER:${BUNDLEFOLDER} \
275 -v BUNDLE_URL:${ACTUAL_BUNDLE_URL} \
276 -v CONTROLLER:${ODL_SYSTEM_IP} \
277 -v CONTROLLER_USER:${USER} \
278 -v JAVA_HOME:${JAVA_HOME} \
279 -v JDKVERSION:${JDKVERSION} \
280 -v JENKINS_WORKSPACE:${WORKSPACE} \
281 -v MININET1:${TOOLS_SYSTEM_2_IP} \
282 -v MININET2:${TOOLS_SYSTEM_3_IP} \
283 -v MININET3:${TOOLS_SYSTEM_4_IP} \
284 -v MININET4:${TOOLS_SYSTEM_5_IP} \
285 -v MININET5:${TOOLS_SYSTEM_6_IP} \
286 -v MININET:${TOOLS_SYSTEM_IP} \
287 -v MININET_USER:${USER} \
288 -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
289 -v NUM_ODL_SYSTEM:${NUM_ODL_SYSTEM} \
290 -v NUM_TOOLS_SYSTEM:${NUM_TOOLS_SYSTEM} \
291 -v ODL_STREAM:${DISTROSTREAM} \
292 -v ODL_SYSTEM_1_IP:${ODL_SYSTEM_IP} \
293 -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} \
294 -v ODL_SYSTEM_USER:${USER} \
295 -v SUITES:"${SUITES}" \
296 -v TOOLS_SYSTEM_1_IP:${TOOLS_SYSTEM_IP} \
297 -v TOOLS_SYSTEM_2_IP:${TOOLS_SYSTEM_2_IP} \
298 -v TOOLS_SYSTEM_3_IP:${TOOLS_SYSTEM_3_IP} \
299 -v TOOLS_SYSTEM_4_IP:${TOOLS_SYSTEM_4_IP} \
300 -v TOOLS_SYSTEM_5_IP:${TOOLS_SYSTEM_5_IP} \
301 -v TOOLS_SYSTEM_6_IP:${TOOLS_SYSTEM_6_IP} \
302 -v TOOLS_SYSTEM_IP:${TOOLS_SYSTEM_IP} \
303 -v TOOLS_SYSTEM_USER:${USER} \
304 -v USER_HOME:${HOME} \
306 ${TESTOPTIONS} ${SUITES} || true
308 echo "Examining the files in data/log and checking filesize"
309 ssh ${ODL_SYSTEM_IP} "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"
310 ssh ${ODL_SYSTEM_IP} "du -hs /tmp/${BUNDLEFOLDER}/data/log/*"
312 for i in `seq 1 ${NUM_ODL_SYSTEM}`
314 CONTROLLERIP=ODL_SYSTEM_${i}_IP
315 echo "Lets's take the karaf thread dump again..."
316 ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_after.log
317 pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_after.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
318 echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
319 ssh ${!CONTROLLERIP} "${JAVA_HOME}/bin/jstack -l ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_after.log || true
321 set +e # We do not want to create red dot just because something went wrong while fetching logs.
322 ssh "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
326 # FIXME: Unify the copy process between various scripts.
328 for i in `seq 1 ${NUM_ODL_SYSTEM}`
330 CONTROLLERIP=ODL_SYSTEM_${i}_IP
331 echo "Compressing karaf.log ${i}"
332 ssh ${!CONTROLLERIP} gzip --best /tmp/${BUNDLEFOLDER}/data/log/karaf.log
333 echo "Fetching compressed karaf.log ${i}"
334 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"
335 # TODO: Should we compress the output log file as well?
336 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"
338 # FIXME: Put member index in filename, instead of directory name.
339 mkdir -p "gclogs-${i}"
340 scp "${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/data/log/*.log" "gclogs-${i}/" && ssh ${!CONTROLLERIP} rm -f "/tmp/${BUNDLEFOLDER}/data/log/*.log"
343 echo "Examine copied files"
346 true # perhaps Jenkins is testing last exit code
348 # vim: ts=4 sw=4 sts=4 et ft=sh :