Skip to content

Commit

Permalink
Merge pull request #137 from SungJin1212/Disable-at-mondifier-to-walk…
Browse files Browse the repository at this point in the history
…info
  • Loading branch information
yeya24 authored Nov 21, 2024
2 parents efd4618 + 4171472 commit 8b48fe2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (s *PromQLSmith) walkExpr(e ExprType, valueTypes ...parser.ValueType) (pars
case MatrixSelector:
return s.walkMatrixSelector(), nil
case VectorSelector:
return s.walkVectorSelector(), nil
return s.walkVectorSelector(s.enableAtModifier), nil
case CallExpr:
return s.walkCall(valueTypes...), nil
case NumberLiteral:
Expand Down Expand Up @@ -216,7 +216,7 @@ func (s *PromQLSmith) walkSubQueryExpr() parser.Expr {
expr := &parser.SubqueryExpr{
Range: time.Hour,
Step: time.Minute,
Expr: s.walkVectorSelector(),
Expr: s.walkVectorSelector(s.enableAtModifier),
}
if s.enableOffset && s.rnd.Int()%2 == 0 {
negativeOffset := s.rnd.Intn(2) == 0
Expand Down Expand Up @@ -296,7 +296,7 @@ func (s *PromQLSmith) walkInfo(expr *parser.Call) {
// skip second parameter
expr.Args = expr.Args[:1]
} else {
expr.Args[1] = s.walkVectorSelector()
expr.Args[1] = s.walkVectorSelector(false)
}
}

Expand Down Expand Up @@ -414,7 +414,7 @@ func (s *PromQLSmith) walkVariadicFunctions(expr *parser.Call) {
}
}

func (s *PromQLSmith) walkVectorSelector() parser.Expr {
func (s *PromQLSmith) walkVectorSelector(enableAtModifier bool) parser.Expr {
expr := &parser.VectorSelector{}
expr.LabelMatchers = s.walkLabelMatchers()
s.populateSeries(expr)
Expand All @@ -425,7 +425,7 @@ func (s *PromQLSmith) walkVectorSelector() parser.Expr {
expr.OriginalOffset = -expr.OriginalOffset
}
}
if s.enableAtModifier && s.rnd.Float64() > 0.7 {
if enableAtModifier && s.rnd.Float64() > 0.7 {
expr.Timestamp, expr.StartOrEnd = s.walkAtModifier()
}

Expand Down Expand Up @@ -621,7 +621,7 @@ func (s *PromQLSmith) walkMatrixSelector() parser.Expr {
return &parser.MatrixSelector{
// Make sure the time range is > 0s.
Range: time.Duration(s.rnd.Intn(5)+1) * time.Minute,
VectorSelector: s.walkVectorSelector(),
VectorSelector: s.walkVectorSelector(s.enableAtModifier),
}
}

Expand Down
2 changes: 1 addition & 1 deletion walk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ func TestWalkVectorSelector(t *testing.T) {
rnd := rand.New(rand.NewSource(time.Now().Unix()))
opts := []Option{WithEnableOffset(true), WithEnableAtModifier(true)}
p := New(rnd, testSeriesSet, opts...)
expr := p.walkVectorSelector()
expr := p.walkVectorSelector(true)
vs, ok := expr.(*parser.VectorSelector)
require.True(t, ok)
containsMetricName := false
Expand Down

0 comments on commit 8b48fe2

Please sign in to comment.