Merge "GBP Vagrant setup for Ubuntu VM"
[releng/builder.git] / jjb / integration / include-raw-integration-deploy-controller-run-test.sh
1 # Activate robotframework virtualenv
2 # ${ROBOT_VENV} comes from the include-raw-integration-install-robotframework.sh
3 # script.
4 source ${ROBOT_VENV}/bin/activate
5
6 CONTROLLERMEM="2048m"
7
8 if [ ${CONTROLLERSCOPE} == 'all' ]; then
9     ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
10     CONTROLLERMEM="3072m"
11 else
12     ACTUALFEATURES="${CONTROLLERFEATURES}"
13 fi
14
15 if [ -f ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} ]; then
16     echo "scriptplan exists!!!"
17     echo "Changing the scriptplan path..."
18     cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
19     cat scriptplan.txt
20     for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
21         echo "Executing ${line}..."
22         source ${line}
23     done
24 fi
25
26 cat > ${WORKSPACE}/controller-script.sh <<EOF
27
28 echo "Changing to /tmp"
29 cd /tmp
30
31 echo "Downloading the distribution..."
32 wget --no-verbose '${ACTUALBUNDLEURL}'
33
34 echo "Extracting the new controller..."
35 unzip -q ${BUNDLE}
36
37 echo "Configuring the startup features..."
38 FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
39 sed -ie "s/featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${ACTUALFEATURES}/g" \${FEATURESCONF}
40 sed -ie "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%g" \${FEATURESCONF}
41 cat \${FEATURESCONF}
42
43 echo "Configuring the log..."
44 LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
45 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/g' \${LOGCONF}
46 cat \${LOGCONF}
47
48 echo "Configure max memory..."
49 MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
50 sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' \${MEMCONF}
51 cat \${MEMCONF}
52
53 echo "Starting controller..."
54 /tmp/${BUNDLEFOLDER}/bin/start
55
56 echo "Waiting for controller to come up..."
57 COUNT="0"
58 while true; do
59     RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
60     echo \$RESP
61     if [[ \$RESP == *"200"* ]]; then
62         echo Controller is UP
63         break
64     elif (( "\$COUNT" > "600" )); then
65         echo Timeout Controller DOWN
66         echo "Dumping Karaf log..."
67         cat /tmp/${BUNDLEFOLDER}/data/log/karaf.log
68         exit 1
69     else
70         COUNT=\$(( \${COUNT} + 5 ))
71         sleep 5
72         echo waiting \$COUNT secs...
73     fi
74 done
75
76 echo "Cool down for 1 min :)..."
77 sleep 60
78
79 echo "Checking OSGi bundles..."
80 sshpass -p karaf /tmp/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
81
82 EOF
83
84 scp ${WORKSPACE}/controller-script.sh ${CONTROLLER0}:/tmp
85 ssh ${CONTROLLER0} 'bash /tmp/controller-script.sh'
86
87 echo "Changing the testplan path..."
88 cat ${WORKSPACE}/test/csit/testplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > testplan.txt
89 cat testplan.txt
90
91 SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
92
93 echo "Starting Robot test suites ${SUITES} ..."
94 pybot -N ${TESTPLAN} -c critical -e exclude -v BUNDLEFOLDER:${BUNDLEFOLDER} -v WORKSPACE:/tmp \
95 -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} -v CONTROLLER:${CONTROLLER0} -v CONTROLLER_USER:${USER} \
96 -v MININET:${MININET0} -v MININET1:${MININET1} -v MININET2:${MININET2} -v MININET_USER:${USER} \
97 -v USER_HOME:${HOME} ${TESTOPTIONS} ${SUITES} || true
98
99 echo "Fetching Karaf log"
100 scp ${CONTROLLER0}:/tmp/${BUNDLEFOLDER}/data/log/karaf.log .
101
102 # vim: ts=4 sw=4 sts=4 et ft=sh :
103