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