Merge "Update SFC netvirt CSIT with fluorine and queens"
[releng/builder.git] / jjb / integration / distribution / distribution-deploy-verify.sh
index e3e60a5a90a9fdd3ce5049dbc216fdfd89079e32..ba28c7f6474f5b0803d028a30156257aed4f27b2 100644 (file)
@@ -14,11 +14,14 @@ 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}"
+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"
+fi
+
+sed -ie "s%\(featuresRepositories=\|featuresRepositories =\)%featuresRepositories = mvn:org.opendaylight.integration/${FEATURE_TEST_STRING}/${BUNDLEVERSION}/xml/features,%g" ${FEATURESCONF}
+
 # Add actual boot features.
 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" "${FEATURESCONF}"
 cat "${FEATURESCONF}"
@@ -53,38 +56,56 @@ 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
 
-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
+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 ..."
-sleep 300
+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 "Checking OSGi bundles..."
+echo "Checking OSGi bundles..."
 # sshpass seems to fail with new karaf version
 # sshpass -p karaf ${WORKSPACE}/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
 
@@ -95,25 +116,13 @@ 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
 }
 
@@ -129,9 +138,9 @@ echo "Kill controller"
 ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sh
 
 echo "Bug 4628: Detecting misplaced config files"
-pushd "${WORKSPACE}/${BUNDLEFOLDER}"
+pushd "${WORKSPACE}/${BUNDLEFOLDER}" || exit
 XMLS_FOUND=`echo *.xml`
-popd
+popd || exit
 if [ "$XMLS_FOUND" != "*.xml" ]; then
     echo "Bug 4628 confirmed."
     ## TODO: Uncomment the following when ODL is fixed, to guard against regression.