2 ACTUALFEATURES="odl-integration-all"
4 if [[ ! -z "${CONTROLLERFEATURES}" ]]; then
5 ACTUALFEATURES="odl-integration-all,${CONTROLLERFEATURES}"
8 echo "Kill any controller running"
9 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
11 echo "Clean Existing distribution"
12 rm -rf ${BUNDLEFOLDER}
14 echo "Fetch the distribution..."
15 if [[ -z "${BUNDLE_PATH}" ]]; then
16 wget --progress=dot:mega "${ACTUAL_BUNDLE_URL}"
21 echo "Extracting the new controller..."
24 echo "Configuring the startup features..."
25 FEATURESCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg"
26 FEATURE_TEST_STRING="features-test"
27 if [[ "$KARAF_VERSION" == "karaf3" ]]; then
28 FEATURE_TEST_STRING="features-integration-test"
31 sed -ie "s%\(featuresRepositories= \|featuresRepositories = \)%featuresRepositories = mvn:org.opendaylight.integration/${FEATURE_TEST_STRING}/${BUNDLE_VERSION}/xml/features,%g" ${FEATURESCONF}
33 if [[ ! -z "${REPO_URL}" ]]; then
34 # sed below will fail if it finds space between feature repos.
35 REPO_URL_NO_SPACE="$(echo -e "${REPO_URL}" | tr -d '[:space:]')"
36 sed -ie "s%featuresRepositories = %featuresRepositories = ${REPO_URL_NO_SPACE},%g" ${FEATURESCONF}
39 # Add actual boot features.
40 # sed below will fail if it finds space between feature repos.
41 FEATURES_NO_SPACE="$(echo -e "${ACTUALFEATURES}" | tr -d '[:space:]')"
42 sed -ie "s/\(featuresBoot= \|featuresBoot = \)/featuresBoot = ${FEATURES_NO_SPACE},/g" "${FEATURESCONF}"
45 echo "Configuring the log..."
46 LOGCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg"
47 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/g' "${LOGCONF}"
50 echo "Configure max memory..."
51 MEMCONF="${WORKSPACE}/${BUNDLEFOLDER}/bin/setenv"
52 sed -ie "s/2048m/${CONTROLLERMEM}/g" "${MEMCONF}"
55 echo "Listing all open ports on controller system"
58 if [ "$JDKVERSION" == 'openjdk11' ]; then
59 echo "Preparing for JRE Version 11"
60 JAVA_HOME="/opt/jdk-11"
61 elif [ "${JDKVERSION}" == 'openjdk8' ]; then
62 echo "Setting the JRE Version to 8"
63 # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
64 # 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
65 export JAVA_HOME='/usr/lib/jvm/java-1.8.0'
66 elif [ "${JDKVERSION}" == 'openjdk7' ]; then
67 echo "Setting the JRE Version to 7"
68 # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
69 # 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
70 export JAVA_HOME='/usr/lib/jvm/java-1.7.0'
72 readlink -e "${JAVA_HOME}/bin/java"
73 echo "JDK Version should be overriden by JAVA_HOME"
76 echo "Redirecting karaf console output to karaf_console.log"
77 export KARAF_REDIRECT="${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
78 mkdir -p ${WORKSPACE}/${BUNDLEFOLDER}/data/log
80 echo "Starting controller..."
81 ${WORKSPACE}/${BUNDLEFOLDER}/bin/start
83 function dump_log_and_exit {
84 echo "Dumping first 500K bytes of karaf log..."
85 head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
86 echo "Dumping last 500K bytes of karaf log..."
87 tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
88 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
89 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
93 echo "Waiting up to 6 minutes for controller to come up, checking every 5 seconds..."
96 COUNT=$(( ${COUNT} + 5 ))
98 echo "already waited ${COUNT} seconds..."
99 if grep --quiet 'org.opendaylight.infrautils.*System ready' "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
100 echo "Controller is UP"
102 elif (( "${COUNT}" >= "360" )); then
103 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 'Error installing boot feature repository'
130 exit_on_log_file_message 'BindException: Address already in use'
131 exit_on_log_file_message 'server is unhealthy'
133 echo "Fetching Karaf logs"
134 # TODO: Move instead of copy? Gzip?
135 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
136 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
138 echo "Kill controller"
139 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
141 echo "Bug 4628: Detecting misplaced config files"
142 pushd "${WORKSPACE}/${BUNDLEFOLDER}" || exit
143 XMLS_FOUND="$(echo *.xml)"
145 if [ "$XMLS_FOUND" != "*.xml" ]; then
146 echo "Bug 4628 confirmed."
147 ## TODO: Uncomment the following when ODL is fixed, to guard against regression.
150 echo "Bug 4628 not detected."
153 # vim: ts=4 sw=4 sts=4 et ft=sh :