Increase ocata packer timeout from 60m to 75m
[releng/builder.git] / jjb / integration / distribution / distribution-check-bootup.sh
1
2 CONTROLLERMEM="3072m"
3 ACTUALFEATURES="odl-integration-all"
4 BUNDLEVERSION="$(xpath distribution/pom.xml '/project/version/text()' 2> /dev/null)"
5 BUNDLEFOLDER="${KARAF_ARTIFACT}-${BUNDLEVERSION}"
6 BUNDLE="${BUNDLEFOLDER}.zip"
7 BUNDLE_PATH="/tmp/r/org/opendaylight/integration/${KARAF_ARTIFACT}/${BUNDLEVERSION}/${BUNDLE}"
8
9 echo "Kill any controller running"
10 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
11
12 echo "Clean Existing distribution"
13 rm -rf ${BUNDLEFOLDER}
14
15 echo "Copying the distribution..."
16 cp "${BUNDLE_PATH}" .
17
18 echo "Extracting the new controller..."
19 unzip -q "${BUNDLE}"
20
21 echo "Configuring the startup features..."
22 FEATURESCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg"
23 # Add test feature repo if Karaf 4.
24 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}"
25 # Add test feature repo if Karaf 3.
26 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}"
27 # Add actual boot features.
28 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" "${FEATURESCONF}"
29 cat "${FEATURESCONF}"
30
31 echo "Configuring the log..."
32 LOGCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg"
33 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/g' "${LOGCONF}"
34 cat "${LOGCONF}"
35
36 echo "Configure max memory..."
37 MEMCONF="${WORKSPACE}/${BUNDLEFOLDER}/bin/setenv"
38 sed -ie "s/2048m/${CONTROLLERMEM}/g" "${MEMCONF}"
39 cat "${MEMCONF}"
40
41 echo "Listing all open ports on controller system"
42 netstat -pnatu
43
44 echo "redirected karaf console output to karaf_console.log"
45 export KARAF_REDIRECT="${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
46
47 if [ "${JDKVERSION}" == 'openjdk8' ]; then
48     echo "Setting the JRE Version to 8"
49     # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
50     # 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
51     export JAVA_HOME='/usr/lib/jvm/java-1.8.0'
52 elif [ "${JDKVERSION}" == 'openjdk7' ]; then
53     echo "Setting the JRE Version to 7"
54     # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
55     # 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
56     export JAVA_HOME='/usr/lib/jvm/java-1.7.0'
57 fi
58 readlink -e "${JAVA_HOME}/bin/java"
59 echo "JDK Version should be overriden by JAVA_HOME"
60 java -version
61
62 echo "Redirecting karaf console output to karaf_console.log"
63 export KARAF_REDIRECT="${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
64
65 echo "Starting controller..."
66 ${WORKSPACE}/${BUNDLEFOLDER}/bin/start
67
68 # No need for verbose printing during repeating operations.
69 set +x
70
71 echo "Waiting for controller to come up..."
72 COUNT=0
73 while true; do
74     RESP="$(curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null || true)"
75     echo "${RESP}"
76     if [[ "${RESP}" == *"200"* ]]; then
77         echo Controller is UP
78         break
79     elif (( "${COUNT}" > 600 )); then
80         echo Timeout Controller 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         COUNT=$(( ${COUNT} + 1 ))
88         sleep 1
89         if [[ $(($COUNT % 5)) == 0 ]]; then
90             echo already waited ${COUNT} seconds...
91         fi
92     fi
93 done
94
95 echo "loading many features at once.  Need to allow time for problems to show up in logs.  cool down for 5 min ..."
96 COUNT="300"
97 while true; do
98     if (( "${COUNT}" <= "0" )); then
99         break
100     fi
101     echo "${COUNT} seconds yet to wait..."
102     sleep 10
103     COUNT="$(( ${COUNT} - 10 ))"
104 done
105
106 # End of repeating operations, enable verbose printing.
107 set -x
108
109 # echo "Checking OSGi bundles..."
110 # sshpass seems to fail with new karaf version
111 # sshpass -p karaf ${WORKSPACE}/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
112
113 echo "Listing all open ports on controller system"
114 netstat -pnatu
115
116 function exit_on_log_file_message {
117     echo "looking for \"$1\" in karaf.log file"
118     if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
119         echo ABORTING: found "$1"
120         echo "Dumping first 500K bytes of karaf log..."
121         head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
122         echo "Dumping last 500K bytes of karaf log..."
123         tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
124         cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
125         cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
126         exit 1
127     fi
128
129     echo "looking for \"$1\" in karaf_console.log file"
130     if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"; then
131         echo ABORTING: found "$1"
132         echo "Dumping first 500K bytes of karaf log..."
133         head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
134         echo "Dumping last 500K bytes of karaf log..."
135         tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
136         cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
137         cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
138         exit 1
139     fi
140 }
141
142 exit_on_log_file_message 'BindException: Address already in use'
143 exit_on_log_file_message 'server is unhealthy'
144
145 echo "Fetching Karaf logs"
146 # TODO: Move instead of copy? Gzip?
147 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
148 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
149
150 echo "Kill controller"
151 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
152
153 echo "Bug 4628: Detecting misplaced config files"
154 pushd "${WORKSPACE}/${BUNDLEFOLDER}"
155 XMLS_FOUND="$(echo *.xml)"
156 popd
157 if [ "$XMLS_FOUND" != "*.xml" ]; then
158     echo "Bug 4628 confirmed."
159     ## TODO: Uncomment the following when ODL is fixed, to guard against regression.
160     # exit 1
161 else
162     echo "Bug 4628 not detected."
163 fi
164
165 # vim: ts=4 sw=4 sts=4 et ft=sh :