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 NEXUSURL_PREFIX=${ODLNEXUSPROXY:-https://nexus.opendaylight.org}
12 if [ ${BUNDLEURL} == 'last' ]; then
13 NEXUSPATH="${NEXUSURL_PREFIX}/content/repositories/opendaylight.snapshot/org/opendaylight/integration/distribution-${DISTRIBUTION}"
14 # Extract the BUNDLEVERSION from the pom.xml
15 BUNDLEVERSION=`xpath pom.xml '/project/version/text()' 2> /dev/null`
16 echo "Bundle version is ${BUNDLEVERSION}"
17 # Acquire the timestamp information from maven-metadata.xml
18 wget ${NEXUSPATH}/${BUNDLEVERSION}/maven-metadata.xml
19 TIMESTAMP=`xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null`
20 echo "Nexus timestamp is ${TIMESTAMP}"
21 BUNDLEFOLDER="distribution-${DISTRIBUTION}-${BUNDLEVERSION}"
22 BUNDLE="distribution-${DISTRIBUTION}-${TIMESTAMP}.zip"
23 BUNDLEURL="${NEXUSPATH}/${BUNDLEVERSION}/${BUNDLE}"
25 BUNDLE="${BUNDLEURL##*/}"
26 BUNDLEVERSION="$(basename $(dirname $BUNDLEURL))"
27 BUNDLEFOLDER="distribution-${DISTRIBUTION}-${BUNDLEVERSION}"
30 echo "Distribution bundle URL is ${BUNDLEURL}"
31 echo "Distribution bundle is ${BUNDLE}"
32 echo "Distribution folder is ${BUNDLEFOLDER}"
34 cat > ${WORKSPACE}/controller-script.sh <<EOF
35 echo "Downloading the distribution..."
37 wget --no-verbose '${BUNDLEURL}'
39 echo "Extracting the new controller..."
42 echo "Configuring the startup features..."
43 cd ${BUNDLEFOLDER}/etc
44 CFG=org.apache.karaf.features.cfg
45 cp \${CFG} \${CFG}.bak
46 cat \${CFG}.bak | sed "s/^featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${CONTROLLERFEATURES}/" > \${CFG}.1
47 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}
50 echo "Configuring the log..."
51 LOG=org.ops4j.pax.logging.cfg
52 cp \${LOG} \${LOG}.bak
53 cat \${LOG}.bak | sed 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/' > \${LOG}
56 echo "Configure max memory..."
59 cp \${MEM} \${MEM}.bak
60 cat \${MEM}.bak | sed 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/' > \${MEM}
63 echo "Starting controller..."
66 echo "Waiting for controller to come up..."
69 RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
71 if [[ \$RESP == *"200"* ]]; then
74 elif (( "\$COUNT" > "600" )); then
75 echo Timeout Controller DOWN
76 echo "Dumping Karaf log..."
81 COUNT=\$(( \${COUNT} + 5 ))
83 echo waiting \$COUNT secs...
87 echo "Cool down for 1 min :)..."
90 echo "Checking OSGi bundles..."
91 ./client 'bundle:list'
95 scp ${WORKSPACE}/controller-script.sh ${CONTROLLER0}:/tmp
96 ssh ${CONTROLLER0} 'bash /tmp/controller-script.sh'
98 echo "Changing the testplan path..."
99 cat ${WORKSPACE}/test/csit/testplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > testplan.txt
102 SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
104 echo "Starting Robot test suites ${SUITES} ..."
105 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}
107 echo "Fetching Karaf log"
108 scp ${CONTROLLER0}:/tmp/${BUNDLEFOLDER}/data/log/karaf.log .
110 # vim: ts=4 sw=4 sts=4 et ft=sh :