1 # Create a script to run controller inside a dynamic jenkins slave
5 if [ ${CONTROLLERSCOPE} == 'all' ]; then
6 CONTROLLERFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
10 if [ ${BUNDLEURL} == 'last' ]; then
11 NEXUSPATH="https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/distribution-${DISTRIBUTION}"
12 # Extract the BUNDLEVERSION from the pom.xml
13 BUNDLEVERSION=`xpath pom.xml '/project/version/text()' 2> /dev/null`
14 echo "Bundle version is ${BUNDLEVERSION}"
15 # Acquire the timestamp information from maven-metadata.xml
16 wget ${NEXUSPATH}/${BUNDLEVERSION}/maven-metadata.xml
17 TIMESTAMP=`xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null`
18 echo "Nexus timestamp is ${TIMESTAMP}"
19 BUNDLEFOLDER="distribution-${DISTRIBUTION}-${BUNDLEVERSION}"
20 BUNDLE="distribution-${DISTRIBUTION}-${TIMESTAMP}.zip"
21 BUNDLEURL="${NEXUSPATH}/${BUNDLEVERSION}/${BUNDLE}"
23 BUNDLE="${BUNDLEURL##*/}"
24 BUNDLEVERSION="$(basename $(dirname $BUNDLEURL))"
25 BUNDLEFOLDER="distribution-${DISTRIBUTION}-${BUNDLEVERSION}"
28 echo "Distribution bundle URL is ${BUNDLEURL}"
29 echo "Distribution bundle is ${BUNDLE}"
30 echo "Distribution folder is ${BUNDLEFOLDER}"
32 cat > ${WORKSPACE}/controller-script.sh <<EOF
33 echo "Downloading the distribution..."
35 wget --no-verbose '${BUNDLEURL}'
37 echo "Extracting the new controller..."
40 echo "Configuring the startup features..."
41 cd ${BUNDLEFOLDER}/etc
42 CFG=org.apache.karaf.features.cfg
43 cp \${CFG} \${CFG}.bak
44 cat \${CFG}.bak | sed "s/^featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${CONTROLLERFEATURES}/" > \${CFG}.1
45 cat \${CFG}.1 | sed "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%" > \${CFG}
48 echo "Configuring the log..."
49 LOG=org.ops4j.pax.logging.cfg
50 cp \${LOG} \${LOG}.bak
51 cat \${LOG}.bak | sed 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/' > \${LOG}
54 echo "Configure max memory..."
57 cp \${MEM} \${MEM}.bak
58 cat \${MEM}.bak | sed 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/' > \${MEM}
61 echo "Starting controller..."
64 echo "Waiting for controller to come up..."
67 RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
69 if [[ \$RESP == *"200"* ]]; then
72 elif (( "\$COUNT" > "600" )); then
73 echo Timeout Controller DOWN
74 echo "Dumping Karaf log..."
79 COUNT=\$(( \${COUNT} + 5 ))
81 echo waiting \$COUNT secs...
85 echo "Cool down for 1 min :)..."
88 echo "Checking OSGi bundles..."
89 ./client 'bundle:list'
93 scp ${WORKSPACE}/controller-script.sh ${CONTROLLER0}:/tmp
94 ssh ${CONTROLLER0} 'bash /tmp/controller-script.sh'
96 echo "Changing the testplan path..."
97 cat ${WORKSPACE}/test/csit/testplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > testplan.txt
100 SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
102 echo "Starting Robot test suites ${SUITES} ..."
103 pybot -N ${TESTPLAN} -c critical -e exclude --loglevel TRACE -v BUNDLEFOLDER:${BUNDLEFOLDER} -v WORKSPACE:/tmp -v CONTROLLER:${CONTROLLER0} -v MININET:${MININET0} -v MININET_USER:${USER} -v USER_HOME:${HOME} ${TESTOPTIONS} ${SUITES}
105 echo "Fetching Karaf log"
106 scp ${CONTROLLER0}:/tmp/${BUNDLEFOLDER}/data/log/karaf.log .
108 # vim: ts=4 sw=4 sts=4 et ft=sh :