Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/armon/go-metrics v0.4.1
github.com/aws/aws-sdk-go v1.55.6
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874
github.com/cortexproject/promqlsmith v0.0.0-20250203072244-cbb5738d00ca
github.com/cortexproject/promqlsmith v0.0.0-20250407233056-90db95b1a4e4
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 @@ -938,8 +938,8 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
github.com/coreos/go-systemd/v22 v22.3.2/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-20250203072244-cbb5738d00ca h1:TvKuPFRUQ39O07xv3b+TO6GBRhchYKyBCCXrlmmDE3Y=
github.com/cortexproject/promqlsmith v0.0.0-20250203072244-cbb5738d00ca/go.mod h1:xbYQa0KX6Eh6YWbTBfZ9kK3N4hRxX+ZPIfVIY2U/y00=
github.com/cortexproject/promqlsmith v0.0.0-20250407233056-90db95b1a4e4 h1:dpo7kQ24uFSV6Zgm9/kB34TIUWjGmadlbKrM6fNfQko=
github.com/cortexproject/promqlsmith v0.0.0-20250407233056-90db95b1a4e4/go.mod h1:jh6POgN18lXU133HBMfwr/1TjvBp8e5kL4ZtRsAPvGY=
github.com/cortexproject/weaveworks-common v0.0.0-20241129212437-96019edf21f1 h1:UoSixdl0sBUhfEOMpIGxFnJjp3/y/+nkw6Du7su05FE=
github.com/cortexproject/weaveworks-common v0.0.0-20241129212437-96019edf21f1/go.mod h1:7cl8fS/nivXe2DmBUUmr/3UGTJG2jVU2NRaIayR2Zjs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down
19 changes: 5 additions & 14 deletions integration/query_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func TestDisableChunkTrimmingFuzz(t *testing.T) {
expr = ps.WalkRangeQuery()
query = expr.Pretty(0)
// timestamp is a known function that break with disable chunk trimming.
if isValidQuery(expr, 5, false) && !strings.Contains(query, "timestamp") {
if isValidQuery(expr, false) && !strings.Contains(query, "timestamp") {
break
}
}
Expand Down Expand Up @@ -566,7 +566,7 @@ func TestExpandedPostingsCacheFuzz(t *testing.T) {
matchers := make([]string, 0, testRun)
for i := 0; i < testRun; i++ {
expr := ps.WalkRangeQuery()
if isValidQuery(expr, 5, true) {
if isValidQuery(expr, true) {
break
}
queries = append(queries, expr.Pretty(0))
Expand Down Expand Up @@ -1731,7 +1731,7 @@ func runQueryFuzzTestCases(t *testing.T, ps *promqlsmith.PromQLSmith, c1, c2 *e2
for i := 0; i < run; i++ {
for {
expr = ps.WalkInstantQuery()
if isValidQuery(expr, 5, skipStdAggregations) {
if isValidQuery(expr, skipStdAggregations) {
query = expr.Pretty(0)
break
}
Expand All @@ -1752,7 +1752,7 @@ func runQueryFuzzTestCases(t *testing.T, ps *promqlsmith.PromQLSmith, c1, c2 *e2
for i := 0; i < run; i++ {
for {
expr = ps.WalkRangeQuery()
if isValidQuery(expr, 5, skipStdAggregations) {
if isValidQuery(expr, skipStdAggregations) {
query = expr.Pretty(0)
break
}
Expand Down Expand Up @@ -1803,9 +1803,8 @@ func shouldUseSampleNumComparer(query string) bool {
return false
}

func isValidQuery(generatedQuery parser.Expr, maxDepth int, skipStdAggregations bool) bool {
func isValidQuery(generatedQuery parser.Expr, skipStdAggregations bool) bool {
isValid := true
currentDepth := 0
// TODO(SungJin1212): Test limitk, limit_ratio
if strings.Contains(generatedQuery.String(), "limitk") {
// current skip the limitk
Expand All @@ -1820,13 +1819,5 @@ func isValidQuery(generatedQuery parser.Expr, maxDepth int, skipStdAggregations
// If skipStdAggregations enabled, we skip to evaluate for stddev and stdvar aggregations.
return false
}
parser.Inspect(generatedQuery, func(node parser.Node, path []parser.Node) error {
if currentDepth > maxDepth {
isValid = false
return fmt.Errorf("generated query has exceeded maxDepth of %d", maxDepth)
}
currentDepth = len(path) + 1
return nil
})
return isValid
}
14 changes: 14 additions & 0 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.

68 changes: 65 additions & 3 deletions vendor/github.com/cortexproject/promqlsmith/promqlsmith.go

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

Loading
Loading