Allow unit tests to input raw data into sources
A user was interested in inserting data into a syslog source to test that the fields were extracted as expected. Currently unit tests only support inserting data into transform components.
The way the data is received by each source component is different so this will probably require some support at the component level to enable unit tests.
Example config that currently fails:
[sources.in]
type = "syslog"
mode = "tcp"
address = "0.0.0.0:9000"
[transforms.remap]
type = "remap"
inputs = ["in"]
source = """
.foo = "bar"
"""
[sinks.out]
type = "console"
inputs = ["remap"]
encoding.codec = "json"
[[tests]]
name = "test_syslog"
[[tests.inputs]]
insert_at = "in"
type = "raw"
value = '<190>Feb 13 21:31:56 74794bfb6795 liblogging-stdlog: [origin software="rsyslogd" swVersion="8.24.0" x-pid="8979" x-info="http://www.rsyslog.com"] hello world'
[[tests.outputs]]
extract_from = "in"
[[tests.outputs.conditions]]
type = "check_fields"
"message.equals" = "hello world"
Could be very useful for unit testing file source parsing with (unfortunately) complicated multiline config as well
This would be good too, another option I was thinking would support using vrl when generating the raw value. That would allow a test to use the vrl parse functions as inputs to for tests, such as parse_syslog. Or maybe just create types that correspond to you source parsers.
- insert_at: transform_that_expects_syslog
type: raw
value: |
parse_syslog!("<14>2023-01-17T20:37:08.695177Z 172.16.253.1 cat=system,type=alarm,v=1,aname=ntd2,atype=cms-alarm:device-status-alarm,sev=MAJOR,clrd=true,sp="Deployment State",txt=,lsc=2023-01-17T20:37:08.507Z,mm=0,")
or
- insert_at: transform_that_expects_syslog
type: syslog
value: <14>2023-01-17T20:37:08.695177Z 172.16.253.1 cat=system,type=alarm,v=1,aname=ntd2,atype=cms-alarm:device-status-alarm,sev=MAJOR,clrd=true,sp="Deployment State",txt=,lsc=2023-01-17T20:37:08.507Z,mm=0,