Skip to content

Commit

Permalink
[dbnode] Additional require-exhaustive test cases (#2412)
Browse files Browse the repository at this point in the history
  • Loading branch information
rallen090 authored Jun 17, 2020
1 parent 9d98e79 commit 669609d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/docker-integration-tests/prometheus/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,19 @@ function test_query_limits_applied {
echo "Test query limit with coordinator limit header"
ATTEMPTS=50 TIMEOUT=2 MAX_TIMEOUT=4 retry_with_backoff \
'[[ $(curl -s -H "M3-Limit-Max-Series: 10" 0.0.0.0:7201/api/v1/query?query=\\{__name__!=\"\"\\} | jq -r ".data.result | length") -eq 10 ]]'

echo "Test query limit with require-exhaustive headers false"
ATTEMPTS=50 TIMEOUT=2 MAX_TIMEOUT=4 retry_with_backoff \
'[[ $(curl -s -H "M3-Limit-Max-Series: 2" -H "M3-Limit-Require-Exhaustive: false" 0.0.0.0:7201/api/v1/query?query=database_write_tagged_success | jq -r ".data.result | length") -eq 2 ]]'

echo "Test query limit with require-exhaustive headers true (below limit therefore no error)"
ATTEMPTS=50 TIMEOUT=2 MAX_TIMEOUT=4 retry_with_backoff \
'[[ $(curl -s -H "M3-Limit-Max-Series: 4" -H "M3-Limit-Require-Exhaustive: true" 0.0.0.0:7201/api/v1/query?query=database_write_tagged_success | jq -r ".data.result | length") -eq 3 ]]'

echo "Test query limit with require-exhaustive headers true (above limit therefore error)"
failedOverLimit=$(curl -s -H "M3-Limit-Max-Series: 3" -H "M3-Limit-Require-Exhaustive: true" 0.0.0.0:7201/api/v1/query?query=database_write_tagged_success | jq)
test "$(echo $failedOverLimit | jq -r ".status")" = "error"
test "$(grep "query matched too many time series" <<< $failedOverLimit)"
}

function prometheus_query_native {
Expand Down
4 changes: 4 additions & 0 deletions src/dbnode/storage/index_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/m3db/m3/src/m3ninx/index/segment"
idxpersist "github.com/m3db/m3/src/m3ninx/persist"
"github.com/m3db/m3/src/x/context"
xerrors "github.com/m3db/m3/src/x/errors"
"github.com/m3db/m3/src/x/ident"
xtest "github.com/m3db/m3/src/x/test"
xtime "github.com/m3db/m3/src/x/time"
Expand Down Expand Up @@ -643,6 +644,7 @@ func TestNamespaceIndexBlockQuery(t *testing.T) {
result, err = idx.Query(ctx, q, qOpts)
if test.requireExhaustive {
require.Error(t, err)
require.False(t, xerrors.IsRetryableError(err))
} else {
require.NoError(t, err)
require.False(t, result.Exhaustive)
Expand Down Expand Up @@ -879,6 +881,7 @@ func TestNamespaceIndexBlockAggregateQuery(t *testing.T) {
result, err = idx.AggregateQuery(ctx, q, aggOpts)
if test.requireExhaustive {
require.Error(t, err)
require.False(t, xerrors.IsRetryableError(err))
} else {
require.NoError(t, err)
require.False(t, result.Exhaustive)
Expand Down Expand Up @@ -1116,6 +1119,7 @@ func TestNamespaceIndexBlockAggregateQueryAggPath(t *testing.T) {
result, err = idx.AggregateQuery(ctx, q, aggOpts)
if test.requireExhaustive {
require.Error(t, err)
require.False(t, xerrors.IsRetryableError(err))
} else {
require.NoError(t, err)
require.False(t, result.Exhaustive)
Expand Down

0 comments on commit 669609d

Please sign in to comment.