Merge "Add Job to run tempest against odl-neutron-dummyprovider-test"
[releng/builder.git] / jjb / integration / include-raw-integration-deploy-controller-offline.sh
1 # Create a script to run controller inside a dynamic jenkins slave
2 DISTRIBUTION="karaf"
3 CONTROLLERFEATURES="odl-integration-compatible-with-all"
4 CONTROLLERMEM="3072m"
5
6 NEXUSURL_PREFIX=${ODLNEXUSPROXY:-https://nexus.opendaylight.org}
7
8 if [ ${BUNDLEURL} == 'last' ]; then
9     NEXUSPATH="${NEXUSURL_PREFIX}/content/repositories/opendaylight.snapshot/org/opendaylight/integration/distribution-${DISTRIBUTION}"
10     # Extract the BUNDLEVERSION from the pom.xml
11     BUNDLEVERSION=`xpath pom.xml '/project/version/text()' 2> /dev/null`
12     echo "Bundle version is ${BUNDLEVERSION}"
13     # Acquire the timestamp information from maven-metadata.xml
14     wget ${NEXUSPATH}/${BUNDLEVERSION}/maven-metadata.xml
15     TIMESTAMP=`xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null`
16     echo "Nexus timestamp is ${TIMESTAMP}"
17     BUNDLEFOLDER="distribution-${DISTRIBUTION}-${BUNDLEVERSION}"
18     BUNDLE="distribution-${DISTRIBUTION}-${TIMESTAMP}.zip"
19     BUNDLEURL="${NEXUSPATH}/${BUNDLEVERSION}/${BUNDLE}"
20 else
21     BUNDLE="${BUNDLEURL##*/}"
22     BUNDLEVERSION="$(basename $(dirname $BUNDLEURL))"
23     BUNDLEFOLDER="distribution-${DISTRIBUTION}-${BUNDLEVERSION}"
24 fi
25
26 echo "Distribution bundle URL is ${BUNDLEURL}"
27 echo "Distribution bundle is ${BUNDLE}"
28 echo "Distribution folder is ${BUNDLEFOLDER}"
29
30 echo "Downloading the distribution..."
31 wget --no-verbose  ${BUNDLEURL}
32
33 echo "Extracting the new controller..."
34 unzip -q ${BUNDLE}
35
36 echo "Configuring the startup features..."
37 cd ${BUNDLEFOLDER}/etc
38 CFG=org.apache.karaf.features.cfg
39 cp ${CFG} ${CFG}.bak
40 cat ${CFG}.bak | sed "s/^featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${CONTROLLERFEATURES}/" > ${CFG}.1
41 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}
42 cat ${CFG}
43
44 echo "Configuring the log..."
45 LOG=org.ops4j.pax.logging.cfg
46 cp ${LOG} ${LOG}.bak
47 cat ${LOG}.bak | sed 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/' > ${LOG}
48 cat ${LOG}
49
50 echo "Configure the repos..."
51 REPO=org.ops4j.pax.url.mvn.cfg
52 cp ${REPO} ${REPO}.bak
53 cat ${REPO}.bak | sed '/http/d' | sed '$s/...$//'> ${REPO}
54 cat ${REPO}
55
56 echo "Configure max memory..."
57 MEM=setenv
58 cd ../bin
59 cp ${MEM} ${MEM}.bak
60 cat ${MEM}.bak | sed 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/' > ${MEM}
61 cat ${MEM}
62
63 echo "Starting controller..."
64 ./start &
65
66 echo "sleeping for 20 seconds..."
67 sleep 20
68
69 echo "Check OSGi bundles..."
70 sshpass -p karaf ./client -u karaf "feature:install ${CONTROLLERFEATURES}" || echo $? > ${WORKSPACE}/error.txt
71
72 echo "Fetching Karaf log"
73 cd ${WORKSPACE}
74 cp ${BUNDLEFOLDER}/data/log/karaf.log .
75
76 echo "Exit with error"
77 if [ `cat error.txt` -ne 0 ]; then
78     echo "Failed to deploy offline"
79     exit 1
80 fi
81
82 # vim: ts=4 sw=4 sts=4 et ft=sh :
83