Merge "make test_with_retry a function"

This commit is contained in:
Jenkins 2015-06-26 20:42:08 +00:00 committed by Gerrit Code Review
commit 71e51c09c0
2 changed files with 19 additions and 6 deletions

View File

@ -1967,6 +1967,19 @@ function stop_service {
fi fi
} }
# Test with a finite retry loop.
#
function test_with_retry {
local testcmd=$1
local failmsg=$2
local until=${3:-10}
local sleep=${4:-0.5}
if ! timeout $until sh -c "while ! $testcmd; do sleep $sleep; done"; then
die $LINENO "$failmsg"
fi
}
# Restore xtrace # Restore xtrace
$XTRACE $XTRACE

View File

@ -696,9 +696,10 @@ function start_neutron_service_and_check {
if is_ssl_enabled_service "neutron"; then if is_ssl_enabled_service "neutron"; then
ssl_ca="--ca-certificate=${SSL_BUNDLE_FILE}" ssl_ca="--ca-certificate=${SSL_BUNDLE_FILE}"
fi fi
if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget ${ssl_ca} --no-proxy -q -O- $service_protocol://$Q_HOST:$service_port; do sleep 1; done"; then
die $LINENO "Neutron did not start" local testcmd="wget ${ssl_ca} --no-proxy -q -O- $service_protocol://$Q_HOST:$service_port"
fi test_with_retry "$testcmd" "Neutron did not start" $SERVICE_TIMEOUT
# Start proxy if enabled # Start proxy if enabled
if is_service_enabled tls-proxy; then if is_service_enabled tls-proxy; then
start_tls_proxy '*' $Q_PORT $Q_HOST $Q_PORT_INT & start_tls_proxy '*' $Q_PORT $Q_HOST $Q_PORT_INT &
@ -1380,9 +1381,8 @@ function _ssh_check_neutron {
local timeout_sec=$5 local timeout_sec=$5
local probe_cmd = "" local probe_cmd = ""
probe_cmd=`_get_probe_cmd_prefix $from_net` probe_cmd=`_get_probe_cmd_prefix $from_net`
if ! timeout $timeout_sec sh -c "while ! $probe_cmd ssh -o StrictHostKeyChecking=no -i $key_file ${user}@$ip echo success; do sleep 1; done"; then local testcmd="$probe_cmd ssh -o StrictHostKeyChecking=no -i $key_file ${user}@$ip echo success"
die $LINENO "server didn't become ssh-able!" test_with_retry "$testcmd" "server $ip didn't become ssh-able" $timeout_sec
fi
} }
# Neutron 3rd party programs # Neutron 3rd party programs