Skip to content

Commit

Permalink
Support label_join and label_replace in query fuzz tests (#6302)
Browse files Browse the repository at this point in the history
* support label_join and label_replace in query fuzz tests

Signed-off-by: Ben Ye <[email protected]>

* fix lint

Signed-off-by: Ben Ye <[email protected]>

---------

Signed-off-by: Ben Ye <[email protected]>
  • Loading branch information
yeya24 authored Nov 2, 2024
1 parent 1ead7d2 commit e31f9c2
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 14 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/aws/aws-sdk-go v1.55.5
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874
github.com/cespare/xxhash v1.1.0
github.com/cortexproject/promqlsmith v0.0.0-20241101182713-3eec5725bc3f
github.com/cortexproject/promqlsmith v0.0.0-20241102030034-4051538fd914
github.com/dustin/go-humanize v1.0.1
github.com/efficientgo/core v1.0.0-rc.3
github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -944,8 +944,8 @@ github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
github.com/coreos/go-systemd/v22 v22.4.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cortexproject/promqlsmith v0.0.0-20241101182713-3eec5725bc3f h1:5C8PGy3GN+qqQatdDMU5bXFIspoIngMuyD7UCWkMiRA=
github.com/cortexproject/promqlsmith v0.0.0-20241101182713-3eec5725bc3f/go.mod h1:ypUb6BfnDVr7QrBgAxtzRqZ573swvka0BdCkPqa2A5g=
github.com/cortexproject/promqlsmith v0.0.0-20241102030034-4051538fd914 h1:UhI6yOSqMz3ln8FGaZRLbJTKzPHRaVwewoTa6N5PU5k=
github.com/cortexproject/promqlsmith v0.0.0-20241102030034-4051538fd914/go.mod h1:ypUb6BfnDVr7QrBgAxtzRqZ573swvka0BdCkPqa2A5g=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
9 changes: 3 additions & 6 deletions integration/query_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"os"
"path"
"path/filepath"
"slices"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -42,9 +41,6 @@ var enabledFunctions []*parser.Function

func init() {
for _, f := range parser.Functions {
if slices.Contains(f.ArgTypes, parser.ValueTypeString) {
continue
}
// Ignore native histogram functions for now as our test cases are only float samples.
if strings.Contains(f.Name, "histogram") && f.Name != "histogram_quantile" {
continue
Expand Down Expand Up @@ -129,7 +125,7 @@ func TestDisableChunkTrimmingFuzz(t *testing.T) {
serieses := make([]prompb.TimeSeries, numSeries)
lbls := make([]labels.Labels, numSeries)
for i := 0; i < numSeries; i++ {
series := e2e.GenerateSeriesWithSamples(fmt.Sprintf("test_series_%d", i), start, scrapeInterval, i*numSamples, numSamples, prompb.Label{Name: "job", Value: "test"})
series := e2e.GenerateSeriesWithSamples("test_series", start, scrapeInterval, i*numSamples, numSamples, prompb.Label{Name: "job", Value: "test"}, prompb.Label{Name: "series", Value: strconv.Itoa(i)})
serieses[i] = series

builder := labels.NewBuilder(labels.EmptyLabels())
Expand Down Expand Up @@ -175,7 +171,8 @@ func TestDisableChunkTrimmingFuzz(t *testing.T) {
for {
expr = ps.WalkRangeQuery()
query = expr.Pretty(0)
if !strings.Contains(query, "timestamp") {
// timestamp is a known function that break with disable chunk trimming.
if isValidQuery(expr, 5) && !strings.Contains(query, "timestamp") {
break
}
}
Expand Down
4 changes: 0 additions & 4 deletions vendor/github.com/cortexproject/promqlsmith/opts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions vendor/github.com/cortexproject/promqlsmith/walk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e31f9c2

Please sign in to comment.