1 if [[ ! -z "${CONTROLLERFEATURES}" ]]; then
2 ACTUALFEATURES="odl-integration-all,${CONTROLLERFEATURES}"
4 ACTUALFEATURES="odl-integration-all"
7 if [[ "${JOB_NAME}" == *"distribution-sanity"* ]]; then
13 echo "Kill any controller running"
14 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
16 echo "Clean Existing distribution"
17 rm -rf ${BUNDLEFOLDER}
19 echo "Fetch the distribution..."
20 if [[ -z "${BUNDLE_PATH}" ]]; then
21 wget --progress=dot:mega "${ACTUAL_BUNDLE_URL}"
26 echo "Extracting the new controller..."
29 echo "Configuring the startup features..."
30 FEATURESCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg"
31 FEATURE_TEST_STRING="features-test"
32 if [[ "$KARAF_VERSION" == "karaf3" ]]; then
33 FEATURE_TEST_STRING="features-integration-test"
36 sed -ie "s%\(featuresRepositories= \|featuresRepositories = \)%featuresRepositories = mvn:org.opendaylight.integration/${FEATURE_TEST_STRING}/${BUNDLE_VERSION}/xml/features,%g" ${FEATURESCONF}
38 if [[ ! -z "${REPO_URL}" ]]; then
39 # sed below will fail if it finds space between feature repos.
40 REPO_URL_NO_SPACE="$(echo -e "${REPO_URL}" | tr -d '[:space:]')"
41 sed -ie "s%featuresRepositories = %featuresRepositories = ${REPO_URL_NO_SPACE},%g" ${FEATURESCONF}
44 # Add actual boot features.
45 # sed below will fail if it finds space between feature repos.
46 FEATURES_NO_SPACE="$(echo -e "${ACTUALFEATURES}" | tr -d '[:space:]')"
47 sed -ie "s/\(featuresBoot= \|featuresBoot = \)/featuresBoot = ${FEATURES_NO_SPACE},/g" "${FEATURESCONF}"
50 echo "Configuring the log..."
51 LOGCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg"
52 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/g' "${LOGCONF}"
55 echo "Configure max memory..."
56 MEMCONF="${WORKSPACE}/${BUNDLEFOLDER}/bin/setenv"
57 sed -ie "s/2048m/${CONTROLLERMEM}/g" "${MEMCONF}"
60 echo "Listing all open ports on controller system"
63 if [ "$JDKVERSION" == 'openjdk11' ]; then
64 echo "Preparing for JRE Version 11"
65 JAVA_HOME="/opt/jdk-11"
66 elif [ "${JDKVERSION}" == 'openjdk8' ]; then
67 echo "Setting the JRE Version to 8"
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.8.0-openjdk-1.8.0.60-2.b27.el7_1.x86_64/jre/bin/java
70 export JAVA_HOME='/usr/lib/jvm/java-1.8.0'
71 elif [ "${JDKVERSION}" == 'openjdk7' ]; then
72 echo "Setting the JRE Version to 7"
73 # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start.
74 # 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
75 export JAVA_HOME='/usr/lib/jvm/java-1.7.0'
77 readlink -e "${JAVA_HOME}/bin/java"
78 echo "JDK Version should be overriden by JAVA_HOME"
81 echo "Redirecting karaf console output to karaf_console.log"
82 export KARAF_REDIRECT="${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"
83 mkdir -p ${WORKSPACE}/${BUNDLEFOLDER}/data/log
85 echo "Starting controller..."
86 ${WORKSPACE}/${BUNDLEFOLDER}/bin/start
88 function dump_log_and_exit {
89 echo "Dumping first 500K bytes of karaf log..."
90 head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
91 echo "Dumping last 500K bytes of karaf log..."
92 tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"
93 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
94 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
98 echo "Waiting up to 6 minutes for controller to come up, checking every 5 seconds..."
101 COUNT=$(( ${COUNT} + 5 ))
103 echo "already waited ${COUNT} seconds..."
104 if grep --quiet 'org.opendaylight.infrautils.*System ready' "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
105 echo "Controller is UP"
107 elif (( "${COUNT}" >= "360" )); then
108 echo "Timeout Controller DOWN"
113 # echo "Checking OSGi bundles..."
114 # sshpass seems to fail with new karaf version
115 # sshpass -p karaf ${WORKSPACE}/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
117 echo "Listing all open ports on controller system"
120 function exit_on_log_file_message {
121 echo "looking for \"$1\" in karaf.log file"
122 if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
123 echo ABORTING: found "$1"
127 echo "looking for \"$1\" in karaf_console.log file"
128 if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"; then
129 echo ABORTING: found "$1"
134 exit_on_log_file_message 'Error installing boot feature repository'
135 exit_on_log_file_message 'BindException: Address already in use'
136 exit_on_log_file_message 'server is unhealthy'
138 echo "Fetching Karaf logs"
139 # TODO: Move instead of copy? Gzip?
140 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" .
141 cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" .
143 echo "Kill controller"
144 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
146 echo "Bug 4628: Detecting misplaced config files"
147 pushd "${WORKSPACE}/${BUNDLEFOLDER}" || exit
148 XMLS_FOUND="$(echo *.xml)"
150 if [ "$XMLS_FOUND" != "*.xml" ]; then
151 echo "Bug 4628 confirmed."
152 ## TODO: Uncomment the following when ODL is fixed, to guard against regression.
155 echo "Bug 4628 not detected."
158 # vim: ts=4 sw=4 sts=4 et ft=sh :