mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-11 14:53:49 +00:00
b82bd0c2ec
Do not read timestamps for blocks, which cannot contain surrounding logs. This should improve peformance for https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6730 . Also optimize min(_time) and max(_time) calculations a bit by avoiding conversion of timestamp to string when it isn't needed. This should improve performance for https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7070 .
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package logstorage
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestParsePipeStreamContextSuccess(t *testing.T) {
|
|
f := func(pipeStr string) {
|
|
t.Helper()
|
|
expectParsePipeSuccess(t, pipeStr)
|
|
}
|
|
|
|
f(`stream_context before 5`)
|
|
f(`stream_context after 10`)
|
|
f(`stream_context after 0`)
|
|
f(`stream_context before 10 after 20`)
|
|
}
|
|
|
|
func TestParsePipeStreamContextFailure(t *testing.T) {
|
|
f := func(pipeStr string) {
|
|
t.Helper()
|
|
expectParsePipeFailure(t, pipeStr)
|
|
}
|
|
|
|
f(`stream_context`)
|
|
f(`stream_context before`)
|
|
f(`stream_context after`)
|
|
f(`stream_context before after`)
|
|
f(`stream_context after before`)
|
|
f(`stream_context before -4`)
|
|
f(`stream_context after -4`)
|
|
}
|
|
|
|
func TestPipeStreamContextUpdateNeededFields(t *testing.T) {
|
|
f := func(s, neededFields, unneededFields, neededFieldsExpected, unneededFieldsExpected string) {
|
|
t.Helper()
|
|
expectPipeNeededFields(t, s, neededFields, unneededFields, neededFieldsExpected, unneededFieldsExpected)
|
|
}
|
|
|
|
// all the needed fields
|
|
f("stream_context after 4 before 10", "*", "", "*", "")
|
|
|
|
// plus unneeded fields
|
|
f("stream_context before 10 after 4", "*", "f1,f2", "*", "f1,f2")
|
|
f("stream_context after 4", "*", "_time,f1,_stream_id", "*", "f1")
|
|
|
|
// needed fields
|
|
f("stream_context before 3", "f1,f2", "", "_stream_id,_time,f1,f2", "")
|
|
f("stream_context before 3", "_time,f1,_stream_id", "", "_stream_id,_time,f1", "")
|
|
}
|