Skip to content

Commit 8fcc10b

Browse files
committed
Combine metrics for difference HTTP error codes from metrics file
Signed-off-by: Jonathan West <[email protected]>
1 parent 1698ef7 commit 8fcc10b

File tree

1 file changed

+36
-8
lines changed

1 file changed

+36
-8
lines changed

hack/run-rollouts-manager-e2e-tests.sh

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ set -u
1919

2020
extract_metrics_data() {
2121

22+
set +eu
23+
2224
TMP_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
2325

2426
while true; do
@@ -39,20 +41,43 @@ extract_metrics_data() {
3941

4042
curl http://localhost:8080/metrics -o "$TMP_DIR/rollouts-metric-endpoint-output.txt"
4143

42-
GET_REQUESTS=`cat "$TMP_DIR/rollouts-metric-endpoint-output.txt" | grep "rest_client_requests_total" | grep "GET" | rev | cut -d' ' -f1 | rev`
43-
PUT_REQUESTS=`cat "$TMP_DIR/rollouts-metric-endpoint-output.txt" | grep "rest_client_requests_total" | grep "PUT" | grep -v "409" | rev | cut -d' ' -f1 | rev`
44-
POST_REQUESTS=`cat "$TMP_DIR/rollouts-metric-endpoint-output.txt" | grep "rest_client_requests_total" | grep "POST" | rev | cut -d' ' -f1 | rev`
44+
echo "* Metrics gathered raw output ---------------------------------------------------------------"
45+
cat "$TMP_DIR/rollouts-metric-endpoint-output.txt"
46+
echo "---------------------------------------------------------------------------------------------"
47+
48+
GET_REQUESTS=`cat "$TMP_DIR/rollouts-metric-endpoint-output.txt" | grep "rest_client_requests_total" | grep "GET" | grep "200" | rev | cut -d' ' -f1 | rev`
49+
50+
PUT_REQUESTS_200=`cat "$TMP_DIR/rollouts-metric-endpoint-output.txt" | grep "rest_client_requests_total" | grep "PUT" | grep "200" | rev | cut -d' ' -f1 | rev`
51+
52+
# 409 Conflict error code
53+
PUT_REQUESTS_409=`cat "$TMP_DIR/rollouts-metric-endpoint-output.txt" | grep "rest_client_requests_total" | grep "PUT" | grep "409" | rev | cut -d' ' -f1 | rev`
54+
55+
# 201 Created error code
56+
POST_REQUESTS_201=`cat "$TMP_DIR/rollouts-metric-endpoint-output.txt" | grep "rest_client_requests_total" | grep "POST" | grep "201" | rev | cut -d' ' -f1 | rev`
57+
58+
# 409 Conflict error code
59+
POST_REQUESTS_409=`cat "$TMP_DIR/rollouts-metric-endpoint-output.txt" | grep "rest_client_requests_total" | grep "POST" | grep "409" | rev | cut -d' ' -f1 | rev`
4560

4661
if [[ "$GET_REQUESTS" == "" ]]; then
4762
GET_REQUESTS=0
4863
fi
49-
if [[ "$POST_REQUESTS" == "" ]]; then
50-
POST_REQUESTS=0
64+
65+
if [[ "$POST_REQUESTS_201" == "" ]]; then
66+
POST_REQUESTS_201=0
67+
fi
68+
if [[ "$POST_REQUESTS_409" == "" ]]; then
69+
POST_REQUESTS_409=0
70+
fi
71+
72+
if [[ "$PUT_REQUESTS_200" == "" ]]; then
73+
PUT_REQUESTS_200=0
5174
fi
52-
if [[ "$PUT_REQUESTS" == "" ]]; then
53-
PUT_REQUESTS=0
75+
if [[ "$PUT_REQUESTS_409" == "" ]]; then
76+
PUT_REQUESTS_409=0
5477
fi
5578

79+
PUT_REQUESTS=`expr $PUT_REQUESTS_200 + $PUT_REQUESTS_409`
80+
POST_REQUESTS=`expr $POST_REQUESTS_201 + $POST_REQUESTS_409`
5681

5782
# 2) Extract the # of RolloutManager reconciles
5883

@@ -89,6 +114,9 @@ fi
89114

90115
# Before the test starts, extract initial metrics values from the /metrics endpoint of the operator
91116
extract_metrics_data
117+
118+
set -eu
119+
92120
INITIAL_GET_REQUESTS=$GET_REQUESTS
93121
INITIAL_PUT_REQUESTS=$PUT_REQUESTS
94122
INITIAL_POST_REQUESTS=$POST_REQUESTS
@@ -118,7 +146,7 @@ sanity_test_metrics_data() {
118146

119147
extract_metrics_data
120148

121-
set -x
149+
set -eux
122150

123151
FINAL_GET_REQUESTS=$GET_REQUESTS
124152
FINAL_PUT_REQUESTS=$PUT_REQUESTS

0 commit comments

Comments
 (0)