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}"
14 ACTUALFEATURES="${CONTROLLERFEATURES}"
17 # Some versions of jenkins job builder result in feature list containing spaces
18 # and ending in newline. Remove all that.
19 ACTUALFEATURES=`echo "${ACTUALFEATURES}" | tr -d '\n \r'`
21 if [ -f ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} ]; then
22 echo "scriptplan exists!!!"
23 echo "Changing the scriptplan path..."
24 cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
26 for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
27 echo "Executing ${line}..."
32 cat > ${WORKSPACE}/controller-script.sh <<EOF
34 echo "Changing to /tmp"
37 echo "Downloading the distribution..."
38 wget --no-verbose '${ACTUALBUNDLEURL}'
40 echo "Extracting the new controller..."
43 echo "Configuring the startup features..."
44 FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
45 sed -ie "s/featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${ACTUALFEATURES}/g" \${FEATURESCONF}
46 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}
49 echo "Configuring the log..."
50 LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
51 sed -ie 's/log4j.appender.out.maxBackupIndex=10/log4j.appender.out.maxBackupIndex=1/g' \${LOGCONF}
52 # FIXME: Make log size limit configurable from build parameter.
53 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=100GB/g' \${LOGCONF}
56 echo "Configure max memory..."
57 MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
58 sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' \${MEMCONF}
61 echo "Listing all open ports on controller system..."
64 if [ ${JDKVERSION} == 'openjdk8' ]; then
65 echo "Setting the JRE Version to 8"
66 # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
67 # sudo /usr/sbin/alternatives --set java /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-2.b27.el7_1.x86_64/jre/bin/java
68 export JAVA_HOME=/usr/lib/jvm/java-1.8.0
69 elif [ ${JDKVERSION} == 'openjdk7' ]; then
70 echo "Setting the JRE Version to 7"
71 # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
72 # sudo /usr/sbin/alternatives --set java /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85-2.6.1.2.el7_1.x86_64/jre/bin/java
73 export JAVA_HOME=/usr/lib/jvm/java-1.7.0
75 echo "JAVA_HOME is \${JAVA_HOME}"
76 # Did you know that in HERE documents, single quote is an ordinary character, but backticks are still executing?
77 JAVA_RESOLVED=\`readlink -e "\${JAVA_HOME}/bin/java"\`
78 echo "Java binary pointed at by JAVA_HOME: \${JAVA_RESOLVED}"
79 echo "JDK default version ..."
82 echo "Starting controller..."
83 /tmp/${BUNDLEFOLDER}/bin/start
85 echo "Waiting for controller to come up..."
88 RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
90 if [[ \$RESP == *"200"* ]]; then
93 elif (( "\$COUNT" > "600" )); then
94 echo Timeout Controller DOWN
95 echo "Dumping first 500K bytes of karaf log..."
96 head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
97 echo "Dumping last 500K bytes of karaf log..."
98 tail --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
99 echo "Listing all open ports on controller system"
103 COUNT=\$(( \${COUNT} + 5 ))
105 echo waiting \$COUNT secs...
109 echo "Cool down for ${COOLDOWN_PERIOD} seconds :)..."
110 sleep ${COOLDOWN_PERIOD}
112 echo "Listing all open ports on controller system..."
115 function exit_on_log_file_message {
116 echo "looking for \"\$1\" in log file"
117 if grep --quiet "\$1" /tmp/${BUNDLEFOLDER}/data/log/karaf.log; then
118 echo ABORTING: found "\$1"
119 echo "Dumping first 500K bytes of karaf log..."
120 head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
121 echo "Dumping last 500K bytes of karaf log..."
122 tail --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
127 exit_on_log_file_message 'BindException: Address already in use'
128 exit_on_log_file_message 'server is unhealthy'
132 scp ${WORKSPACE}/controller-script.sh ${ODL_SYSTEM_IP}:/tmp
133 ssh ${ODL_SYSTEM_IP} 'bash /tmp/controller-script.sh'
135 echo "Changing the testplan path..."
136 cat ${WORKSPACE}/test/csit/testplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > testplan.txt
139 SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
141 echo "Starting Robot test suites ${SUITES} ..."
142 pybot -N ${TESTPLAN} -c critical -e exclude -v BUNDLEFOLDER:${BUNDLEFOLDER} -v WORKSPACE:/tmp \
143 -v BUNDLE_URL:${ACTUALBUNDLEURL} -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
144 -v CONTROLLER:${ODL_SYSTEM_IP} -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} -v CONTROLLER_USER:${USER} -v ODL_SYSTEM_USER:${USER} \
145 -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} \
146 -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} \
147 -v TOOLS_SYSTEM_USER:${USER} -v JDKVERSION:${JDKVERSION} -v ODL_STREAM:${DISTROSTREAM} \
148 -v MININET:${TOOLS_SYSTEM_IP} -v MININET1:${TOOLS_SYSTEM_2_IP} -v MININET2:${TOOLS_SYSTEM_3_IP} \
149 -v MININET3:${TOOLS_SYSTEM_4_IP} -v MININET4:${TOOLS_SYSTEM_5_IP} -v MININET5:${TOOLS_SYSTEM_6_IP} \
150 -v MININET_USER:${USER} -v USER_HOME:${HOME} ${TESTOPTIONS} ${SUITES} || true
151 # FIXME: Sort (at least -v) options alphabetically.
153 echo "Killing ODL and fetching Karaf log..."
154 set +e # We do not want to create red dot just because something went wrong while fetching logs.
155 ssh "${ODL_SYSTEM_IP}" tail --bytes=1M "/tmp/${BUNDLEFOLDER}/data/log/karaf.log" > "karaf.log"
156 ssh "${ODL_SYSTEM_IP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
158 ssh "${ODL_SYSTEM_IP}" xz -9ekvv "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
159 scp "${ODL_SYSTEM_IP}:/tmp/${BUNDLEFOLDER}/data/log/karaf.log.xz" .
160 true # perhaps Jenkins is testing last exit code
162 # vim: ts=4 sw=4 sts=4 et ft=sh :