X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Fintegration%2Fdistribution%2Fdistribution-check-bootup.sh;h=f10c09a56ef3dc5a9777098d63a338f34cef9edc;hb=4a923310adf468e0b70acfa2456660b82b812bc4;hp=d4ffea9cdd3bcff8939ddbbbdddb799aa92269f9;hpb=8b679b18fa5c62273ae54f88ae8b82241c94ca7f;p=releng%2Fbuilder.git diff --git a/jjb/integration/distribution/distribution-check-bootup.sh b/jjb/integration/distribution/distribution-check-bootup.sh index d4ffea9cd..f10c09a56 100644 --- a/jjb/integration/distribution/distribution-check-bootup.sh +++ b/jjb/integration/distribution/distribution-check-bootup.sh @@ -1,32 +1,63 @@ +#!/bin/bash +# do not add integration features in MRI projects +if [[ "$KARAF_PROJECT" == integration ]]; then + if [[ -n "${CONTROLLERFEATURES}" ]]; then + ACTUALFEATURES="odl-integration-all,${CONTROLLERFEATURES}" + else + ACTUALFEATURES="odl-integration-all" + fi +else + ACTUALFEATURES="${CONTROLLERFEATURES}" +fi -CONTROLLERMEM="3072m" -ACTUALFEATURES="odl-integration-all" -BUNDLEVERSION="$(xpath distribution/pom.xml '/project/version/text()' 2> /dev/null)" -BUNDLEFOLDER="${KARAF_ARTIFACT}-${BUNDLEVERSION}" -BUNDLE="${BUNDLEFOLDER}.zip" -BUNDLE_PATH="/tmp/r/org/opendaylight/integration/${KARAF_ARTIFACT}/${BUNDLEVERSION}/${BUNDLE}" +if [[ "${JOB_NAME}" == *"distribution-sanity"* ]]; then + CONTROLLERMEM="4096m" +else + CONTROLLERMEM="3072m" +fi echo "Kill any controller running" +# shellcheck disable=SC2009 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh echo "Clean Existing distribution" -rm -rf ${BUNDLEFOLDER} +rm -rf "${BUNDLEFOLDER}" -echo "Copying the distribution..." -cp "${BUNDLE_PATH}" . +echo "Fetch the distribution..." +if [[ -z "${BUNDLE_PATH}" ]]; then + wget --progress=dot:mega "${ACTUAL_BUNDLE_URL}" +else + cp "${BUNDLE_PATH}" . +fi echo "Extracting the new controller..." unzip -q "${BUNDLE}" echo "Configuring the startup features..." FEATURESCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg" -# Add test feature repo if Karaf 4. -sed -ie "s%mvn:org.opendaylight.integration/features-index/${BUNDLEVERSION}/xml/features%mvn:org.opendaylight.integration/features-index/${BUNDLEVERSION}/xml/features,mvn:org.opendaylight.integration/features-test/${BUNDLEVERSION}/xml/features%g" "${FEATURESCONF}" -# Add test feature repo if Karaf 3. -sed -ie "s%mvn:org.opendaylight.integration/features-integration-index/${BUNDLEVERSION}/xml/features%mvn:org.opendaylight.integration/features-integration-index/${BUNDLEVERSION}/xml/features,mvn:org.opendaylight.integration/features-integration-test/${BUNDLEVERSION}/xml/features%g" "${FEATURESCONF}" -# Add actual boot features. -sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" "${FEATURESCONF}" -cat "${FEATURESCONF}" +FEATURE_TEST_STRING="features-test" +FEATURE_TEST_VERSION="$BUNDLE_VERSION" +if [[ "$KARAF_ARTIFACT" == "opendaylight" ]]; then + FEATURE_TEST_VERSION="$(sed -r "s%^([0-9]+)\.([0-9]+)\.0(.*)%0.\1.\2\3%" <<<"$BUNDLE_VERSION")" +fi + +# only replace feature repo in integration/distro, MRI projects need to pull in +# the features they need by themselves +if [[ "$KARAF_PROJECT" == integration ]]; then + sed -ie "s%\(featuresRepositories= \|featuresRepositories = \)%featuresRepositories = mvn:org.opendaylight.integration/${FEATURE_TEST_STRING}/${FEATURE_TEST_VERSION}/xml/features,%g" "${FEATURESCONF}" + + if [[ -n "${REPO_URL}" ]]; then + # sed below will fail if it finds space between feature repos. + REPO_URL_NO_SPACE="$(echo -e "${REPO_URL}" | tr -d '[:space:]')" + sed -ie "s%featuresRepositories = %featuresRepositories = ${REPO_URL_NO_SPACE},%g" "${FEATURESCONF}" + fi + + # Add actual boot features. + # sed below will fail if it finds space between feature repos. + FEATURES_NO_SPACE="$(echo -e "${ACTUALFEATURES}" | tr -d '[:space:]')" + sed -ie "s/\(featuresBoot= \|featuresBoot = \)/featuresBoot = ${FEATURES_NO_SPACE},/g" "${FEATURESCONF}" + cat "${FEATURESCONF}" +fi echo "Configuring the log..." LOGCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg" @@ -41,19 +72,17 @@ cat "${MEMCONF}" echo "Listing all open ports on controller system" netstat -pnatu -echo "redirected karaf console output to karaf_console.log" -export KARAF_REDIRECT="${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" - -if [ "${JDKVERSION}" == 'openjdk8' ]; then +if [ "$JDKVERSION" == 'openjdk17' ]; then + echo "Preparing for JRE Version 17" + JAVA_HOME="/usr/lib/jvm/java-17-openjdk" +elif [ "$JDKVERSION" == 'openjdk11' ]; then + echo "Preparing for JRE Version 11" + JAVA_HOME="/usr/lib/jvm/java-11-openjdk" +elif [ "${JDKVERSION}" == 'openjdk8' ]; then echo "Setting the JRE Version to 8" # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start. # 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 export JAVA_HOME='/usr/lib/jvm/java-1.8.0' -elif [ "${JDKVERSION}" == 'openjdk7' ]; then - echo "Setting the JRE Version to 7" - # dynamic_verify does not allow sudo, JAVA_HOME should be enough for karaf start. - # 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 - export JAVA_HOME='/usr/lib/jvm/java-1.7.0' fi readlink -e "${JAVA_HOME}/bin/java" echo "JDK Version should be overriden by JAVA_HOME" @@ -61,51 +90,36 @@ java -version echo "Redirecting karaf console output to karaf_console.log" export KARAF_REDIRECT="${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" +mkdir -p "${WORKSPACE}/${BUNDLEFOLDER}/data/log" echo "Starting controller..." -${WORKSPACE}/${BUNDLEFOLDER}/bin/start - -# No need for verbose printing during repeating operations. -set +x - -echo "Waiting for controller to come up..." -COUNT=0 -while true; do - RESP="$(curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null || true)" - echo "${RESP}" - if [[ "${RESP}" == *"200"* ]]; then - echo Controller is UP - break - elif (( "${COUNT}" > 600 )); then - echo Timeout Controller DOWN - echo "Dumping Karaf log..." - cat "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" - echo "Listing all open ports on controller system" - netstat -pnatu - exit 1 - else - COUNT=$(( ${COUNT} + 1 )) - sleep 1 - if [[ $(($COUNT % 5)) == 0 ]]; then - echo already waited ${COUNT} seconds... - fi - fi -done +"${WORKSPACE}/${BUNDLEFOLDER}/bin/start" + +function dump_log_and_exit { + echo "Dumping first 500K bytes of karaf log..." + head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" + echo "Dumping last 500K bytes of karaf log..." + tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" + cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" . + cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" . + exit 1 +} -echo "loading many features at once. Need to allow time for problems to show up in logs. cool down for 5 min ..." -COUNT="300" +echo "Waiting up to 6 minutes for controller to come up, checking every 5 seconds..." +COUNT="0" while true; do - if (( "${COUNT}" <= "0" )); then + COUNT=$(( COUNT + 5 )) + sleep 5 + echo "already waited ${COUNT} seconds..." + if grep --quiet 'org.opendaylight.infrautils.*System ready' "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then + echo "Controller is UP" break + elif (( "${COUNT}" >= "360" )); then + echo "Timeout Controller DOWN" + dump_log_and_exit fi - echo "${COUNT} seconds yet to wait..." - sleep 10 - COUNT="$(( ${COUNT} - 10 ))" done -# End of repeating operations, enable verbose printing. -set -x - # echo "Checking OSGi bundles..." # sshpass seems to fail with new karaf version # sshpass -p karaf ${WORKSPACE}/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list' @@ -117,28 +131,17 @@ function exit_on_log_file_message { echo "looking for \"$1\" in karaf.log file" if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then echo ABORTING: found "$1" - echo "Dumping first 500K bytes of karaf log..." - head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" - echo "Dumping last 500K bytes of karaf log..." - tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" - cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" . - cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" . - exit 1 + dump_log_and_exit fi echo "looking for \"$1\" in karaf_console.log file" if grep --quiet "$1" "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log"; then echo ABORTING: found "$1" - echo "Dumping first 500K bytes of karaf log..." - head --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" - echo "Dumping last 500K bytes of karaf log..." - tail --bytes=500K "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" - cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" . - cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" . - exit 1 + dump_log_and_exit fi } +exit_on_log_file_message 'Error installing boot feature repository' exit_on_log_file_message 'BindException: Address already in use' exit_on_log_file_message 'server is unhealthy' @@ -148,12 +151,13 @@ cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log" . cp "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf_console.log" . echo "Kill controller" +# shellcheck disable=SC2009 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh echo "Bug 4628: Detecting misplaced config files" -pushd "${WORKSPACE}/${BUNDLEFOLDER}" -XMLS_FOUND="$(echo *.xml)" -popd +pushd "${WORKSPACE}/${BUNDLEFOLDER}" || exit +XMLS_FOUND="$(echo -- *.xml)" +popd || exit if [ "$XMLS_FOUND" != "*.xml" ]; then echo "Bug 4628 confirmed." ## TODO: Uncomment the following when ODL is fixed, to guard against regression.