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}"
8 if [ ${BRANCH} == 'master' ]; then
13 if [ ${BUNDLEURL} == 'last' ]; then
14 NEXUSPATH="https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/distribution-${DISTRIBUTION}"
15 # Extract the BUNDLEVERSION from the pom.xml
16 BUNDLEVERSION=`xpath pom.xml '/project/version/text()' 2> /dev/null`
17 echo "Bundle version is $BUNDLEVERSION"
18 # Acquire the timestamp information from maven-metadata.xml
19 wget ${NEXUSPATH}/${BUNDLEVERSION}/maven-metadata.xml
20 TIMESTAMP=`xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null`
21 echo "Nexus timestamp is $TIMESTAMP"
22 BUNDLEFOLDER="distribution-${DISTRIBUTION}-${BUNDLEVERSION}"
23 BUNDLE="distribution-${DISTRIBUTION}-${TIMESTAMP}.zip"
24 BUNDLEURL="${NEXUSPATH}/${BUNDLEVERSION}/${BUNDLE}"
25 echo "Distribution bundle URL is ${BUNDLEURL}"
27 BUNDLE="$(echo "$BUNDLEURL" | awk -F '/' '{ print $(NF) }')"
28 BUNDLEFOLDER="${BUNDLE//.zip}"
31 cat > ${WORKSPACE}/controller-script.sh <<EOF
32 echo "Downloading the distribution from ${BUNDLEURL}"
34 wget --no-verbose ${BUNDLEURL}
36 echo "Extracting the new controller..."
39 echo "Configuring the startup features..."
40 cd ${BUNDLEFOLDER}/etc
41 CFG=org.apache.karaf.features.cfg
42 cp \${CFG} \${CFG}.bak
43 cat \${CFG}.bak | sed "s/^featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${CONTROLLERFEATURES}/" > \${CFG}
46 echo "Configuring the log..."
47 LOG=org.ops4j.pax.logging.cfg
48 cp \${LOG} \${LOG}.bak
49 cat \${LOG}.bak | sed 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/' > \${LOG}
52 echo "Configure max memory..."
55 cp \${MEM} \${MEM}.bak
56 cat \${MEM}.bak | sed 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/' > \${MEM}
59 echo "Starting controller..."
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
74 COUNT=\$(( \${COUNT} + 5 ))
76 echo waiting \$COUNT secs...
80 echo "Cool down for 1 min :)..."
83 echo "Checking OSGi bundles..."
84 ./client 'bundle:list'
88 scp ${WORKSPACE}/controller-script.sh $CONTROLLER0:/tmp
89 ssh $CONTROLLER0 'bash /tmp/controller-script.sh'
91 echo "Changing the testplan path..."
92 cat ${WORKSPACE}/test/csit/testplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > testplan.txt
95 SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
97 echo "Starting Robot test suites ${SUITES} ..."
98 pybot -N ${TESTPLAN} -c critical -e exclude -v CONTROLLER:${CONTROLLER0} -v MININET:${MININET0} -v MININET_USER:${USER} -v USER_HOME:${HOME} ${TESTOPTIONS} ${SUITES}
100 echo "Fetching Karaf log"
101 scp $CONTROLLER0:/tmp/$BUNDLEFOLDER/data/log/karaf.log .
103 # vim: ts=4 sw=4 sts=4 et ft=sh :