2 if [[ -n "${CONTROLLERFEATURES}" ]]; then
3 ACTUALFEATURES="odl-integration-all,${CONTROLLERFEATURES}"
5 ACTUALFEATURES="odl-integration-all"
8 if [[ "${JOB_NAME}" == *"distribution-sanity"* ]]; then
14 echo "Kill any controller running"
15 # shellcheck disable=SC2009
16 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
18 echo "Clean Existing distribution"
19 rm -rf "${BUNDLEFOLDER}"
21 echo "Fetch the distribution..."
22 if [[ -z "${BUNDLE_PATH}" ]]; then
23 wget --progress=dot:mega "${ACTUAL_BUNDLE_URL}"
28 echo "Extracting the new controller..."
31 echo "Configuring the startup features..."
32 FEATURESCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg"
33 FEATURE_TEST_STRING="features-test"
34 if [[ "$KARAF_VERSION" == "karaf3" ]]; then
35 FEATURE_TEST_STRING="features-integration-test"
38 sed -ie "s%\(featuresRepositories= \|featuresRepositories = \)%featuresRepositories = mvn:org.opendaylight.integration/${FEATURE_TEST_STRING}/${BUNDLE_VERSION}/xml/features,%g" "${FEATURESCONF}"
40 if [[ -n "${REPO_URL}" ]]; then
41 # sed below will fail if it finds space between feature repos.
42 REPO_URL_NO_SPACE="$(echo -e "${REPO_URL}" | tr -d '[:space:]')"
43 sed -ie "s%featuresRepositories = %featuresRepositories = ${REPO_URL_NO_SPACE},%g" "${FEATURESCONF}"
46 # Add actual boot features.
47 # sed below will fail if it finds space between feature repos.
48 FEATURES_NO_SPACE="$(echo -e "${ACTUALFEATURES}" | tr -d '[:space:]')"
49 sed -ie "s/\(featuresBoot= \|featuresBoot = \)/featuresBoot = ${FEATURES_NO_SPACE},/g" "${FEATURESCONF}"
52 echo "Configuring the log..."
53 LOGCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg"
54 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/g' "${LOGCONF}"
57 echo "Configure max memory..."
58 MEMCONF="${WORKSPACE}/${BUNDLEFOLDER}/bin/setenv"
59 sed -ie "s/2048m/${CONTROLLERMEM}/g" "${MEMCONF}"
62 echo "Listing all open ports on controller system"
65 if [ "$JDKVERSION" == 'openjdk11' ]; then
66 echo "Preparing for JRE Version 11"
67 JAVA_HOME="/opt/jdk-11"
68 elif [ "${JDKVERSION}" == 'openjdk8' ]; then
69 echo "Setting the JRE Version to 8"
70 # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
71 # 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
72 export JAVA_HOME='/usr/lib/jvm/java-1.8.0'
73 elif [ "${JDKVERSION}" == 'openjdk7' ]; then
74 echo "Setting the JRE Version to 7"
75 # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
76 # 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
77 export JAVA_HOME='/usr/lib/jvm/java-1.7.0'
79 readlink -e "${JAVA_HOME}/bin/java"
80 echo "JDK Version should be overriden by JAVA_HOME"
83 echo "Redirecting karaf console output to karaf_console.log"
84 export KARAF_REDIRECT="${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
85 mkdir -p "${WORKSPACE}/${BUNDLEFOLDER}/data/log"
87 echo "Starting controller..."
88 "${WORKSPACE}/${BUNDLEFOLDER}/bin/start"
90 function dump_log_and_exit {
91 echo "Dumping first 500K bytes of karaf log..."
92 head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
93 echo "Dumping last 500K bytes of karaf log..."
94 tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
95 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
96 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
100 echo "Waiting up to 6 minutes for controller to come up, checking every 5 seconds..."
103 COUNT=$(( COUNT + 5 ))
105 echo "already waited ${COUNT} seconds..."
106 if grep --quiet 'org.opendaylight.infrautils.*System ready' "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
107 echo "Controller is UP"
109 elif (( "${COUNT}" >= "360" )); then
110 echo "Timeout Controller DOWN"
115 # echo "Checking OSGi bundles..."
116 # sshpass seems to fail with new karaf version
117 # sshpass -p karaf ${WORKSPACE}/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
119 echo "Listing all open ports on controller system"
122 function exit_on_log_file_message {
123 echo "looking for \"$1\" in karaf.log file"
124 if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
125 echo ABORTING: found "$1"
129 echo "looking for \"$1\" in karaf_console.log file"
130 if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"; then
131 echo ABORTING: found "$1"
136 exit_on_log_file_message 'Error installing boot feature repository'
137 exit_on_log_file_message 'BindException: Address already in use'
138 exit_on_log_file_message 'server is unhealthy'
140 echo "Fetching Karaf logs"
141 # TODO: Move instead of copy? Gzip?
142 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
143 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
145 echo "Kill controller"
146 # shellcheck disable=SC2009
147 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
149 echo "Bug 4628: Detecting misplaced config files"
150 pushd "${WORKSPACE}/${BUNDLEFOLDER}" || exit
151 XMLS_FOUND="$(echo -- *.xml)"
153 if [ "$XMLS_FOUND" != "*.xml" ]; then
154 echo "Bug 4628 confirmed."
155 ## TODO: Uncomment the following when ODL is fixed, to guard against regression.
158 echo "Bug 4628 not detected."
161 # vim: ts=4 sw=4 sts=4 et ft=sh :