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 # Add test feature repo if Karaf 4.
19 sed -ie "s%\(featuresRepositories=\|featuresRepositories =\)%featuresRepositories = mvn:org.opendaylight.integration/features-test/${BUNDLEVERSION}/xml/features,%g" "${FEATURESCONF}"
20 # Add test feature repo if Karaf 3.
21 sed -ie "s%\(featuresRepositories=\|featuresRepositories =\)%featuresRepositories = 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 mkdir -p ${WORKSPACE}/${BUNDLEFOLDER}/data/log
61
62 echo "Starting controller..."
63 ${WORKSPACE}/${BUNDLEFOLDER}/bin/start
64
65 echo "Waiting for controller to come up..."
66 # Silence the chatty output during the loop.
67 set +x
68 COUNT=0
69 # Bug 9044 workaround: use bin/client instead of Linux ssh command.
70 CLIENT="${WORKSPACE}/${BUNDLEFOLDER}/bin/client"
71 while true; do
72     # Is there a way to both print output and store RC without manipulating the e flag?
73     set +e
74     ${CLIENT} "feature:list -i"
75     RC="$?"
76     set -e
77     if [[ "${RC}" == "0" ]]; then
78         echo Karaf is UP
79         break
80     elif (( "${COUNT}" > 600 )); then
81         echo Timeout Karaf DOWN
82         echo "Dumping Karaf log..."
83         cat "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
84         echo "Listing all open ports on controller system"
85         netstat -pnatu
86         exit 1
87     else
88         echo "${RC}"
89         COUNT=$(( ${COUNT} + 1 ))
90         sleep 1
91         if [[ $(($COUNT % 5)) == 0 ]]; then
92             echo already waited ${COUNT} seconds...
93         fi
94     fi
95 done
96 # Un-silence the chatty output.
97 set -x
98
99 echo "Installing all features..."
100 $CLIENT feature:install ${ACTUALFEATURES} || echo $? > "${WORKSPACE}/error.txt"
101
102 echo "killing karaf process..."
103 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
104 sleep 5
105
106 echo "Fetching Karaf logs"
107 # TODO: Move instead of copy? Gzip?
108 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
109 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
110
111 echo "Exit if error"
112 if [ -f "${WORKSPACE}/error.txt" ]; then
113     echo "Failed to deploy offline"
114     exit 1
115 else
116     echo "Offline test: PASS"
117 fi
118
119 # vim: ts=4 sw=4 sts=4 et ft=sh :