Skip to content

Commit e31f9c2

Browse files
authored
Support label_join and label_replace in query fuzz tests (#6302)
* 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]>
1 parent 1ead7d2 commit e31f9c2

File tree

6 files changed

+84
-14
lines changed

6 files changed

+84
-14
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/aws/aws-sdk-go v1.55.5
1111
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874
1212
github.com/cespare/xxhash v1.1.0
13-
github.com/cortexproject/promqlsmith v0.0.0-20241101182713-3eec5725bc3f
13+
github.com/cortexproject/promqlsmith v0.0.0-20241102030034-4051538fd914
1414
github.com/dustin/go-humanize v1.0.1
1515
github.com/efficientgo/core v1.0.0-rc.3
1616
github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,8 +944,8 @@ github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
944944
github.com/coreos/go-systemd/v22 v22.4.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
945945
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
946946
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
947-
github.com/cortexproject/promqlsmith v0.0.0-20241101182713-3eec5725bc3f h1:5C8PGy3GN+qqQatdDMU5bXFIspoIngMuyD7UCWkMiRA=
948-
github.com/cortexproject/promqlsmith v0.0.0-20241101182713-3eec5725bc3f/go.mod h1:ypUb6BfnDVr7QrBgAxtzRqZ573swvka0BdCkPqa2A5g=
947+
github.com/cortexproject/promqlsmith v0.0.0-20241102030034-4051538fd914 h1:UhI6yOSqMz3ln8FGaZRLbJTKzPHRaVwewoTa6N5PU5k=
948+
github.com/cortexproject/promqlsmith v0.0.0-20241102030034-4051538fd914/go.mod h1:ypUb6BfnDVr7QrBgAxtzRqZ573swvka0BdCkPqa2A5g=
949949
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
950950
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
951951
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

integration/query_fuzz_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"os"
1111
"path"
1212
"path/filepath"
13-
"slices"
1413
"sort"
1514
"strconv"
1615
"strings"
@@ -42,9 +41,6 @@ var enabledFunctions []*parser.Function
4241

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

135131
builder := labels.NewBuilder(labels.EmptyLabels())
@@ -175,7 +171,8 @@ func TestDisableChunkTrimmingFuzz(t *testing.T) {
175171
for {
176172
expr = ps.WalkRangeQuery()
177173
query = expr.Pretty(0)
178-
if !strings.Contains(query, "timestamp") {
174+
// timestamp is a known function that break with disable chunk trimming.
175+
if isValidQuery(expr, 5) && !strings.Contains(query, "timestamp") {
179176
break
180177
}
181178
}

vendor/github.com/cortexproject/promqlsmith/opts.go

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/cortexproject/promqlsmith/walk.go

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)