Add missing silicon jobs for distribution
[releng/builder.git] / jjb / integration / distribution / distribution-check-bootup.sh
index 35076e1fc09ad550a9f0feae86a256a093cd2522..84ea9ea6e10378054a6f192971763b0ddc3bb617 100644 (file)
@@ -1,34 +1,52 @@
+#!/bin/bash
+if [[ -n "${CONTROLLERFEATURES}" ]]; then
+    ACTUALFEATURES="odl-integration-all,${CONTROLLERFEATURES}"
+else
+    ACTUALFEATURES="odl-integration-all"
+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"
-FEATURE_TEST_STRING="features-integration-test"
-if [[ "$KARAF_VERSION" == "karaf4" ]]; then
-    FEATURE_TEST_STRING="features-test"
+FEATURE_TEST_STRING="features-test"
+if [[ "$KARAF_VERSION" == "karaf3" ]]; then
+    FEATURE_TEST_STRING="features-integration-test"
 fi
 
-sed -ie "s%\(featuresRepositories=\|featuresRepositories =\)%featuresRepositories = mvn:org.opendaylight.integration/${FEATURE_TEST_STRING}/${BUNDLEVERSION}/xml/features,%g" ${FEATURESCONF}
+sed -ie "s%\(featuresRepositories= \|featuresRepositories = \)%featuresRepositories = mvn:org.opendaylight.integration/${FEATURE_TEST_STRING}/${BUNDLE_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 -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" "${FEATURESCONF}"
+# 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}"
 
 echo "Configuring the log..."
@@ -44,20 +62,14 @@ 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"
-mkdir -p ${WORKSPACE}/${BUNDLEFOLDER}/data/log
-
-if [ "${JDKVERSION}" == 'openjdk8' ]; then
+if [ "$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"
@@ -65,13 +77,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
-
-# No need for verbose printing during repeating operations.
-set +x
+"${WORKSPACE}/${BUNDLEFOLDER}/bin/start"
 
 function dump_log_and_exit {
     echo "Dumping first 500K bytes of karaf log..."
@@ -83,41 +92,20 @@ function dump_log_and_exit {
     exit 1
 }
 
-echo "Waiting up to 5 minutes for controller to come up, checking every 5 seconds..."
-if [ "${DISTROSTREAM}" == "carbon" ] || [ "${DISTROSTREAM}" == "nitrogen" ]; then
-    # Only oxygen and above have the infrautils.ready feature, so using REST API to determine if the controller is ready.
-    COUNT="0"
-    while true; do
-        COUNT=$(( ${COUNT} + 5 ))
-        sleep 5
-        echo "already waited ${COUNT} seconds..."
-        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}" > "300" )); then
-            echo "Timeout Controller DOWN"
-            dump_log_and_exit
-        fi
-    done
-else
-    COUNT="0"
-    while true; do
-        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
-            echo "Controller is UP"
-            break
-        elif (( "${COUNT}" > "300" )); then
-            echo "Timeout Controller DOWN"
-            dump_log_and_exit
-        fi
-    done
-fi
-
-set -x
+echo "Waiting up to 6 minutes for controller to come up, checking every 5 seconds..."
+COUNT="0"
+while true; do
+    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
+done
 
 # echo "Checking OSGi bundles..."
 # sshpass seems to fail with new karaf version
@@ -140,6 +128,7 @@ function exit_on_log_file_message {
     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'
 
@@ -149,11 +138,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."