3 ACTUALFEATURES="odl-integration-all"
4 BUNDLEVERSION="$(xpath distribution/pom.xml '/project/version/text()' 2> /dev/null)"
5 BUNDLEFOLDER="${KARAF_ARTIFACT}-${BUNDLEVERSION}"
6 BUNDLE="${BUNDLEFOLDER}.zip"
7 BUNDLE_PATH="/tmp/r/org/opendaylight/integration/${KARAF_ARTIFACT}/${BUNDLEVERSION}/${BUNDLE}"
9 echo "Kill any controller running"
10 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
12 echo "Clean Existing distribution"
13 rm -rf ${BUNDLEFOLDER}
15 echo "Copying the distribution..."
18 echo "Extracting the new controller..."
21 echo "Configuring the startup features..."
22 FEATURESCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg"
23 FEATURE_TEST_STRING="features-integration-test"
24 if [[ "$KARAF_VERSION" == "karaf4" ]]; then
25 FEATURE_TEST_STRING="features-test"
28 sed -ie "s%\(featuresRepositories=\|featuresRepositories =\)%featuresRepositories = mvn:org.opendaylight.integration/${FEATURE_TEST_STRING}/${BUNDLEVERSION}/xml/features,%g" ${FEATURESCONF}
30 # Add actual boot features.
31 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" "${FEATURESCONF}"
34 echo "Configuring the log..."
35 LOGCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg"
36 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/g' "${LOGCONF}"
39 echo "Configure max memory..."
40 MEMCONF="${WORKSPACE}/${BUNDLEFOLDER}/bin/setenv"
41 sed -ie "s/2048m/${CONTROLLERMEM}/g" "${MEMCONF}"
44 echo "Listing all open ports on controller system"
47 echo "redirected karaf console output to karaf_console.log"
48 export KARAF_REDIRECT="${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
49 mkdir -p ${WORKSPACE}/${BUNDLEFOLDER}/data/log
51 if [ "${JDKVERSION}" == 'openjdk8' ]; then
52 echo "Setting the JRE Version to 8"
53 # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
54 # 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
55 export JAVA_HOME='/usr/lib/jvm/java-1.8.0'
56 elif [ "${JDKVERSION}" == 'openjdk7' ]; then
57 echo "Setting the JRE Version to 7"
58 # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
59 # 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
60 export JAVA_HOME='/usr/lib/jvm/java-1.7.0'
62 readlink -e "${JAVA_HOME}/bin/java"
63 echo "JDK Version should be overriden by JAVA_HOME"
66 echo "Redirecting karaf console output to karaf_console.log"
67 export KARAF_REDIRECT="${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
68 mkdir -p ${WORKSPACE}/${BUNDLEFOLDER}/data/log
70 echo "Starting controller..."
71 ${WORKSPACE}/${BUNDLEFOLDER}/bin/start
73 # No need for verbose printing during repeating operations.
76 echo "Waiting for controller to come up..."
79 RESP="$(curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null || true)"
81 if [[ "${RESP}" == *"200"* ]]; then
84 elif (( "${COUNT}" > 600 )); then
85 echo Timeout Controller DOWN
86 echo "Dumping Karaf log..."
87 cat "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
88 echo "Listing all open ports on controller system"
92 COUNT=$(( ${COUNT} + 1 ))
94 if [[ $(($COUNT % 5)) == 0 ]]; then
95 echo already waited ${COUNT} seconds...
100 echo "loading many features at once. Need to allow time for problems to show up in logs. cool down for 5 min ..."
103 if (( "${COUNT}" <= "0" )); then
106 echo "${COUNT} seconds yet to wait..."
108 COUNT="$(( ${COUNT} - 10 ))"
111 # End of repeating operations, enable verbose printing.
114 # echo "Checking OSGi bundles..."
115 # sshpass seems to fail with new karaf version
116 # sshpass -p karaf ${WORKSPACE}/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
118 echo "Listing all open ports on controller system"
121 function exit_on_log_file_message {
122 echo "looking for \"$1\" in karaf.log file"
123 if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
124 echo ABORTING: found "$1"
125 echo "Dumping first 500K bytes of karaf log..."
126 head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
127 echo "Dumping last 500K bytes of karaf log..."
128 tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
129 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
130 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
134 echo "looking for \"$1\" in karaf_console.log file"
135 if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"; then
136 echo ABORTING: found "$1"
137 echo "Dumping first 500K bytes of karaf log..."
138 head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
139 echo "Dumping last 500K bytes of karaf log..."
140 tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
141 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
142 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
147 exit_on_log_file_message 'BindException: Address already in use'
148 exit_on_log_file_message 'server is unhealthy'
150 echo "Fetching Karaf logs"
151 # TODO: Move instead of copy? Gzip?
152 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
153 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
155 echo "Kill controller"
156 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
158 echo "Bug 4628: Detecting misplaced config files"
159 pushd "${WORKSPACE}/${BUNDLEFOLDER}" || exit
160 XMLS_FOUND="$(echo *.xml)"
162 if [ "$XMLS_FOUND" != "*.xml" ]; then
163 echo "Bug 4628 confirmed."
164 ## TODO: Uncomment the following when ODL is fixed, to guard against regression.
167 echo "Bug 4628 not detected."
170 # vim: ts=4 sw=4 sts=4 et ft=sh :