add a parser unit test using the 'in File(...)' construct
This commit is contained in:
parent
217aaee414
commit
88f89279ad
4 changed files with 59 additions and 0 deletions
22
pkg/parser/tests/base-grok-external-data/base-grok.yaml
Normal file
22
pkg/parser/tests/base-grok-external-data/base-grok.yaml
Normal 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"
|
||||
|
||||
|
2
pkg/parser/tests/base-grok-external-data/parsers.yaml
Normal file
2
pkg/parser/tests/base-grok-external-data/parsers.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
- filename: {{.TestDirectory}}/base-grok.yaml
|
||||
stage: s00-raw
|
32
pkg/parser/tests/base-grok-external-data/test.yaml
Normal file
32
pkg/parser/tests/base-grok-external-data/test.yaml
Normal 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
|
||||
|
3
pkg/parser/tests/sample_strings.txt
Normal file
3
pkg/parser/tests/sample_strings.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
VALUE1
|
||||
VALUE3
|
||||
RATATA
|
Loading…
Add table
Reference in a new issue