Skip to content

Commit

Permalink
update query fuzz tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <[email protected]>
  • Loading branch information
yeya24 committed Oct 12, 2023
1 parent f58d90c commit 2559b03
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions integration/query_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/prompb"
"github.com/prometheus/prometheus/promql/parser"
"github.com/stretchr/testify/require"

"github.com/cortexproject/cortex/integration/e2e"
Expand Down Expand Up @@ -84,7 +85,7 @@ func TestVerticalShardingFuzz(t *testing.T) {
// Push some series to Cortex.
start := now.Add(-time.Minute * 10)
end := now.Add(-time.Minute * 1)
numSeries := 3
numSeries := 100
numSamples := 20
lbls := make([]labels.Labels, numSeries*2)
serieses := make([]prompb.TimeSeries, numSeries*2)
Expand Down Expand Up @@ -144,24 +145,19 @@ func TestVerticalShardingFuzz(t *testing.T) {
}

now = time.Now()
cases := make([]*testCase, 0, 200)
for i := 0; i < 100; i++ {
expr := ps.WalkInstantQuery()
query := expr.Pretty(0)
res1, err1 := c1.Query(query, now)
res2, err2 := c2.Query(query, now)
cases = append(cases, &testCase{
query: query,
res1: res1,
res2: res2,
err1: err1,
err2: err2,
instantQuery: true,
})
}
cases := make([]*testCase, 0, 100)

for i := 0; i < 100; i++ {
expr := ps.WalkRangeQuery()
var expr parser.Expr
// Let's make sure we generate aggregation expression only as
// this is our main target to test.
for {
expr = ps.WalkRangeQuery()
aggr, ok := expr.(*parser.AggregateExpr)

Check failure on line 156 in integration/query_fuzz_test.go

View workflow job for this annotation

GitHub Actions / integration (integration_query_fuzz)

aggr declared and not used
if ok {
break
}
}
query := expr.Pretty(0)
res1, err1 := c1.QueryRange(query, start, end, scrapeInterval)
res2, err2 := c2.QueryRange(query, start, end, scrapeInterval)
Expand Down

0 comments on commit 2559b03

Please sign in to comment.