33set -ueo pipefail
44
55wait_for_url () {
6- echo " --- Waiting for HTTP connection available"
7- timeout -s TERM 30s bash -c \
8- ' while [[ "$(curl -s -o /dev/null -L -w ' ' %{http_code}' ' ${0})" != "200" ]]; do \
9- echo "Waiting for ${0}" && sleep 2; \
10- done' ${1}
11- curl -s -I -X GET $1
6+ curl -s --retry-connrefused --retry 5 --retry-delay 2 --retry-max-time 30 \
7+ --max-time 1 -L -I -X GET " ${1} "
128}
139
14- echo " == Setup"
15-
1610# Stop all background jobs on exit
17- trap ' pkill -15 -f "dist/toxiproxy-server$"; pkill -15 -f "exe/endpoint$"' EXIT SIGINT SIGTERM
11+ trap ' pkill -15 -f "dist/toxiproxy-server$"; pkill -15 -f "exe/endpoint$"' \
12+ EXIT SIGINT SIGTERM
1813
1914echo " === Starting Web service"
2015
@@ -31,7 +26,8 @@ wait_for_url http://localhost:8474/version
3126
3227echo " === Test client to manipulate proxy"
3328
34- ./dist/toxiproxy-cli -h http://localhost:8474 create -l localhost:20000 -u localhost:20002 shopify_http
29+ ./dist/toxiproxy-cli -h http://localhost:8474 \
30+ create -l localhost:20000 -u localhost:20002 shopify_http
3531./dist/toxiproxy-cli list
3632./dist/toxiproxy-cli toggle shopify_http
3733./dist/toxiproxy-cli inspect shopify_http
@@ -50,76 +46,103 @@ echo -e "-----------------\n"
5046
5147echo " === Latency toxic downstream"
5248
53- ./dist/toxiproxy-cli toxic add --downstream --type latency --toxicName " latency_downstream" \
54- --attribute " latency=1000" --attribute=" jitter=50" \
55- --toxicity 0.99 shopify_http
49+ ./dist/toxiproxy-cli toxic add --downstream \
50+ --type=latency \
51+ --toxicName=" latency_downstream" \
52+ --attribute=" latency=1000" \
53+ --attribute=" jitter=50" \
54+ --toxicity=0.99 \
55+ shopify_http
5656./dist/toxiproxy-cli inspect shopify_http
5757
5858go test -bench=. ./test/e2e -v
5959
60- ./dist/toxiproxy-cli toxic update --toxicName " latency_downstream" --attribute=" jitter=20" \
61- --toxicity 0.7 shopify_http
60+ ./dist/toxiproxy-cli toxic update --toxicName=" latency_downstream" \
61+ --attribute=" jitter=20" \
62+ --toxicity=0.7 \
63+ shopify_http
6264./dist/toxiproxy-cli inspect shopify_http
6365
64- ./dist/toxiproxy-cli toxic delete --toxicName " latency_downstream" shopify_http
66+ ./dist/toxiproxy-cli toxic delete --toxicName= " latency_downstream" shopify_http
6567
6668echo -e " -----------------\n"
6769
6870echo " === Latency toxic upstream"
6971
70- ./dist/toxiproxy-cli toxic add --upstream --type latency --toxicName " latency_upstream" \
71- --attribute " latency=1000" --attribute " jitter=50" \
72- --toxicity 1 shopify_http
72+ ./dist/toxiproxy-cli toxic add --upstream \
73+ --type=latency \
74+ --toxicName=" latency_upstream" \
75+ --attribute=" latency=1000" \
76+ --attribute=" jitter=50" \
77+ --toxicity=1 \
78+ shopify_http
7379./dist/toxiproxy-cli inspect shopify_http
7480
7581go test -bench=. ./test/e2e -v
7682
77- ./dist/toxiproxy-cli toxic update --toxicName " latency_upstream" --attribute=" jitter=20" \
78- --toxicity 0.3 shopify_http
83+ ./dist/toxiproxy-cli toxic update --toxicName=" latency_upstream" \
84+ --attribute=" jitter=20" \
85+ --toxicity=0.3 \
86+ shopify_http
7987./dist/toxiproxy-cli inspect shopify_http
8088
81- ./dist/toxiproxy-cli toxic delete --toxicName " latency_upstream" shopify_http
89+ ./dist/toxiproxy-cli toxic delete --toxicName= " latency_upstream" shopify_http
8290
8391echo -e " -----------------\n"
8492
8593echo " === Bandwidth toxic"
8694
87- ./dist/toxiproxy-cli toxic add --type bandwidth --toxicName " bandwidth_kb_per_second" \
88- --attribute " rate=1" --toxicity 0.5 shopify_http
89- ./dist/toxiproxy-cli toxic update --toxicName " bandwidth_kb_per_second" --attribute=" rate=10" \
90- --toxicity 1.0 shopify_http
95+ ./dist/toxiproxy-cli toxic add --type=bandwidth \
96+ --toxicName=" bandwidth_kb_per_second" \
97+ --attribute=" rate=1" \
98+ --toxicity=0.5 \
99+ shopify_http
100+ ./dist/toxiproxy-cli toxic update --toxicName=" bandwidth_kb_per_second" \
101+ --attribute=" rate=10" \
102+ --toxicity=1.0 \
103+ shopify_http
91104
92105go test -bench=. ./test/e2e -v
93106
94- ./dist/toxiproxy-cli toxic delete --toxicName " bandwidth_kb_per_second" shopify_http
107+ ./dist/toxiproxy-cli toxic delete --toxicName=" bandwidth_kb_per_second" \
108+ shopify_http
95109
96110echo -e " -----------------\n"
97111
98112echo " === Timeout toxic"
99113
100- ./dist/toxiproxy-cli toxic add --type timeout --toxicName " timeout_ms" \
101- --attribute " timeout=10" --toxicity 0.1 shopify_http
102- ./dist/toxiproxy-cli toxic delete --toxicName " timeout_ms" shopify_http
114+ ./dist/toxiproxy-cli toxic add --type=timeout \
115+ --toxicName=" timeout_ms" \
116+ --attribute=" timeout=10" \
117+ --toxicity=0.1 \
118+ shopify_http
119+ ./dist/toxiproxy-cli toxic delete --toxicName=" timeout_ms" shopify_http
103120
104121echo -e " -----------------\n"
105122
106123echo " === Slicer toxic"
107124
108- ./dist/toxiproxy-cli toxic add --type slicer --toxicName " slicer_us" \
109- --attribute " average_size=64" --attribute " size_variation=32" \
110- --attribute=" delay=10" --toxicity 1.0 shopify_http
125+ ./dist/toxiproxy-cli toxic add --type=slicer \
126+ --toxicName=" slicer_us" \
127+ --attribute=" average_size=64" \
128+ --attribute=" size_variation=32" \
129+ --attribute=" delay=10" \
130+ --toxicity=1.0 \
131+ shopify_http
111132go test -bench=. ./test/e2e -v
112- ./dist/toxiproxy-cli toxic delete --toxicName " slicer_us" shopify_http
133+ ./dist/toxiproxy-cli toxic delete --toxicName= " slicer_us" shopify_http
113134
114135echo -e " -----------------\n"
115136
116137echo " === Reset peer toxic"
117138
118- ./dist/toxiproxy-cli toxic add --type reset_peer --toxicName " reset_peer" \
119- --attribute " timeout=2000" \
120- --toxicity 1.0 shopify_http
139+ ./dist/toxiproxy-cli toxic add --type=reset_peer \
140+ --toxicName=" reset_peer" \
141+ --attribute=" timeout=2000" \
142+ --toxicity=1.0 \
143+ shopify_http
121144./dist/toxiproxy-cli inspect shopify_http
122- ./dist/toxiproxy-cli toxic delete --toxicName " reset_peer" shopify_http
145+ ./dist/toxiproxy-cli toxic delete --toxicName= " reset_peer" shopify_http
123146
124147echo -e " -----------------\n"
125148
0 commit comments