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