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" == 'openjdk11' ]; then
76 echo "Preparing for JRE Version 11"
77 JAVA_HOME="/usr/lib/jvm/java-11-openjdk"
78 elif [ "${JDKVERSION}" == 'openjdk8' ]; then
79 echo "Setting the JRE Version to 8"
80 # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
81 # 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
82 export JAVA_HOME='/usr/lib/jvm/java-1.8.0'
84 readlink -e "${JAVA_HOME}/bin/java"
85 echo "JDK Version should be overriden by JAVA_HOME"
88 echo "Redirecting karaf console output to karaf_console.log"
89 export KARAF_REDIRECT="${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
90 mkdir -p "${WORKSPACE}/${BUNDLEFOLDER}/data/log"
92 echo "Starting controller..."
93 "${WORKSPACE}/${BUNDLEFOLDER}/bin/start"
95 function dump_log_and_exit {
96 echo "Dumping first 500K bytes of karaf log..."
97 head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
98 echo "Dumping last 500K bytes of karaf log..."
99 tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
100 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
101 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
105 echo "Waiting up to 6 minutes for controller to come up, checking every 5 seconds..."
108 COUNT=$(( COUNT + 5 ))
110 echo "already waited ${COUNT} seconds..."
111 if grep --quiet 'org.opendaylight.infrautils.*System ready' "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
112 echo "Controller is UP"
114 elif (( "${COUNT}" >= "360" )); then
115 echo "Timeout Controller DOWN"
120 # echo "Checking OSGi bundles..."
121 # sshpass seems to fail with new karaf version
122 # sshpass -p karaf ${WORKSPACE}/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
124 echo "Listing all open ports on controller system"
127 function exit_on_log_file_message {
128 echo "looking for \"$1\" in karaf.log file"
129 if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
130 echo ABORTING: found "$1"
134 echo "looking for \"$1\" in karaf_console.log file"
135 if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"; then
136 echo ABORTING: found "$1"
141 exit_on_log_file_message 'Error installing boot feature repository'
142 exit_on_log_file_message 'BindException: Address already in use'
143 exit_on_log_file_message 'server is unhealthy'
145 echo "Fetching Karaf logs"
146 # TODO: Move instead of copy? Gzip?
147 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
148 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
150 echo "Kill controller"
151 # shellcheck disable=SC2009
152 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
154 echo "Bug 4628: Detecting misplaced config files"
155 pushd "${WORKSPACE}/${BUNDLEFOLDER}" || exit
156 XMLS_FOUND="$(echo -- *.xml)"
158 if [ "$XMLS_FOUND" != "*.xml" ]; then
159 echo "Bug 4628 confirmed."
160 ## TODO: Uncomment the following when ODL is fixed, to guard against regression.
163 echo "Bug 4628 not detected."
166 # vim: ts=4 sw=4 sts=4 et ft=sh :