f0f2fbb6d5e46d43c90ef9d5c1c858c82f0f22a9
[releng/builder.git] / jjb / integration / distribution / distribution-deploy-verify.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 # Add actual boot features.
23 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" "${FEATURESCONF}"
24 cat "${FEATURESCONF}"
25
26 echo "Configuring the log..."
27 LOGCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg"
28 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/g' "${LOGCONF}"
29 cat "${LOGCONF}"
30
31 echo "Configure max memory..."
32 MEMCONF="${WORKSPACE}/${BUNDLEFOLDER}/bin/setenv"
33 sed -ie "s/2048m/${CONTROLLERMEM}/g" "${MEMCONF}"
34 cat "${MEMCONF}"
35
36 echo "Listing all open ports on controller system"
37 netstat -pnatu
38
39 if [ "${JDKVERSION}" == 'openjdk8' ]; then
40     echo "Setting the JRE Version to 8"
41     # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
42     # 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
43     export JAVA_HOME='/usr/lib/jvm/java-1.8.0'
44 elif [ "${JDKVERSION}" == 'openjdk7' ]; then
45     echo "Setting the JRE Version to 7"
46     # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
47     # 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
48     export JAVA_HOME='/usr/lib/jvm/java-1.7.0'
49 fi
50 readlink -e "${JAVA_HOME}/bin/java"
51 echo "Default JDK Version, JAVA_HOME should override"
52 java -version
53
54 echo "Redirecting karaf console output to karaf_console.log"
55 export KARAF_REDIRECT="${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
56
57 echo "Starting controller..."
58 ${WORKSPACE}/${BUNDLEFOLDER}/bin/start
59
60 echo "Waiting for controller to come up..."
61 COUNT=0
62 while true; do
63     RESP="$(curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null || true)"
64     echo "${RESP}"
65     if [[ "${RESP}" == *"200"* ]]; then
66         echo Controller is UP
67         break
68     elif (( "${COUNT}" > 600 )); then
69         echo Timeout Controller DOWN
70         echo "Dumping Karaf log..."
71         cat "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
72         echo "Listing all open ports on controller system"
73         netstat -pnatu
74         exit 1
75     else
76         COUNT=$(( ${COUNT} + 1 ))
77         sleep 1
78         if [[ $(($COUNT % 5)) == 0 ]]; then
79             echo already waited ${COUNT} seconds...
80         fi
81     fi
82 done
83
84 echo "loading many features at once.  Need to allow time for problems to show up in logs.  cool down for 5 min ..."
85 sleep 300
86
87 echo "Checking OSGi bundles..."
88 # sshpass seems to fail with new karaf version
89 # sshpass -p karaf ${WORKSPACE}/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
90
91 echo "Listing all open ports on controller system"
92 netstat -pnatu
93
94 function exit_on_log_file_message {
95     echo "looking for \"$1\" in karaf.log file"
96     if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
97         echo ABORTING: found "$1"
98         echo "Dumping first 500K bytes of karaf log..."
99         head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
100         echo "Dumping last 500K bytes of karaf log..."
101         tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
102         cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
103         cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
104         exit 1
105     fi
106
107     echo "looking for \"$1\" in karaf_console.log file"
108     if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"; then
109         echo ABORTING: found "$1"
110         echo "Dumping first 500K bytes of karaf log..."
111         head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
112         echo "Dumping last 500K bytes of karaf log..."
113         tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
114         cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
115         cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
116         exit 1
117     fi
118 }
119
120 exit_on_log_file_message 'BindException: Address already in use'
121 exit_on_log_file_message 'server is unhealthy'
122
123 echo "Fetching Karaf logs"
124 # TODO: Move instead of copy? Gzip?
125 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
126 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
127
128 echo "Kill controller"
129 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
130
131 echo "Bug 4628: Detecting misplaced config files"
132 pushd "${WORKSPACE}/${BUNDLEFOLDER}" || exit
133 XMLS_FOUND=`echo *.xml`
134 popd || exit
135 if [ "$XMLS_FOUND" != "*.xml" ]; then
136     echo "Bug 4628 confirmed."
137     ## TODO: Uncomment the following when ODL is fixed, to guard against regression.
138     # exit 1
139 else
140     echo "Bug 4628 not detected."
141 fi
142
143 # vim: ts=4 sw=4 sts=4 et ft=sh :