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