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

Test label filter for bytes. #2941

Merged
merged 3 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion pkg/logql/ast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ func Test_FilterMatcher(t *testing.T) {
},
[]linecheck{{"foo", true}, {"bar", false}, {"foobar", true}},
},
{
`{app="foo"} | logfmt | duration > 1s and total_bytes < 1GB`,
[]*labels.Matcher{
mustNewMatcher(labels.MatchEqual, "app", "foo"),
},
[]linecheck{{"duration=5m total_bytes=5kB", true}, {"duration=1s total_bytes=256B", false}, {"duration=0s", false}},
},
} {
tt := tt
t.Run(tt.q, func(t *testing.T) {
Expand All @@ -223,7 +230,7 @@ func Test_FilterMatcher(t *testing.T) {
sp := p.ForStream(labelBar)
for _, lc := range tt.lines {
_, _, ok := sp.Process([]byte(lc.l))
assert.Equal(t, lc.e, ok)
assert.Equalf(t, lc.e, ok, "query for line '%s' was %v and not %v", lc.l, ok, lc.e)
}
}
})
Expand Down
6 changes: 3 additions & 3 deletions pkg/logql/log/label_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ func TestBinary_Filter(t *testing.T) {
labels.Labels{{Name: "foo", Value: "5"}, {Name: "bar", Value: "1s"}},
},
{
NewAndLabelFilter(NewNumericLabelFilter(LabelFilterEqual, "foo", 5), NewBytesLabelFilter(LabelFilterEqual, "bar", 42)),
labels.Labels{{Name: "foo", Value: "5"}, {Name: "bar", Value: "42B"}},
NewAndLabelFilter(NewNumericLabelFilter(LabelFilterEqual, "foo", 5), NewBytesLabelFilter(LabelFilterEqual, "bar", 42000)),
labels.Labels{{Name: "foo", Value: "5"}, {Name: "bar", Value: "42kB"}},
jeschkies marked this conversation as resolved.
Show resolved Hide resolved
true,
labels.Labels{{Name: "foo", Value: "5"}, {Name: "bar", Value: "42B"}},
labels.Labels{{Name: "foo", Value: "5"}, {Name: "bar", Value: "42kB"}},
},
{
NewAndLabelFilter(
Expand Down