From c73dd15e9cb5fe47f2cbb0e31a98c598581ec8fb Mon Sep 17 00:00:00 2001 From: Artem Nikolayevsky Date: Sun, 6 Oct 2019 20:00:44 +1100 Subject: [PATCH] Add integration test for label_replace --- .../query_fanout/warning.sh | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/scripts/docker-integration-tests/query_fanout/warning.sh b/scripts/docker-integration-tests/query_fanout/warning.sh index 0f30fba253..346bacf718 100755 --- a/scripts/docker-integration-tests/query_fanout/warning.sh +++ b/scripts/docker-integration-tests/query_fanout/warning.sh @@ -203,7 +203,6 @@ function test_label_values { ATTEMPTS=3 TIMEOUT=1 retry_with_backoff test_label_values 100 ATTEMPTS=3 TIMEOUT=1 retry_with_backoff test_label_values 1 max_fetch_series_limit_applied - GRAPHITE="foo.bar.$t" function write_carbon { CLUSTER=$1 @@ -307,3 +306,24 @@ ATTEMPTS=3 TIMEOUT=1 retry_with_backoff render_carbon 9 14 max_fetch_series_limi ATTEMPTS=3 TIMEOUT=1 retry_with_backoff find_carbon 16 remote_store_cluster-c_complete_tags_warning ATTEMPTS=3 TIMEOUT=1 retry_with_backoff find_carbon 9 max_fetch_series_limit_applied,remote_store_cluster-c_complete_tags_warning +# NB (arnikola): following tests are unrelated to fanout but there's no good +# testbed story yet; reported query execution errors will be added here and +# migrated to a proper testbed when it becomes available. + +function func { + QUERY=$1 + EXPECTED_COUNT=$2 + EXPECTED=$3 + RESPONSE=$(curl -sSL "http://localhost:7201/api/v1/query?query=$QUERY") + ACTUAL_COUNT=$(echo $RESPONSE | jq '.data.result | length') + ACTUAL=$(echo $RESPONSE | jq .data.result[].metric.foo | tr "\n" ":") + CONCAT=$(echo $EXPECTED | tr " " ":") + test $ACTUAL_COUNT = $EXPECTED_COUNT && test $ACTUAL = $CONCAT +} + +METRIC_NAME="quail_$t" +write_metrics coordinator-cluster-a 5 +func "label_replace($METRIC_NAME,\"foo\",\"bar_\$1\",\"val\",\"(.*)\")" label_replace 5 "\"bar_0\" \"bar_1\" \"bar_2\" \"bar_3\" \"bar_4\"" + +## Regression suite vs user reports +func "label_replace($METRIC_NAME,\"foo\",\"bar_\$1\",\"val\",\"(.*)\")+0" label_replace 5 "\"bar_0\" \"bar_1\" \"bar_2\" \"bar_3\" \"bar_4\""