Adding cluster test + some fixes
[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     if [ ${BRANCH} == 'master' ]; then
9         DISTRIBUTION="test"
10     fi
11 fi
12
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}"
26 else
27     BUNDLE="$(echo "$BUNDLEURL" | awk -F '/' '{ print $(NF) }')"
28     BUNDLEFOLDER="${BUNDLE//.zip}"
29 fi
30
31 cat > ${WORKSPACE}/controller-script.sh <<EOF
32 echo "Downloading the distribution from ${BUNDLEURL}"
33 cd /tmp
34 wget --no-verbose  ${BUNDLEURL}
35
36 echo "Extracting the new controller..."
37 unzip -q ${BUNDLE}
38
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}
44 cat \${CFG}
45
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}
50 cat \${LOG}
51
52 echo "Configure max memory..."
53 MEM=setenv
54 cd ../bin
55 cp \${MEM} \${MEM}.bak
56 cat \${MEM}.bak | sed 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/' > \${MEM}
57 cat \${MEM}
58
59 echo "Starting controller..."
60 ./start &
61
62 echo "Waiting for controller to come up..."
63 COUNT="0"
64 while true; do
65     RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
66     echo \$RESP
67     if [[ \$RESP == *"200"* ]]; then
68         echo Controller is UP
69         break
70     elif (( "\$COUNT" > "600" )); then
71         echo Timeout Controller DOWN
72         break
73     else
74         COUNT=\$(( \${COUNT} + 5 ))
75         sleep 5
76         echo waiting \$COUNT secs...
77     fi
78 done
79
80 echo "Cool down for 1 min :)..."
81 sleep 60
82
83 echo "Checking OSGi bundles..."
84 ./client 'bundle:list'
85
86 EOF
87
88 scp ${WORKSPACE}/controller-script.sh $CONTROLLER0:/tmp
89 ssh $CONTROLLER0 'bash /tmp/controller-script.sh'
90
91 echo "Changing the testplan path..."
92 cat ${WORKSPACE}/test/csit/testplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > testplan.txt
93 cat testplan.txt
94
95 SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
96
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}
99
100 echo "Fetching Karaf log"
101 scp $CONTROLLER0:/tmp/$BUNDLEFOLDER/data/log/karaf.log .
102
103 # vim: ts=4 sw=4 sts=4 et ft=sh :
104