Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add timeout to busy-wait loops #101

Merged
merged 1 commit into from
Jun 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions tests/tks-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,20 @@ 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
break
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

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -291,14 +303,20 @@ 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
break
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

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down