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