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