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="/usr/lib/jvm/java-11-openjdk"
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'
74 readlink -e "${JAVA_HOME}/bin/java"
75 echo "JDK Version should be overriden by JAVA_HOME"
78 echo "Redirecting karaf console output to karaf_console.log"
79 export KARAF_REDIRECT="${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
80 mkdir -p "${WORKSPACE}/${BUNDLEFOLDER}/data/log"
82 echo "Starting controller..."
83 "${WORKSPACE}/${BUNDLEFOLDER}/bin/start"
85 function dump_log_and_exit {
86 echo "Dumping first 500K bytes of karaf log..."
87 head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
88 echo "Dumping last 500K bytes of karaf log..."
89 tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
90 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
91 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
95 echo "Waiting up to 6 minutes for controller to come up, checking every 5 seconds..."
98 COUNT=$(( COUNT + 5 ))
100 echo "already waited ${COUNT} seconds..."
101 if grep --quiet 'org.opendaylight.infrautils.*System ready' "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
102 echo "Controller is UP"
104 elif (( "${COUNT}" >= "360" )); then
105 echo "Timeout Controller DOWN"
110 # echo "Checking OSGi bundles..."
111 # sshpass seems to fail with new karaf version
112 # sshpass -p karaf ${WORKSPACE}/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
114 echo "Listing all open ports on controller system"
117 function exit_on_log_file_message {
118 echo "looking for \"$1\" in karaf.log file"
119 if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
120 echo ABORTING: found "$1"
124 echo "looking for \"$1\" in karaf_console.log file"
125 if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"; then
126 echo ABORTING: found "$1"
131 exit_on_log_file_message 'Error installing boot feature repository'
132 exit_on_log_file_message 'BindException: Address already in use'
133 exit_on_log_file_message 'server is unhealthy'
135 echo "Fetching Karaf logs"
136 # TODO: Move instead of copy? Gzip?
137 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
138 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
140 echo "Kill controller"
141 # shellcheck disable=SC2009
142 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
144 echo "Bug 4628: Detecting misplaced config files"
145 pushd "${WORKSPACE}/${BUNDLEFOLDER}" || exit
146 XMLS_FOUND="$(echo -- *.xml)"
148 if [ "$XMLS_FOUND" != "*.xml" ]; then
149 echo "Bug 4628 confirmed."
150 ## TODO: Uncomment the following when ODL is fixed, to guard against regression.
153 echo "Bug 4628 not detected."
156 # vim: ts=4 sw=4 sts=4 et ft=sh :