Include retry logic for checking status

Change-Id: Ic6a46403a5430e91759fb6f254aaa39925f6c533
This commit is contained in:
stewie925 2019-09-24 10:43:35 -07:00 committed by Hari
parent 8564e335b9
commit 71fdc5fdb7
1 changed files with 26 additions and 19 deletions

View File

@ -21,7 +21,6 @@ set -ex
# Come up with a ranger agent payload
region="${REGION_NAME}"
url="${RANGER_SERVICE_URL}"
expected_on_execution="${END_STATUS_KEY}"
UUID=$(python -c 'import uuid; print uuid.uuid1()')
PAYLOAD="{\"ord-notifier\":{
@ -37,27 +36,35 @@ PAYLOAD="{\"ord-notifier\":{
}"
function assertContains()
{
expected=$1
msg=$2
{
n=0
expected=$1
until [ $n -ge 5 ]
do
if [ "$expected" == "Submitted" ]; then
msg="$(curl -i -X POST -d "${PAYLOAD}" $url --header "Content-type:application/json")"
else
msg="$(curl -s "$url?Id=$UUID")"
fi
if echo "$msg" | grep -q "$expected"; then
echo "***TEST IS PASSED: EXPECTED=$expected is in Responce"
break
else
if [ "$n" == "5" ]; then
echo "***FAILED: EXPECTED=$expected in Responce"
exit 1
fi
n=$[$n+1]
sleep 15
fi
done
}
if echo "$msg" | grep -q "$expected"; then
echo "***TEST IS PASSED: EXPECTED=$expected is in Responce"
else
echo "***FAILED: EXPECTED=$expected in Responce"
exit 1
fi
}
request_submit_response="$(curl -i -X POST -d "${PAYLOAD}" $url --header "Content-type:application/json")"
expected_on_request="Submitted"
assertContains "${expected_on_request}" "${request_submit_response}"
assertContains "Submitted"
# Ranger agent support pull or push both model.
# once request submitted openstack take some time to synchronize.
# we are pulling status for testing purpose by sleeping thread for 15 sec
sleep 15
resource_status_from_engine="$(curl -s "$url?Id=$UUID")"
assertContains "${expected_on_execution}" "$resource_status_from_engine"
assertContains "${END_STATUS_KEY}"