2066e3e2b942049f5b8bdc129b8784997273077e
[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 --no-verbose  ${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=config,standard,region,package,kar,ssh,management,${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 -natu
34
35 echo "redirected karaf console output to karaf_console.log"
36 export KARAF_REDIRECT=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log
37
38 echo "JDK Version ..."
39 java -version
40
41 echo "Starting controller..."
42 ${WORKSPACE}/${BUNDLEFOLDER}/bin/start
43
44 echo "Waiting for controller to come up..."
45 COUNT=0
46 while true; do
47     RESP="$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null || true )"
48     echo ${RESP}
49     if [[ ${RESP} == *"200"* ]]; then
50         echo Controller is UP
51         break
52     elif (( ${COUNT} > 600 )); then
53         echo Timeout Controller DOWN
54         echo "Dumping Karaf log..."
55         cat ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
56         echo "Listing all open ports on controller system"
57         netstat -natu
58         exit 1
59     else
60         COUNT=$(( ${COUNT} + 5 ))
61         sleep 5
62         echo waiting ${COUNT} secs...
63     fi
64 done
65
66 echo "loading many features at once.  Need to allow time for problems to show up in logs.  cool down for 5 min ..."
67 sleep 300
68
69 echo "Checking OSGi bundles..."
70 sshpass -p karaf ${WORKSPACE}/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
71
72 echo "Listing all open ports on controller system"
73 netstat -natu
74
75 function exit_on_log_file_message {
76     echo "looking for \"$1\" in karaf.log file"
77     if grep --quiet "$1" ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log; then
78         echo ABORTING: found "$1"
79         echo "Dumping first 500K bytes of karaf log..."
80         head --bytes=500K  ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
81         echo "Dumping last 500K bytes of karaf log..."
82         tail --bytes=500K  ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
83         cp ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log .
84         cp ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log .
85         exit 1
86     fi
87
88     echo "looking for \"$1\" in karaf_console.log file"
89     if grep --quiet "$1" ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log; then
90         echo ABORTING: found "$1"
91         echo "Dumping first 500K bytes of karaf log..."
92         head --bytes=500K  ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log
93         echo "Dumping last 500K bytes of karaf log..."
94         tail --bytes=500K  ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log
95         cp ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log .
96         cp ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log .
97         exit 1
98     fi
99 }
100
101 exit_on_log_file_message 'BindException: Address already in use'
102 exit_on_log_file_message 'server is unhealthy'
103
104 echo "Fetching Karaf logs"
105 cp ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log .
106 cp ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log .
107
108 echo "Kill controller"
109 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
110
111 echo "Detecting misplaced config files"
112 pushd "${WORKSPACE}/${BUNDLEFOLDER}"
113 XMLS_FOUND=`echo *.xml`
114 popd
115 if [ "$XMLS_FOUND" != "*.xml" ]; then
116     echo "Bug 4628 confirmed."
117     ## TODO: Uncomment the following when ODL is fixed, to guard against regression.
118     # exit 1
119 else
120     echo "Bug 4628 not detected."
121 fi
122
123 # vim: ts=4 sw=4 sts=4 et ft=sh :