@@ -17,23 +17,6 @@ delete_cluster_exit () {
1717
1818trap delete_cluster_exit EXIT
1919
20- retry () {
21- local try=0
22- local max=5
23- local delay=5
24- while [ $try -lt $max ]; do
25- try=$(( try + 1 ))
26- echo " Try $try of $* ..."
27- $* && RC=$? || RC=$?
28- if [ $RC -eq 0 ]; then
29- return 0
30- else
31- sleep $delay
32- fi
33- done
34- return 1
35- }
36-
3720wait_for_pods_started () {
3821 for i in {1..50}
3922 do
@@ -96,6 +79,49 @@ wait_for_running () {
9679 set -e
9780}
9881
82+ add_todo () {
83+ set +e
84+
85+ local running=0
86+ local check=0
87+ local check_limit=10
88+
89+ url=$1
90+ title=$2
91+
92+ try=0
93+ rc=1
94+
95+ while [ $rc -ne 0 ] && [ $try -lt 10 ]; do
96+ try=$(( try + 1 ))
97+ curl " $url " \
98+ -H ' Accept: application/json, text/plain, */*' \
99+ -H ' Accept-Language: en-US,en;q=0.9' \
100+ -H ' Connection: keep-alive' \
101+ -H ' Content-Type: application/json' \
102+ -H ' Origin: http://localhost' \
103+ -H ' Referer: http://localhost/' \
104+ -H ' Sec-Fetch-Dest: empty' \
105+ -H ' Sec-Fetch-Mode: cors' \
106+ -H ' Sec-Fetch-Site: same-site' \
107+ -H ' User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0' \
108+ -H ' sec-ch-ua: "Microsoft Edge";v="135", "Not-A.Brand";v="8", "Chromium";v="135"' \
109+ -H ' sec-ch-ua-mobile: ?0' \
110+ -H ' sec-ch-ua-platform: "Windows"' \
111+ --data-raw " {\" title\" :\" $title \" ,\" completed\" :false}"
112+ rc=$?
113+
114+ if [ $rc -ne 0 ]; then
115+ echo " Error adding todo, retrying..."
116+ sleep 5
117+ fi
118+ done
119+
120+ set -e
121+
122+ return $rc
123+ }
124+
99125export STACK_USE_BUILTIN_STACK=true
100126
101127# Test basic stack deploy
@@ -153,21 +179,7 @@ wait_for_running 3
153179
154180# Add a todo
155181todo_title=" 79b06705-b402-431a-83a3-a634392d2754"
156- retry curl ' http://localhost/api/todos' \
157- -H ' Accept: application/json, text/plain, */*' \
158- -H ' Accept-Language: en-US,en;q=0.9' \
159- -H ' Connection: keep-alive' \
160- -H ' Content-Type: application/json' \
161- -H ' Origin: http://localhost' \
162- -H ' Referer: http://localhost/' \
163- -H ' Sec-Fetch-Dest: empty' \
164- -H ' Sec-Fetch-Mode: cors' \
165- -H ' Sec-Fetch-Site: same-site' \
166- -H ' User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0' \
167- -H ' sec-ch-ua: "Microsoft Edge";v="135", "Not-A.Brand";v="8", "Chromium";v="135"' \
168- -H ' sec-ch-ua-mobile: ?0' \
169- -H ' sec-ch-ua-platform: "Windows"' \
170- --data-raw " {\" title\" :\" $todo_title \" ,\" completed\" :false}"
182+ add_todo http://localhost/api/todos " $todo_title "
171183
172184# Check that it exists
173185if [ " $todo_title " != " $( curl -s http://localhost/api/todos | jq -r ' .[] | select(.id == 1) | .title' ) " ]; then
0 commit comments