1 # Create a script to run controller inside a dynamic jenkins slave
3 if [ ${CONTROLLERSCOPE} == 'all' ]; then
4 CONTROLLERFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
8 if [ ${BUNDLEURL} == 'last' ]; then
9 NEXUSPATH="https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/distribution-karaf"
10 # Extract the BUNDLEVERSION from the pom.xml
11 BUNDLEVERSION=`xpath pom.xml '/project/version/text()' 2> /dev/null`
12 echo Bundle version is $BUNDLEVERSION
13 # Acquire the timestamp information from maven-metadata.xml
14 wget ${NEXUSPATH}/${BUNDLEVERSION}/maven-metadata.xml
15 TIMESTAMP=`xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null`
16 echo Nexus timestamp is $TIMESTAMP
17 BUNDLEFOLDER="distribution-karaf-${BUNDLEVERSION}"
18 BUNDLE="distribution-karaf-${TIMESTAMP}.zip"
19 BUNDLEURL="${NEXUSPATH}/${BUNDLEVERSION}/${BUNDLE}"
20 echo Distribution bundle URL is ${BUNDLEURL}
22 BUNDLE="$(echo "$BUNDLEURL" | awk -F '/' '{ print $(NF) }')"
23 BUNDLEFOLDER="${BUNDLE//.zip}"
26 cat > ${WORKSPACE}/controller-script.sh <<EOF
27 echo Downloading the distribution from ${BUNDLEURL}
29 wget --no-verbose ${BUNDLEURL}
31 echo Extracting the new controller...
34 echo Configuring the startup features...
35 cd ${BUNDLEFOLDER}/etc
36 export CFG=org.apache.karaf.features.cfg
37 cp \${CFG} \${CFG}.bak
38 cat \${CFG}.bak | sed "s/^featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${CONTROLLERFEATURES}/" > \${CFG}
41 echo Configuring the log...
42 export LOG=org.ops4j.pax.logging.cfg
43 cp \${LOG} \${LOG}.bak
44 cat \${LOG}.bak | sed 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/' > \${LOG}
47 echo Configure max memory...
50 cp \${MEM} \${MEM}.bak
51 cat \${MEM}.bak | sed 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/' > \${MEM}
54 echo Starting controller...
57 echo Waiting for controller to come up...
60 RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
62 if [[ \$RESP == *"200"* ]]; then
65 elif (( "\$COUNT" > "600" )); then
66 echo Timeout Controller DOWN
69 COUNT=\$(( \${COUNT} + 5 ))
71 echo waiting \$COUNT secs...
75 echo Cool down for 1 min...
78 echo Checking OSGi bundles
79 ./client 'bundle:list'
83 scp ${WORKSPACE}/controller-script.sh $CONTROLLER0:/tmp
84 ssh $CONTROLLER0 'bash /tmp/controller-script.sh'
86 echo Changing the testplan path...
87 cat ${WORKSPACE}/test/csit/testplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > testplan.txt
90 SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
92 echo Starting Robot test suites "${SUITES}" ...
93 pybot -N ${TESTPLAN} -c critical -e exclude -v CONTROLLER:${CONTROLLER0} -v MININET:${MININET0} -v MININET_USER:${USER} -v USER_HOME:${HOME} ${TESTOPTIONS} ${SUITES}
95 echo Fetching Karaf log
96 scp $CONTROLLER0:/tmp/$BUNDLEFOLDER/data/log/karaf.log .
98 # vim: ts=4 sw=4 sts=4 et ft=sh :