Merge "Remove COE openstack based CSIT"
[releng/builder.git] / jjb / integration / distribution / distribution-deploy-offline.sh
1 CONTROLLERMEM="3072m"
2 ACTUALFEATURES="odl-integration-all"
3
4 echo "Kill any controller running"
5 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
6
7 echo "Clean workspace"
8 rm -rf *
9
10 echo "Downloading the distribution..."
11 wget --progress=dot:mega "${ACTUAL_BUNDLE_URL}"
12
13 echo "Extracting the new controller..."
14 unzip -q "${BUNDLE}"
15
16 echo "Configuring the startup features..."
17 FEATURESCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg"
18 FEATURE_TEST_STRING="features-integration-test"
19 if [[ "$KARAF_VERSION" == "karaf4" ]]; then
20     FEATURE_TEST_STRING="features-test"
21 fi
22
23 sed -ie "s%\(featuresRepositories=\|featuresRepositories =\)%featuresRepositories = mvn:org.opendaylight.integration/${FEATURE_TEST_STRING}/${BUNDLEVERSION}/xml/features,%g" ${FEATURESCONF}
24
25 # Feature is instaled later.
26 cat "${FEATURESCONF}"
27
28 echo "Configuring the log..."
29 LOGCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg"
30 sed -ie 's/log4j.appender.out.maxBackupIndex=10/log4j.appender.out.maxBackupIndex=1/g' "${LOGCONF}"
31 # FIXME: Make log size limit configurable from build parameter.
32 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=30GB/g' "${LOGCONF}"
33 cat "${LOGCONF}"
34
35 echo "Configure the repos..."
36 REPOCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.ops4j.pax.url.mvn.cfg"
37 sed -ie '/http/d' "${REPOCONF}"
38 sed -ie '$s/...$//' "${REPOCONF}"
39 cat "${REPOCONF}"
40
41 echo "Configure max memory..."
42 MEMCONF="${WORKSPACE}/${BUNDLEFOLDER}/bin/setenv"
43 sed -ie "s/2048m/${CONTROLLERMEM}/g" "${MEMCONF}"
44 cat "${MEMCONF}"
45
46 if [ "${JDKVERSION}" == 'openjdk8' ]; then
47     echo "Setting the JRE Version to 8"
48     # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
49     # sudo /usr/sbin/alternatives --set java /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-2.b27.el7_1.x86_64/jre/bin/java
50     export JAVA_HOME='/usr/lib/jvm/java-1.8.0'
51 elif [ "${JDKVERSION}" == 'openjdk7' ]; then
52     echo "Setting the JRE Version to 7"
53     # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
54     # sudo /usr/sbin/alternatives --set java /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85-2.6.1.2.el7_1.x86_64/jre/bin/java
55     export JAVA_HOME='/usr/lib/jvm/java-1.7.0'
56 fi
57 readlink -e "${JAVA_HOME}/bin/java"
58 echo "Default JDK Version, JAVA_HOME should override"
59 java -version
60
61 echo "Redirecting karaf console output to karaf_console.log"
62 export KARAF_REDIRECT="${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
63 mkdir -p ${WORKSPACE}/${BUNDLEFOLDER}/data/log
64
65 echo "Starting controller..."
66 ${WORKSPACE}/${BUNDLEFOLDER}/bin/start
67
68 echo "Waiting for controller to come up..."
69 # Silence the chatty output during the loop.
70 set +x
71 COUNT=0
72 # Bug 9044 workaround: use bin/client instead of Linux ssh command.
73 CLIENT="${WORKSPACE}/${BUNDLEFOLDER}/bin/client"
74 while true; do
75     # Is there a way to both print output and store RC without manipulating the e flag?
76     set +e
77     ${CLIENT} "feature:list -i"
78     RC="$?"
79     set -e
80     if [[ "${RC}" == "0" ]]; then
81         echo Karaf is UP
82         break
83     elif (( "${COUNT}" > 600 )); then
84         echo Timeout Karaf DOWN
85         echo "Dumping Karaf log..."
86         cat "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
87         echo "Listing all open ports on controller system"
88         netstat -pnatu
89         exit 1
90     else
91         echo "${RC}"
92         COUNT=$(( ${COUNT} + 1 ))
93         sleep 1
94         if [[ $(($COUNT % 5)) == 0 ]]; then
95             echo already waited ${COUNT} seconds...
96         fi
97     fi
98 done
99 # Un-silence the chatty output.
100 set -x
101
102 echo "Installing all features..."
103 $CLIENT feature:install ${ACTUALFEATURES} || echo $? > "${WORKSPACE}/error.txt"
104
105 echo "killing karaf process..."
106 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
107 sleep 5
108
109 echo "Fetching Karaf logs"
110 # TODO: Move instead of copy? Gzip?
111 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
112 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
113
114 echo "Exit if error"
115 if [ -f "${WORKSPACE}/error.txt" ]; then
116     echo "Failed to deploy offline"
117     exit 1
118 else
119     echo "Offline test: PASS"
120 fi
121
122 # vim: ts=4 sw=4 sts=4 et ft=sh :