Java 8 for CSIT jobs.
[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 if [ ${JDKVERSION} == 'openjdk8' ]; then
11     echo "Setting the JDK Version to 8"
12     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
13     export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-2.b27.el7_1.x86_64
14     java -version
15 fi
16 if [ ${JDKVERSION} == 'openjdk7' ]; then
17     echo "Setting the JDK Version to 7"
18     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
19     export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85-2.6.1.2.el7_1.x86_64
20     java -version
21 fi
22
23 echo "Downloading the distribution..."
24 wget --no-verbose  ${ACTUALBUNDLEURL}
25
26 echo "Extracting the new controller..."
27 unzip -q ${BUNDLE}
28
29 echo "Configuring the startup features..."
30 FEATURESCONF=${WORKSPACE}/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
31 sed -ie "s/featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${ACTUALFEATURES}/g" ${FEATURESCONF}
32 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}
33 cat ${FEATURESCONF}
34
35 echo "Configuring the log..."
36 LOGCONF=${WORKSPACE}/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
37 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/g' ${LOGCONF}
38 cat ${LOGCONF}
39
40 echo "Configure max memory..."
41 MEMCONF=${WORKSPACE}/${BUNDLEFOLDER}/bin/setenv
42 sed -ie "s/2048m/${CONTROLLERMEM}/g" ${MEMCONF}
43 cat ${MEMCONF}
44
45 echo "Listing all open ports on controller system"
46 netstat -natu
47
48 echo "redirected karaf console output to karaf_console.log"
49 export KARAF_REDIRECT=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log
50
51 echo "JDK Version ..."
52 java -version
53
54 echo "Starting controller..."
55 ${WORKSPACE}/${BUNDLEFOLDER}/bin/start
56
57 echo "Waiting for controller to come up..."
58 COUNT=0
59 while true; do
60     RESP="$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null || true )"
61     echo ${RESP}
62     if [[ ${RESP} == *"200"* ]]; then
63         echo Controller is UP
64         break
65     elif (( ${COUNT} > 600 )); then
66         echo Timeout Controller DOWN
67         echo "Dumping Karaf log..."
68         cat ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
69         echo "Listing all open ports on controller system"
70         netstat -natu
71         exit 1
72     else
73         COUNT=$(( ${COUNT} + 5 ))
74         sleep 5
75         echo waiting ${COUNT} secs...
76     fi
77 done
78
79 echo "loading many features at once.  Need to allow time for problems to show up in logs.  cool down for 5 min ..."
80 sleep 300
81
82 echo "Checking OSGi bundles..."
83 sshpass -p karaf ${WORKSPACE}/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
84
85 echo "Listing all open ports on controller system"
86 netstat -natu
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 1M of karaf.log..."
93         head --bytes=1M  ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
94         cp ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log .
95         cp ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log .
96         exit 1
97     fi
98
99     echo "looking for \"$1\" in karaf_console.log file"
100     if grep --quiet "$1" ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log; then
101         echo ABORTING: found "$1"
102         echo "Dumping first 1M of karaf_console.log..."
103         head --bytes=1M  ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log
104         cp ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log .
105         cp ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log .
106         exit 1
107     fi
108 }
109
110 exit_on_log_file_message 'BindException: Address already in use'
111 exit_on_log_file_message 'server is unhealthy'
112
113 echo "Fetching Karaf logs"
114 cp ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log .
115 cp ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log .
116
117 echo "Kill controller"
118 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
119
120 # vim: ts=4 sw=4 sts=4 et ft=sh :
121