From 4277cf67d67c865ea7a3b1097ff231eb78ba277c Mon Sep 17 00:00:00 2001 From: Jamo Luhrsen Date: Fri, 16 Mar 2018 16:30:28 -0700 Subject: [PATCH] Use infrautils.ready to check controller UP-ness infrautils.ready is only there in Oxygen and beyond so still need to leave the old logic for Carbon and Nitrogen CSIT to use. As those age out, we can remove the old logic. I think that will be in 12-18 months. Change-Id: I58b7156866d606589d45cfc87b1ccb0604ad6c02 Signed-off-by: Jamo Luhrsen --- .../integration-deploy-controller-run-test.sh | 81 +++++++++++++------ 1 file changed, 56 insertions(+), 25 deletions(-) diff --git a/jjb/integration/integration-deploy-controller-run-test.sh b/jjb/integration/integration-deploy-controller-run-test.sh index cbe81a93bb..423420abaf 100644 --- a/jjb/integration/integration-deploy-controller-run-test.sh +++ b/jjb/integration/integration-deploy-controller-run-test.sh @@ -16,10 +16,8 @@ fi if [ ${CONTROLLERSCOPE} == 'all' ]; then ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}" export CONTROLLERMEM="3072m" - COOLDOWN_PERIOD="180" else ACTUALFEATURES="odl-infrautils-ready,${CONTROLLERFEATURES}" - COOLDOWN_PERIOD="60" fi # Some versions of jenkins job builder result in feature list containing spaces @@ -154,20 +152,62 @@ if [[ "$USEFEATURESBOOT" != "True" ]]; then feature:list -i fi -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 )" - echo \$RESP - if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then - SHARD="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/jolokia/read/org.opendaylight.controller:Category=Shards,name=\member-\$1-shard-inventory-config,type=DistributedConfigDatastore)" - echo \$SHARD +if [ "${DISTROSTREAM}" == "carbon" ] || [ "${DISTROSTREAM}" == "nitrogen" ]; +then + echo "only oxygen and above have the infrautils.ready feature, so using REST API to /modules or /shards to determine if the controller is ready."; + + 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 )" + echo \$RESP + + if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then + SHARD="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/jolokia/read/org.opendaylight.controller:Category=Shards,name=\member-\$1-shard-inventory-config,type=DistributedConfigDatastore)" + echo \$SHARD + fi + + if ([[ \$RESP == *"200"* ]] && ([[ "${ENABLE_HAPROXY_FOR_NEUTRON}" != "yes" ]] || [[ \$SHARD == *'"status":200'* ]])); then + echo "Controller is UP" + break + + elif (( "\$COUNT" > "600" )); then + echo Timeout Controller DOWN + echo "Dumping first 500K bytes of karaf log..." + head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log" + echo "Dumping last 500K bytes of karaf log..." + tail --bytes=500K "/tmp/${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 - if ([[ \$RESP == *"200"* ]] && ([[ "${ENABLE_HAPROXY_FOR_NEUTRON}" != "yes" ]] || [[ \$SHARD == *'"status":200'* ]])); then - echo Controller is UP - break - elif (( "\$COUNT" > "600" )); then - echo Timeout Controller DOWN + done + +else + echo "Waiting up to 3 minutes for controller to come up, checking every 5 seconds..." + for i in {1..36}; + do sleep 5; + grep 'org.opendaylight.infrautils.ready-impl.*System ready' /tmp/${BUNDLEFOLDER}/data/log/karaf.log + if [ \$? -eq 0 ] + then + echo "Controller is UP" + break + fi + done; + + # if we ended up not finding ready status in the above loop, we can output some debugs + grep 'org.opendaylight.infrautils.ready-impl.*System ready' /tmp/${BUNDLEFOLDER}/data/log/karaf.log + if [ $? -ne 0 ] + then + echo "Timeout Controller DOWN" echo "Dumping first 500K bytes of karaf log..." head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log" echo "Dumping last 500K bytes of karaf log..." @@ -175,14 +215,8 @@ while true; do 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 +fi echo "Listing all open ports on controller system..." netstat -pnatu @@ -266,9 +300,6 @@ do fi done -echo "Cool down for ${COOLDOWN_PERIOD} seconds :)..." -sleep ${COOLDOWN_PERIOD} - echo "Generating controller variables..." for i in `seq 1 ${NUM_ODL_SYSTEM}` do -- 2.36.6