Skip to content

Commit

Permalink
Uncomment tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
  • Loading branch information
cyriltovena committed Nov 5, 2020
1 parent 9c20705 commit beadfcd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 44 deletions.
22 changes: 11 additions & 11 deletions pkg/chunkenc/memchunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,11 +814,11 @@ func BenchmarkBufferedIteratorLabels(b *testing.B) {
},
}
for _, test := range []string{
// `{app="foo"}`,
`{app="foo"}`,
`{app="foo"} != "foo"`,
// `{app="foo"} != "foo" | logfmt `,
// `{app="foo"} != "foo" | logfmt | duration > 10ms`,
// `{app="foo"} != "foo" | logfmt | duration > 10ms and component="tsdb"`,
`{app="foo"} != "foo" | logfmt `,
`{app="foo"} != "foo" | logfmt | duration > 10ms`,
`{app="foo"} != "foo" | logfmt | duration > 10ms and component="tsdb"`,
} {
b.Run(test, func(b *testing.B) {
b.ReportAllocs()
Expand Down Expand Up @@ -851,13 +851,13 @@ func BenchmarkBufferedIteratorLabels(b *testing.B) {
}

for _, test := range []string{
// `rate({app="foo"}[1m])`,
// `sum by (cluster) (rate({app="foo"}[10s]))`,
// `sum by (cluster) (rate({app="foo"} != "foo" [10s]))`,
// `sum by (cluster) (rate({app="foo"} != "foo" | logfmt[10s]))`,
// `sum by (caller) (rate({app="foo"} != "foo" | logfmt[10s]))`,
// `sum by (cluster) (rate({app="foo"} != "foo" | logfmt | duration > 10ms[10s]))`,
// `sum by (cluster) (rate({app="foo"} != "foo" | logfmt | duration > 10ms and component="tsdb"[1m]))`,
`rate({app="foo"}[1m])`,
`sum by (cluster) (rate({app="foo"}[10s]))`,
`sum by (cluster) (rate({app="foo"} != "foo" [10s]))`,
`sum by (cluster) (rate({app="foo"} != "foo" | logfmt[10s]))`,
`sum by (caller) (rate({app="foo"} != "foo" | logfmt[10s]))`,
`sum by (cluster) (rate({app="foo"} != "foo" | logfmt | duration > 10ms[10s]))`,
`sum by (cluster) (rate({app="foo"} != "foo" | logfmt | duration > 10ms and component="tsdb"[1m]))`,
} {
b.Run(test, func(b *testing.B) {
b.ReportAllocs()
Expand Down
37 changes: 4 additions & 33 deletions pkg/logql/log/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func (h *hasher) Hash(lbs labels.Labels) uint64 {
type BaseLabelsBuilder struct {
del []string
add []labels.Label
// nolint(structcheck) https://github.com/golangci/golangci-lint/issues/826
err string

groups []string
Expand Down Expand Up @@ -238,40 +239,10 @@ Outer:
// No grouping is applied and the cache is used when possible.
func (b *LabelsBuilder) LabelsResult() LabelsResult {
// unchanged path.
if len(b.del) == 0 && len(b.add) == 0 {
if b.err == "" {
return b.currentResult
}
// unchanged but with error.
res := append(b.base.Copy(), labels.Label{Name: ErrorLabel, Value: b.err})
sort.Sort(res)
return b.toResult(res)
}

// In the general case, labels are removed, modified or moved
// rather than added.
res := make(labels.Labels, 0, len(b.base)+len(b.add))
Outer:
for _, l := range b.base {
for _, n := range b.del {
if l.Name == n {
continue Outer
}
}
for _, la := range b.add {
if l.Name == la.Name {
continue Outer
}
}
res = append(res, l)
if len(b.del) == 0 && len(b.add) == 0 && b.err == "" {
return b.currentResult
}
res = append(res, b.add...)
if b.err != "" {
res = append(res, labels.Label{Name: ErrorLabel, Value: b.err})
}
sort.Sort(res)

return b.toResult(res)
return b.toResult(b.Labels())
}

func (b *BaseLabelsBuilder) toResult(lbs labels.Labels) LabelsResult {
Expand Down

0 comments on commit beadfcd

Please sign in to comment.