mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
b644169fc4
commit
998b4a0eef
2 changed files with 64 additions and 0 deletions
32
lib/logstorage/pipe_limit_test.go
Normal file
32
lib/logstorage/pipe_limit_test.go
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
package logstorage
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPipeLimitUpdateNeededFields(t *testing.T) {
|
||||||
|
f := func(s, neededFields, unneededFields, neededFieldsExpected, unneededFieldsExpected string) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
nfs := newTestFieldsSet(neededFields)
|
||||||
|
unfs := newTestFieldsSet(unneededFields)
|
||||||
|
|
||||||
|
lex := newLexer(s)
|
||||||
|
p, err := parsePipeLimit(lex)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("cannot parse %s: %s", s, err)
|
||||||
|
}
|
||||||
|
p.updateNeededFields(nfs, unfs)
|
||||||
|
|
||||||
|
assertNeededFields(t, nfs, unfs, neededFieldsExpected, unneededFieldsExpected)
|
||||||
|
}
|
||||||
|
|
||||||
|
// all the needed fields
|
||||||
|
f("limit 10", "*", "", "*", "")
|
||||||
|
|
||||||
|
// all the needed fields, plus unneeded fields
|
||||||
|
f("limit 10", "*", "f1,f2", "*", "f1,f2")
|
||||||
|
|
||||||
|
// needed fields
|
||||||
|
f("limit 10", "f1,f2", "", "f1,f2", "")
|
||||||
|
}
|
32
lib/logstorage/pipe_offset_test.go
Normal file
32
lib/logstorage/pipe_offset_test.go
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
package logstorage
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPipeOffsetUpdateNeededFields(t *testing.T) {
|
||||||
|
f := func(s, neededFields, unneededFields, neededFieldsExpected, unneededFieldsExpected string) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
nfs := newTestFieldsSet(neededFields)
|
||||||
|
unfs := newTestFieldsSet(unneededFields)
|
||||||
|
|
||||||
|
lex := newLexer(s)
|
||||||
|
p, err := parsePipeOffset(lex)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("cannot parse %s: %s", s, err)
|
||||||
|
}
|
||||||
|
p.updateNeededFields(nfs, unfs)
|
||||||
|
|
||||||
|
assertNeededFields(t, nfs, unfs, neededFieldsExpected, unneededFieldsExpected)
|
||||||
|
}
|
||||||
|
|
||||||
|
// all the needed fields
|
||||||
|
f("offset 10", "*", "", "*", "")
|
||||||
|
|
||||||
|
// all the needed fields, plus unneeded fields
|
||||||
|
f("offset 10", "*", "f1,f2", "*", "f1,f2")
|
||||||
|
|
||||||
|
// needed fields
|
||||||
|
f("offset 10", "f1,f2", "", "f1,f2", "")
|
||||||
|
}
|
Loading…
Reference in a new issue