Adding patch test job + file reorg:
[releng/builder.git] / jjb / integration / include-raw-integration-deploy-controller-run-test.sh
1 # Create a script to run controller inside a dynamic jenkins slave
2 CONTROLLERMEM="2048m"
3 DISTRIBUTION="karaf"
4
5 if [ ${CONTROLLERSCOPE} == 'all' ]; then
6     CONTROLLERFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
7     CONTROLLERMEM="3072m"
8 fi
9
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}"
22 else
23     BUNDLE="${BUNDLEURL##*/}"
24     BUNDLEVERSION="$(basename $(dirname $BUNDLEURL))"
25     BUNDLEFOLDER="distribution-${DISTRIBUTION}-${BUNDLEVERSION}"
26 fi
27
28 echo "Distribution bundle URL is ${BUNDLEURL}"
29 echo "Distribution bundle is ${BUNDLE}"
30 echo "Distribution folder is ${BUNDLEFOLDER}"
31
32 cat > ${WORKSPACE}/controller-script.sh <<EOF
33 echo "Downloading the distribution..."
34 cd /tmp
35 wget --no-verbose '${BUNDLEURL}'
36
37 echo "Extracting the new controller..."
38 unzip -q ${BUNDLE}
39
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}
46 cat \${CFG}
47
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}
52 cat \${LOG}
53
54 echo "Configure max memory..."
55 MEM=setenv
56 cd ../bin
57 cp \${MEM} \${MEM}.bak
58 cat \${MEM}.bak | sed 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/' > \${MEM}
59 cat \${MEM}
60
61 echo "Starting controller..."
62 ./start &
63
64 echo "Waiting for controller to come up..."
65 COUNT="0"
66 while true; do
67     RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
68     echo \$RESP
69     if [[ \$RESP == *"200"* ]]; then
70         echo Controller is UP
71         break
72     elif (( "\$COUNT" > "600" )); then
73         echo Timeout Controller DOWN
74         echo "Dumping Karaf log..."
75         cd ../data/log
76         cat karaf.log
77         exit 1
78     else
79         COUNT=\$(( \${COUNT} + 5 ))
80         sleep 5
81         echo waiting \$COUNT secs...
82     fi
83 done
84
85 echo "Cool down for 1 min :)..."
86 sleep 60
87
88 echo "Checking OSGi bundles..."
89 ./client 'bundle:list'
90
91 EOF
92
93 scp ${WORKSPACE}/controller-script.sh ${CONTROLLER0}:/tmp
94 ssh ${CONTROLLER0} 'bash /tmp/controller-script.sh'
95
96 echo "Changing the testplan path..."
97 cat ${WORKSPACE}/test/csit/testplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > testplan.txt
98 cat testplan.txt
99
100 SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
101
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}
104
105 echo "Fetching Karaf log"
106 scp ${CONTROLLER0}:/tmp/${BUNDLEFOLDER}/data/log/karaf.log .
107
108 # vim: ts=4 sw=4 sts=4 et ft=sh :
109