-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ParserTestDriver #702
Add ParserTestDriver #702
Conversation
Because first argument of #initialize can pass Class or String.
Could you replace one actual parser test with this driver? |
I try to replace |
Ah, my understanding is wrong. In |
6fe3817
to
98afe40
Compare
I want to write parser test like following: def test_multiline
conf = %[
<grok>
pattern %{DATA:message1}\n
</grok>
<grok>
pattern %{DATA:message2}\n
</grok>
]
text = <<TEXT
host1 message1
message2
TEXT
d = Fluent::Parser::TestDriver.new(Fluent::TextParser::MultilineGrokParser).configure(conf)
d.parse(text) do |time, record|
assert_equal(expected, record)
end
end This is same as other test drivers. |
TimeParser itself is not a Parser plugin so I think supporting TimeParser API is not needed. |
TextParser::RegexpParser.method(:initialize).arity is -2.
32e1400
to
0e80436
Compare
Rebased. I removed a commit which replaces TimeParse test cases with ParserTestDriver. |
@okkez How about this? If you ok, I will merge this patch. |
How to use nested config_section and cnofig_param? But this is no tested. def configure(conf)
case conf
when Fluent::Config::Element
@config = conf
when String
io = StringIO.new(conf)
@config = Cofig::Parser.parse(io, 'fluent.conf')
when Hash
@config = Config::Element.new('ROOT', '', conf, [])
else
raise "Unknown type... #{conf}"
end
@instance.configure(@config)
self
end |
As a result of @okkez and I discussion, I added commits to drop Could you review this PR again? |
If there are no concerns from other developers, I will merge it. |
Looks good to me 👍 |
Currently, fluentd does not have
ParserTestDriver
.This PR adds this test driver.
Remaining tasks
Decide whether to include utility methods such asstr2time
or not.ParserTestDriver