2 # do not add integration features in MRI projects
3 if [[ "$KARAF_PROJECT" == integration ]]; then
4 if [[ -n "${CONTROLLERFEATURES}" ]]; then
5 ACTUALFEATURES="odl-integration-all,${CONTROLLERFEATURES}"
7 ACTUALFEATURES="odl-integration-all"
10 ACTUALFEATURES="${CONTROLLERFEATURES}"
13 if [[ "${JOB_NAME}" == *"distribution-sanity"* ]]; then
19 echo "Kill any controller running"
20 # shellcheck disable=SC2009
21 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
23 echo "Clean Existing distribution"
24 rm -rf "${BUNDLEFOLDER}"
26 echo "Fetch the distribution..."
27 if [[ -z "${BUNDLE_PATH}" ]]; then
28 wget --progress=dot:mega "${ACTUAL_BUNDLE_URL}"
33 echo "Extracting the new controller..."
36 echo "Configuring the startup features..."
37 FEATURESCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg"
38 FEATURE_TEST_STRING="features-test"
39 FEATURE_TEST_VERSION="$BUNDLE_VERSION"
40 if [[ "$KARAF_ARTIFACT" == "opendaylight" ]]; then
41 FEATURE_TEST_VERSION="$(sed -r "s%^([0-9]+)\.([0-9]+)\.0(.*)%0.\1.\2\3%" <<<"$BUNDLE_VERSION")"
44 # only replace feature repo in integration/distro, MRI projects need to pull in
45 # the features they need by themselves
46 if [[ "$KARAF_PROJECT" == integration ]]; then
47 sed -ie "s%\(featuresRepositories= \|featuresRepositories = \)%featuresRepositories = mvn:org.opendaylight.integration/${FEATURE_TEST_STRING}/${FEATURE_TEST_VERSION}/xml/features,%g" "${FEATURESCONF}"
49 if [[ -n "${REPO_URL}" ]]; then
50 # sed below will fail if it finds space between feature repos.
51 REPO_URL_NO_SPACE="$(echo -e "${REPO_URL}" | tr -d '[:space:]')"
52 sed -ie "s%featuresRepositories = %featuresRepositories = ${REPO_URL_NO_SPACE},%g" "${FEATURESCONF}"
55 # Add actual boot features.
56 # sed below will fail if it finds space between feature repos.
57 FEATURES_NO_SPACE="$(echo -e "${ACTUALFEATURES}" | tr -d '[:space:]')"
58 sed -ie "s/\(featuresBoot= \|featuresBoot = \)/featuresBoot = ${FEATURES_NO_SPACE},/g" "${FEATURESCONF}"
62 echo "Configuring the log..."
63 LOGCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg"
64 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/g' "${LOGCONF}"
67 echo "Configure max memory..."
68 MEMCONF="${WORKSPACE}/${BUNDLEFOLDER}/bin/setenv"
69 sed -ie "s/2048m/${CONTROLLERMEM}/g" "${MEMCONF}"
72 echo "Listing all open ports on controller system"
75 if [ "$JDKVERSION" == 'openjdk17' ]; then
76 echo "Preparing for JRE Version 17"
77 JAVA_HOME="/usr/lib/jvm/java-17-openjdk"
78 elif [ "$JDKVERSION" == 'openjdk11' ]; then
79 echo "Preparing for JRE Version 11"
80 JAVA_HOME="/usr/lib/jvm/java-11-openjdk"
81 elif [ "${JDKVERSION}" == 'openjdk8' ]; then
82 echo "Setting the JRE Version to 8"
83 # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
84 # 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
85 export JAVA_HOME='/usr/lib/jvm/java-1.8.0'
87 readlink -e "${JAVA_HOME}/bin/java"
88 echo "JDK Version should be overriden by JAVA_HOME"
91 echo "Redirecting karaf console output to karaf_console.log"
92 export KARAF_REDIRECT="${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
93 mkdir -p "${WORKSPACE}/${BUNDLEFOLDER}/data/log"
95 echo "Starting controller..."
96 "${WORKSPACE}/${BUNDLEFOLDER}/bin/start"
98 function dump_log_and_exit {
99 echo "Dumping first 500K bytes of karaf log..."
100 head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
101 echo "Dumping last 500K bytes of karaf log..."
102 tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
103 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
104 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
108 echo "Waiting up to 6 minutes for controller to come up, checking every 5 seconds..."
111 COUNT=$(( COUNT + 5 ))
113 echo "already waited ${COUNT} seconds..."
114 if grep --quiet 'org.opendaylight.infrautils.*System ready' "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
115 echo "Controller is UP"
117 elif (( "${COUNT}" >= "360" )); then
118 echo "Timeout Controller DOWN"
123 # echo "Checking OSGi bundles..."
124 # sshpass seems to fail with new karaf version
125 # sshpass -p karaf ${WORKSPACE}/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
127 echo "Listing all open ports on controller system"
130 function exit_on_log_file_message {
131 echo "looking for \"$1\" in karaf.log file"
132 if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
133 echo ABORTING: found "$1"
137 echo "looking for \"$1\" in karaf_console.log file"
138 if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"; then
139 echo ABORTING: found "$1"
144 exit_on_log_file_message 'Error installing boot feature repository'
145 exit_on_log_file_message 'BindException: Address already in use'
146 exit_on_log_file_message 'server is unhealthy'
148 echo "Fetching Karaf logs"
149 # TODO: Move instead of copy? Gzip?
150 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
151 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
153 echo "Kill controller"
154 # shellcheck disable=SC2009
155 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
157 echo "Bug 4628: Detecting misplaced config files"
158 pushd "${WORKSPACE}/${BUNDLEFOLDER}" || exit
159 XMLS_FOUND="$(echo -- *.xml)"
161 if [ "$XMLS_FOUND" != "*.xml" ]; then
162 echo "Bug 4628 confirmed."
163 ## TODO: Uncomment the following when ODL is fixed, to guard against regression.
166 echo "Bug 4628 not detected."
169 # vim: ts=4 sw=4 sts=4 et ft=sh :