Skip to content

Commit a1ab1bb

Browse files
committed
test/integration.sh: retry query
Currently, querying for the time series produced by the ruler is racey because the ruler may not yet have had a chance to generate the time series specified by the recording rules. This raciness can cause the integration test to occasionally fail. This commit adds retries to the testing of the rules. Eventually, these integration tests could be ported to the same e2e test framework used in observatorium/api. Signed-off-by: Lucas Servén Marín <[email protected]>
1 parent 95411e1 commit a1ab1bb

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

test/integration.sh

+17-7
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,28 @@ echo "-------------------------------------------"
117117
echo "- Rules File tests -"
118118
echo "-------------------------------------------"
119119

120-
query="$(curl \
121-
--fail \
122-
'http://127.0.0.1:8443/api/metrics/v1/test-oidc/api/v1/query?query=trs' \
123-
-H "Authorization: bearer $token")"
120+
i=0
121+
while [ "$i" -lt 10 ]; do
122+
query="$(curl \
123+
--fail \
124+
'http://127.0.0.1:8443/api/metrics/v1/test-oidc/api/v1/query?query=trs' \
125+
-H "Authorization: bearer $token")"
126+
127+
if [[ "$query" == *'"result":[{"metric":{"__name__":"trs","tenant_id":"1610b0c3-c509-4592-a256-a1871353dbfa"}'* ]]; then
128+
result=0
129+
break
130+
else
131+
result=1
132+
((i=i+1))
133+
sleep 5
134+
fi
135+
done
124136

125-
if [[ "$query" == *'"result":[{"metric":{"__name__":"trs","tenant_id":"1610b0c3-c509-4592-a256-a1871353dbfa"}'* ]]; then
126-
result=0
137+
if [ "$result" -eq 0 ]; then
127138
echo "-------------------------------------------"
128139
echo "- Rules File: OK -"
129140
echo "-------------------------------------------"
130141
else
131-
result=1
132142
echo "-------------------------------------------"
133143
echo "- Rules File: FAILED -"
134144
echo "-------------------------------------------"

0 commit comments

Comments
 (0)