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