Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possible selector label value of . to cover more non existent value #109

Merged
merged 1 commit into from
Mar 28, 2024
Merged
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
16 changes: 14 additions & 2 deletions walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,22 @@ func (s *PromQLSmith) walkSelectors() []*labels.Matcher {
value = ""
} else if val > 0.9 {
value = "not_exist_value"
} else if val > 0.8 {
// TODO: randomize the non existent value using random UTF8 runes.
value = "."
} else {
idx := s.rnd.Intn(len(s.labelValues[name]))
value = s.labelValues[name][idx]
}
case labels.MatchNotEqual:
switch s.rnd.Intn(3) {
switch s.rnd.Intn(4) {
case 0:
value = ""
case 1:
value = "not_exist_value"
case 2:
// TODO: randomize the non existent value using random UTF8 runes.
value = "."
default:
idx := s.rnd.Intn(len(s.labelValues[name]))
value = s.labelValues[name][idx]
Expand All @@ -378,6 +384,9 @@ func (s *PromQLSmith) walkSelectors() []*labels.Matcher {
value = ""
} else if val > 0.9 {
value = "not_exist_value"
} else if val > 0.85 {
// TODO: randomize the non existent value using random UTF8 runes.
value = "."
} else if val > 0.8 {
value = ".*"
} else if val > 0.7 {
Expand Down Expand Up @@ -405,8 +414,11 @@ func (s *PromQLSmith) walkSelectors() []*labels.Matcher {
val := s.rnd.Float64()
if val > 0.8 {
value = ""
} else if val > 0.6 {
} else if val > 0.7 {
value = "not_exist_value"
} else if val > 0.6 {
// TODO: randomize the non existent value using random UTF8 runes.
value = "."
} else if val > 0.4 {
// Prefix
idx := s.rnd.Intn(len(s.labelValues[name]))
Expand Down