2 ACTUALFEATURES="odl-integration-all"
4 echo "Kill any controller running"
5 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
10 echo "Downloading the distribution..."
11 wget --progress=dot:mega "${ACTUAL_BUNDLE_URL}"
13 echo "Extracting the new controller..."
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"
23 sed -ie "s%\(featuresRepositories=\|featuresRepositories =\)%featuresRepositories = mvn:org.opendaylight.integration/${FEATURE_TEST_STRING}/${BUNDLEVERSION}/xml/features,%g" ${FEATURESCONF}
25 # Add actual boot features.
26 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" "${FEATURESCONF}"
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}"
34 echo "Configure max memory..."
35 MEMCONF="${WORKSPACE}/${BUNDLEFOLDER}/bin/setenv"
36 sed -ie "s/2048m/${CONTROLLERMEM}/g" "${MEMCONF}"
39 echo "Listing all open ports on controller system"
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'
53 readlink -e "${JAVA_HOME}/bin/java"
54 echo "Default JDK Version, JAVA_HOME should override"
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
61 echo "Starting controller..."
62 ${WORKSPACE}/${BUNDLEFOLDER}/bin/start
64 function dump_log_and_exit {
65 echo "Dumping first 500K bytes of karaf log..."
66 head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
67 echo "Dumping last 500K bytes of karaf log..."
68 tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
69 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
70 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
74 echo "Waiting up to 5 minutes for controller to come up, checking every 5 seconds..."
75 if [ "${DISTROSTREAM}" == "carbon" ] || [ "${DISTROSTREAM}" == "nitrogen" ]; then
76 # Only oxygen and above have the infrautils.ready feature, so using REST API to determine if the controller is ready.
79 COUNT=$(( ${COUNT} + 5 ))
81 echo "already waited ${COUNT} seconds..."
82 RESP="$(curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null || true)"
84 if [[ ${RESP} == *"200"* ]]; then
85 echo "Controller is UP"
87 elif (( "${COUNT}" > "300" )); then
88 echo "Timeout Controller DOWN"
95 COUNT=$(( ${COUNT} + 5 ))
97 echo "already waited ${COUNT} seconds..."
98 if grep --quiet 'org.opendaylight.infrautils.ready-impl.*System ready' "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
99 echo "Controller is UP"
101 elif (( "${COUNT}" > "300" )); then
102 echo "Timeout Controller DOWN"
108 # echo "Checking OSGi bundles..."
109 # sshpass seems to fail with new karaf version
110 # sshpass -p karaf ${WORKSPACE}/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
112 echo "Listing all open ports on controller system"
115 function exit_on_log_file_message {
116 echo "looking for \"$1\" in karaf.log file"
117 if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
118 echo ABORTING: found "$1"
122 echo "looking for \"$1\" in karaf_console.log file"
123 if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"; then
124 echo ABORTING: found "$1"
129 exit_on_log_file_message 'BindException: Address already in use'
130 exit_on_log_file_message 'server is unhealthy'
132 echo "Fetching Karaf logs"
133 # TODO: Move instead of copy? Gzip?
134 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
135 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
137 echo "Kill controller"
138 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
140 echo "Bug 4628: Detecting misplaced config files"
141 pushd "${WORKSPACE}/${BUNDLEFOLDER}" || exit
142 XMLS_FOUND=`echo *.xml`
144 if [ "$XMLS_FOUND" != "*.xml" ]; then
145 echo "Bug 4628 confirmed."
146 ## TODO: Uncomment the following when ODL is fixed, to guard against regression.
149 echo "Bug 4628 not detected."
152 # vim: ts=4 sw=4 sts=4 et ft=sh :