Skip to content

Commit

Permalink
Add integration test for label_replace
Browse files Browse the repository at this point in the history
  • Loading branch information
arnikola committed Oct 6, 2019
1 parent 42ad45d commit c73dd15
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion scripts/docker-integration-tests/query_fanout/warning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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\""

0 comments on commit c73dd15

Please sign in to comment.