1919
2020extract_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
89114
90115# Before the test starts, extract initial metrics values from the /metrics endpoint of the operator
91116extract_metrics_data
117+
118+ set -eu
119+
92120INITIAL_GET_REQUESTS=$GET_REQUESTS
93121INITIAL_PUT_REQUESTS=$PUT_REQUESTS
94122INITIAL_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