Recognize openjdk17 in integration scripts
[releng/builder.git] / jjb / integration / distribution / distribution-check-bootup.sh
index 9e988fe3b4a5939f48239191f4f2628d446d94a5..f10c09a56ef3dc5a9777098d63a338f34cef9edc 100644 (file)
@@ -1,15 +1,27 @@
-CONTROLLERMEM="3072m"
-ACTUALFEATURES="odl-integration-all"
+#!/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
 
-if [[ ! -z "${CONTROLLERFEATURES}" ]]; then
-    ACTUALFEATURES="odl-integration-all,${CONTROLLERFEATURES}"
+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 "Fetch the distribution..."
 if  [[ -z "${BUNDLE_PATH}" ]]; then
@@ -24,23 +36,28 @@ unzip -q "${BUNDLE}"
 echo "Configuring the startup features..."
 FEATURESCONF="${WORKSPACE}/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg"
 FEATURE_TEST_STRING="features-test"
-if [[ "$KARAF_VERSION" == "karaf3" ]]; then
-    FEATURE_TEST_STRING="features-integration-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
 
-sed -ie "s%\(featuresRepositories= \|featuresRepositories = \)%featuresRepositories = mvn:org.opendaylight.integration/${FEATURE_TEST_STRING}/${BUNDLE_VERSION}/xml/features,%g" ${FEATURESCONF}
+# 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 [[ ! -z "${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
+    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}"
+    # 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"
@@ -55,16 +72,17 @@ cat "${MEMCONF}"
 echo "Listing all open ports on controller system"
 netstat -pnatu
 
-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"
@@ -72,10 +90,10 @@ 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
+mkdir -p "${WORKSPACE}/${BUNDLEFOLDER}/data/log"
 
 echo "Starting controller..."
-${WORKSPACE}/${BUNDLEFOLDER}/bin/start
+"${WORKSPACE}/${BUNDLEFOLDER}/bin/start"
 
 function dump_log_and_exit {
     echo "Dumping first 500K bytes of karaf log..."
@@ -90,10 +108,10 @@ function dump_log_and_exit {
 echo "Waiting up to 6 minutes for controller to come up, checking every 5 seconds..."
 COUNT="0"
 while true; do
-    COUNT=$(( ${COUNT} + 5 ))
+    COUNT=$(( COUNT + 5 ))
     sleep 5
     echo "already waited ${COUNT} seconds..."
-    if grep --quiet 'org.opendaylight.infrautils.ready-impl.*System ready' "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
+    if grep --quiet 'org.opendaylight.infrautils.*System ready' "${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log"; then
         echo "Controller is UP"
         break
     elif (( "${COUNT}" >= "360" )); then
@@ -133,11 +151,12 @@ 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}" || exit
-XMLS_FOUND="$(echo *.xml)"
+XMLS_FOUND="$(echo -- *.xml)"
 popd || exit
 if [ "$XMLS_FOUND" != "*.xml" ]; then
     echo "Bug 4628 confirmed."