mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
parent
3d84827174
commit
8685d1d483
2 changed files with 29 additions and 1 deletions
|
@ -111,7 +111,7 @@ module LogStashCompilerLSCLGrammar; module LogStash; module Compiler; module LSC
|
|||
# hash value; e.g., `{"match" => {"baz" => "bar"}, "match" => {"foo" => "bulb"}}` is
|
||||
# interpreted as `{"match" => {"baz" => "bar", "foo" => "blub"}}`.
|
||||
# (NOTE: this bypasses `AST::Hash`'s ability to detect duplicate keys)
|
||||
hash[k] = existing.merge(v)
|
||||
hash[k] = ::LogStash::Util.hash_merge_many(existing, v)
|
||||
elsif existing.kind_of?(::Array)
|
||||
hash[k] = existing.push(*v)
|
||||
else
|
||||
|
|
|
@ -252,6 +252,34 @@ describe LogStash::Compiler do
|
|||
expect(c_plugin).to ir_eql(j.iPlugin(rand_meta, FILTER, "grok", expected_plugin_args))
|
||||
end
|
||||
|
||||
describe "a filter plugin with a repeated hash directive with duplicated keys" do
|
||||
let(:source) { "input { } filter { #{plugin_source} } output { } " }
|
||||
let(:plugin_source) do
|
||||
%q[
|
||||
grok {
|
||||
match => { "message" => "foo" }
|
||||
match => { "message" => "bar" }
|
||||
break_on_match => false
|
||||
}
|
||||
]
|
||||
end
|
||||
subject(:c_plugin) { compiled[:filter] }
|
||||
|
||||
let(:expected_plugin_args) do
|
||||
{
|
||||
"match" => {
|
||||
"message" => ["foo", "bar"]
|
||||
},
|
||||
"break_on_match" => "false"
|
||||
}
|
||||
end
|
||||
|
||||
it "should merge the values of the duplicate keys into an array" do
|
||||
expect(c_plugin).to ir_eql(j.iPlugin(rand_meta, FILTER, "grok", expected_plugin_args))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "a filter plugin that has nested Hash directives" do
|
||||
let(:source) { "input { } filter { #{plugin_source} } output { } " }
|
||||
let(:plugin_source) do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue