Fix SC2059 for ShellCheck 0.4.4, printf formatting
[releng/builder.git] / jjb / integration / distribution / distribution-check-bootup.sh
index ece342a28a590b228a267f0f3649adc61dcca2fe..36bbfd705d6075366f51cfdc7768e4bf5199f073 100644 (file)
@@ -28,14 +28,18 @@ 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}/${BUNDLE_VERSION}/xml/features,%g" ${FEATURESCONF}
+sed -ie "s%\(featuresRepositories= \|featuresRepositories = \)%featuresRepositories = mvn:org.opendaylight.integration/${FEATURE_TEST_STRING}/${BUNDLE_VERSION}/xml/features,%g" ${FEATURESCONF}
 
 if [[ ! -z "${REPO_URL}" ]]; then
-   sed -ie "s%featuresRepositories =%featuresRepositories = ${REPO_URL},%g" ${FEATURESCONF}
+   # 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..."
@@ -83,39 +87,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
+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