Step 2: Change csit job templates to download 2 repositories
[releng/builder.git] / jjb / integration / include-raw-integration-deploy-controller-run-test.sh
1 export 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     export BUNDLEVERSION=`xpath distribution/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     export BUNDLEFOLDER="distribution-karaf-${BUNDLEVERSION}"
21     export BUNDLE="distribution-karaf-${TIMESTAMP}.zip"
22     export ACTUALBUNDLEURL="${NEXUSPATH}/${BUNDLEVERSION}/${BUNDLE}"
23 else
24     export ACTUALBUNDLEURL="${BUNDLEURL}"
25     export BUNDLE="${BUNDLEURL##*/}"
26     export BUNDLEVERSION="$(basename $(dirname $BUNDLEURL))"
27     export 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 if [ -f ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} ]; then
37     echo "scriptplan exists!!!"
38     echo "Changing the scriptplan path..."
39     cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
40     cat scriptplan.txt
41     for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
42         echo "Executing ${line}..."
43         source ${line}
44     done
45 fi
46
47 cat > ${WORKSPACE}/controller-script.sh <<EOF
48
49 echo "Changing to /tmp"
50 cd /tmp
51
52 echo "Downloading the distribution..."
53 wget --no-verbose '${ACTUALBUNDLEURL}'
54
55 echo "Extracting the new controller..."
56 unzip -q ${BUNDLE}
57
58 echo "Configuring the startup features..."
59 FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
60 sed -ie "s/featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${ACTUALFEATURES}/g" \${FEATURESCONF}
61 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}
62 cat \${FEATURESCONF}
63
64 echo "Configuring the log..."
65 LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
66 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/g' \${LOGCONF}
67 cat \${LOGCONF}
68
69 echo "Configure max memory..."
70 MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
71 sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' \${MEMCONF}
72 cat \${MEMCONF}
73
74 echo "Starting controller..."
75 /tmp/${BUNDLEFOLDER}/bin/start
76
77 echo "Waiting for controller to come up..."
78 COUNT="0"
79 while true; do
80     RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
81     echo \$RESP
82     if [[ \$RESP == *"200"* ]]; then
83         echo Controller is UP
84         break
85     elif (( "\$COUNT" > "600" )); then
86         echo Timeout Controller DOWN
87         echo "Dumping Karaf log..."
88         cat /tmp/${BUNDLEFOLDER}/data/log/karaf.log
89         exit 1
90     else
91         COUNT=\$(( \${COUNT} + 5 ))
92         sleep 5
93         echo waiting \$COUNT secs...
94     fi
95 done
96
97 echo "Cool down for 1 min :)..."
98 sleep 60
99
100 echo "Checking OSGi bundles..."
101 sshpass -p karaf /tmp/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
102
103 EOF
104
105 scp ${WORKSPACE}/controller-script.sh ${CONTROLLER0}:/tmp
106 ssh ${CONTROLLER0} 'bash /tmp/controller-script.sh'
107
108 echo "Changing the testplan path..."
109 cat ${WORKSPACE}/test/csit/testplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > testplan.txt
110 cat testplan.txt
111
112 SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
113
114 echo "Starting Robot test suites ${SUITES} ..."
115 pybot -N ${TESTPLAN} -c critical -e exclude -v BUNDLEFOLDER:${BUNDLEFOLDER} -v WORKSPACE:/tmp \
116 -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} -v CONTROLLER:${CONTROLLER0} -v CONTROLLER_USER:${USER} \
117 -v MININET:${MININET0} -v MININET1:${MININET1} -v MININET2:${MININET2} -v MININET_USER:${USER} \
118 -v USER_HOME:${HOME} ${TESTOPTIONS} ${SUITES} || true
119
120 echo "Fetching Karaf log"
121 scp ${CONTROLLER0}:/tmp/${BUNDLEFOLDER}/data/log/karaf.log .
122
123 # vim: ts=4 sw=4 sts=4 et ft=sh :
124