- res="$(__do_curl_to_api ECS GET $query)"
- status=${res:${#res}-3}
-
- if [ $status -ne $1 ]; then
- echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
- ((RES_FAIL++))
- __check_stop_at_error
- return 1
- fi
- if [ $# -eq 3 ]; then
- body=${res:0:${#res}-3}
- targetJson="{\"operational_state\": \"$3\"}"
- echo " TARGET JSON: $targetJson" >> $HTTPLOG
- res=$(python3 ../common/compare_json.py "$targetJson" "$body")
-
- if [ $res -ne 0 ]; then
- echo -e $RED" FAIL, returned body not correct"$ERED
- ((RES_FAIL++))
- __check_stop_at_error
- return 1
+ start=$SECONDS
+ for (( ; ; )); do
+ res="$(__do_curl_to_api ECS GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $# -eq 4 ]; then
+ duration=$((SECONDS-start))
+ echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
+ if [ $duration -gt $4 ]; then
+ echo ""
+ duration=-1 #Last iteration
+ fi
+ else
+ duration=-1 #single test, no wait