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="$(echo ${BUNDLEURL} | awk -F '/' '{ print $(NF) }')"
26 echo "Finding out Bundle folder..."
27 wget --no-verbose ${BUNDLEURL}
28 BUNDLEFOLDER="$(unzip -qql ${BUNDLE} | head -n1 | tr -s ' ' | cut -d' ' -f5- | rev | cut -c 2- | rev)"
32 echo "Distribution bundle URL is ${BUNDLEURL}"
33 echo "Distribution bundle is ${BUNDLE}"
34 echo "Distribution folder is ${BUNDLEFOLDER}"
36 cat > ${WORKSPACE}/controller-script.sh <<EOF
37 echo "Downloading the distribution from ${BUNDLEURL}"
39 wget --no-verbose ${BUNDLEURL}
41 echo "Extracting the new controller..."
44 echo "Configuring the startup features..."
45 cd ${BUNDLEFOLDER}/etc
46 CFG=org.apache.karaf.features.cfg
47 cp \${CFG} \${CFG}.bak
48 cat \${CFG}.bak | sed "s/^featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${CONTROLLERFEATURES}/" > \${CFG}.1
49 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}
52 echo "Configuring the log..."
53 LOG=org.ops4j.pax.logging.cfg
54 cp \${LOG} \${LOG}.bak
55 cat \${LOG}.bak | sed 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/' > \${LOG}
58 echo "Configure max memory..."
61 cp \${MEM} \${MEM}.bak
62 cat \${MEM}.bak | sed 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/' > \${MEM}
65 echo "Starting controller..."
68 echo "Waiting for controller to come up..."
71 RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
73 if [[ \$RESP == *"200"* ]]; then
76 elif (( "\$COUNT" > "600" )); then
77 echo Timeout Controller DOWN
78 echo "Dumping Karaf log..."
83 COUNT=\$(( \${COUNT} + 5 ))
85 echo waiting \$COUNT secs...
89 echo "Cool down for 1 min :)..."
92 echo "Checking OSGi bundles..."
93 ./client 'bundle:list'
97 scp ${WORKSPACE}/controller-script.sh ${CONTROLLER0}:/tmp
98 ssh ${CONTROLLER0} 'bash /tmp/controller-script.sh'
100 echo "Changing the testplan path..."
101 cat ${WORKSPACE}/test/csit/testplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > testplan.txt
104 SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
106 echo "Starting Robot test suites ${SUITES} ..."
107 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}
109 echo "Fetching Karaf log"
110 scp ${CONTROLLER0}:/tmp/${BUNDLEFOLDER}/data/log/karaf.log .
112 # vim: ts=4 sw=4 sts=4 et ft=sh :