1 #@IgnoreInspection BashAddShebang
2 # Activate robotframework virtualenv
3 # ${ROBOT_VENV} comes from the include-raw-integration-install-robotframework.sh
5 source ${ROBOT_VENV}/bin/activate
9 if [ ${CONTROLLERSCOPE} == 'all' ]; then
10 ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
13 ACTUALFEATURES="${CONTROLLERFEATURES}"
16 if [ -f ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} ]; then
17 echo "scriptplan exists!!!"
18 echo "Changing the scriptplan path..."
19 cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
21 for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
22 echo "Executing ${line}..."
27 cat > ${WORKSPACE}/controller-script.sh <<EOF
29 echo "Changing to /tmp"
32 echo "Downloading the distribution..."
33 wget --no-verbose '${ACTUALBUNDLEURL}'
35 echo "Extracting the new controller..."
38 echo "Configuring the startup features..."
39 FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
40 sed -ie "s/featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${ACTUALFEATURES}/g" \${FEATURESCONF}
41 sed -ie "s%mvn:org.opendaylight.integration/features-integration-index/${BUNDLEVERSION}/xml/features%mvn:org.opendaylight.integration/features-integration-index/${BUNDLEVERSION}/xml/features,mvn:org.opendaylight.integration/features-integration-test/${BUNDLEVERSION}/xml/features%g" \${FEATURESCONF}
44 echo "Configuring the log..."
45 LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
46 sed -ie 's/log4j.appender.out.maxBackupIndex=10/log4j.appender.out.maxBackupIndex=1/g' \${LOGCONF}
47 # FIXME: Make log size limit configurable from build parameter.
48 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=100GB/g' \${LOGCONF}
51 echo "Configure max memory..."
52 MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
53 sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' \${MEMCONF}
56 echo "Listing all open ports on controller system..."
59 echo "Starting controller..."
60 /tmp/${BUNDLEFOLDER}/bin/start
62 echo "Waiting for controller to come up..."
65 RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
67 if [[ \$RESP == *"200"* ]]; then
70 elif (( "\$COUNT" > "600" )); then
71 echo Timeout Controller DOWN
72 echo "Dumping Karaf log..."
73 head --bytes=1M "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
74 echo "Listing all open ports on controller system"
78 COUNT=\$(( \${COUNT} + 5 ))
80 echo waiting \$COUNT secs...
84 echo "Cool down for 1 min :)..."
87 echo "Checking OSGi bundles..."
88 sshpass -p karaf /tmp/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
90 echo "Listing all open ports on controller system..."
93 function exit_on_log_file_message {
94 echo "looking for \"\$1\" in log file"
95 if grep --quiet "\$1" /tmp/${BUNDLEFOLDER}/data/log/karaf.log; then
96 echo ABORTING: found "\$1"
97 echo "Dumping Karaf log..."
98 head --bytes=1M "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
103 exit_on_log_file_message 'BindException: Address already in use'
104 exit_on_log_file_message 'server is unhealthy'
108 scp ${WORKSPACE}/controller-script.sh ${ODL_SYSTEM_IP}:/tmp
109 ssh ${ODL_SYSTEM_IP} 'bash /tmp/controller-script.sh'
111 echo "Changing the testplan path..."
112 cat ${WORKSPACE}/test/csit/testplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > testplan.txt
115 SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
117 echo "Starting Robot test suites ${SUITES} ..."
118 pybot -N ${TESTPLAN} -c critical -e exclude -v BUNDLEFOLDER:${BUNDLEFOLDER} -v WORKSPACE:/tmp \
119 -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
120 -v CONTROLLER:${ODL_SYSTEM_IP} -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} -v CONTROLLER_USER:${USER} -v ODL_SYSTEM_USER:${USER} \
121 -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} \
122 -v TOOLS_SYSTEM_USER:${USER} \
123 -v MININET:${TOOLS_SYSTEM_IP} -v MININET1:${TOOLS_SYSTEM_2_IP} -v MININET2:${TOOLS_SYSTEM_3_IP} -v MININET_USER:${USER} \
124 -v USER_HOME:${HOME} ${TESTOPTIONS} ${SUITES} || true
126 echo "Killing ODL and fetching Karaf log..."
127 set +e # We do not want to create red dot just because something went wrong while fetching logs.
128 ssh "${ODL_SYSTEM_IP}" head --bytes=1M "/tmp/${BUNDLEFOLDER}/data/log/karaf.log" > "karaf.log"
129 ssh "${ODL_SYSTEM_IP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
131 ssh "${ODL_SYSTEM_IP}" xz -9ekvv "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
132 scp "${ODL_SYSTEM_IP}:/tmp/${BUNDLEFOLDER}/data/log/karaf.log.xz" .
133 true # perhaps Jenkins is testing last exit code
135 # vim: ts=4 sw=4 sts=4 et ft=sh :