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