add a parser unit test using the 'in File(...)' construct

This commit is contained in:
Thibault bui Koechlin 2020-05-27 16:46:01 +02:00 committed by Farica
parent 160478b419
commit 6cb5ec0460
4 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,22 @@
filter: "evt.Line.Labels.type == 'testlog'"
debug: true
onsuccess: next_stage
name: tests/base-grok
data:
- source_url: https://invalid.com/test.list
dest_file: ../pkg/parser/tests/sample_strings.txt
pattern_syntax:
MYCAP1: ".*"
nodes:
- grok:
pattern: ^xxheader %{MYCAP1:extracted_value} trailing stuff$
apply_on: Line.Raw
statics:
- meta: log_type
value: parsed_testlog
- meta: is_it_in_file
expression: |-
evt.Parsed.extracted_value in File("../pkg/parser/tests/sample_strings.txt") ? "true" : "false"

View file

@ -0,0 +1,2 @@
- filename: {{.TestDirectory}}/base-grok.yaml
stage: s00-raw

View file

@ -0,0 +1,32 @@
#these are the events we input into parser
lines:
- Line:
Labels:
#this one will be checked by a filter
type: testlog
Raw: xxheader VALUE1 trailing stuff
- Line:
#see tricky case : first one is nginx via syslog, the second one is local nginx :)
Labels:
#this one will be checked by a filter
type: testlog
Raw: xxheader VALUE2 trailing stuff
#these are the results we expect from the parser
results:
- Meta:
log_type: parsed_testlog
is_it_in_file: true
Parsed:
extracted_value: VALUE1
Process: true
Stage: s00-raw
- Meta:
log_type: parsed_testlog
is_it_in_file: false
Parsed:
extracted_value: VALUE2
Process: true
Stage: s00-raw

View file

@ -0,0 +1,3 @@
VALUE1
VALUE3
RATATA