Merge "Jenkins build template controller-csit-rest-cars-perf"
[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 "Starting controller..."
36 ${WORKSPACE}/${BUNDLEFOLDER}/bin/start
37
38 echo "Waiting for controller to come up..."
39 COUNT=0
40 while true; do
41     RESP="$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null || true )"
42     echo ${RESP}
43     if [[ ${RESP} == *"200"* ]]; then
44         echo Controller is UP
45         break
46     elif (( ${COUNT} > 600 )); then
47         echo Timeout Controller DOWN
48         echo "Dumping Karaf log..."
49         cat ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
50         echo "Listing all open ports on controller system"
51         netstat -natu
52         exit 1
53     else
54         COUNT=$(( ${COUNT} + 5 ))
55         sleep 5
56         echo waiting ${COUNT} secs...
57     fi
58 done
59
60 echo "Checking OSGi bundles..."
61 sshpass -p karaf ${WORKSPACE}/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
62
63 echo "Listing all open ports on controller system"
64 netstat -natu
65
66 function exit_on_log_file_message {
67     echo "looking for \"$1\" in log file"
68     if grep --quiet "$1" ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log; then
69         echo ABORTING: found "$1"
70         echo "Dumping Karaf log..."
71         cat ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
72         exit 1
73     fi
74 }
75
76 exit_on_log_file_message 'BindException: Address already in use'
77 exit_on_log_file_message 'server is unhealthy'
78
79 echo "Fetching Karaf log"
80 cp ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log .
81
82 echo "Kill controller"
83 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
84
85 # vim: ts=4 sw=4 sts=4 et ft=sh :
86