From 9c8de628b85678adabc1efde785fe31e215730e4 Mon Sep 17 00:00:00 2001 From: Robert Choi Date: Mon, 27 Jun 2022 11:52:52 +0900 Subject: [PATCH] add timeout to busy-wait loops --- tests/tks-e2e.yaml | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/tests/tks-e2e.yaml b/tests/tks-e2e.yaml index 46b249bc..0dd1fbdb 100644 --- a/tests/tks-e2e.yaml +++ b/tests/tks-e2e.yaml @@ -217,7 +217,8 @@ spec: echo "* Create $CL_NAME cluster" tks cluster create ${CL_NAME} - while : + threshold=30 + for i in $(seq 1 $threshold) do CL_STATUS=$(tks cluster list | grep $CL_NAME | awk '{ print $3 }') if [ "$CL_STATUS" = "RUNNING" ]; then @@ -225,6 +226,11 @@ spec: elif [ "$CL_STATUS" = "ERROR" ]; then exit 1 fi + + if [ "$i" -ge "$threshold" ]; then + echo "Timed out waiting for user-cluster to be ready." + exit 1 + fi sleep 1m done @@ -258,7 +264,8 @@ spec: tks cluster delete {{inputs.parameters.cluster_id}} - while : + threshold=30 + for i in $(seq 1 $threshold) do CL_EXIST=$(tks cluster list | grep {{inputs.parameters.cluster_id}} | wc -l) if [ "$CL_EXIST" = "0" ]; then @@ -271,6 +278,11 @@ spec: elif [ "$CL_STATUS" = "ERROR" ]; then exit 1 fi + + if [ "$i" -ge "$threshold" ]; then + echo "Timed out waiting for user-cluster to be deleted." + exit 1 + fi sleep 1m done @@ -291,7 +303,8 @@ spec: tks service create --cluster-id {{inputs.parameters.cluster_id}} --service-name {{inputs.parameters.service_name}} - while : + threshold=30 + for i in $(seq 1 $threshold) do SVC_STATUS=$(tks service list {{inputs.parameters.cluster_id}} | grep {{inputs.parameters.service_name}} | awk '{print $3}') if [ "$SVC_STATUS" = "APP_GROUP_RUNNING" ]; then @@ -299,6 +312,11 @@ spec: elif [ "$SVC_STATUS" = "APP_GROUP_ERROR" ]; then exit 1 fi + + if [ "$i" -ge "$threshold" ]; then + echo "Timed out waiting for {{inputs.parameters.service_name}} to be ready." + exit 1 + fi sleep 1m done @@ -334,7 +352,8 @@ spec: tks service delete {{inputs.parameters.svc_id}} - while : + threshold=30 + for i in $(seq 1 $threshold) do SVC_EXIST=$(tks service list {{inputs.parameters.cluster_id}} | grep {{inputs.parameters.svc_id}} | wc -l) if [ "$SVC_EXIST" = "0" ]; then @@ -347,6 +366,11 @@ spec: elif [ "$SVC_STATUS" = "APP_GROUP_ERROR" ]; then exit 1 fi + + if [ "$i" -ge "$threshold" ]; then + echo "Timed out waiting for {{inputs.parameters.service_name}} to be deleted." + exit 1 + fi sleep 1m done