Merge pull request #1259 from colinsurprenant/issue-1258

fix and regression tests for github issue #1258
This commit is contained in:
Colin Surprenant 2014-04-11 15:56:10 -04:00
commit 8eed4a9233
2 changed files with 37 additions and 1 deletions

View file

@ -208,7 +208,7 @@ class LogStash::Filters::Multiline < LogStash::Filters::Base
# multiline, send it.
if pending
pending.append(event)
event.overwrite(pending.to_hash)
event.overwrite(pending)
@pending.delete(key)
end
end # if/else match

View file

@ -119,4 +119,40 @@ describe LogStash::Filters::Multiline do
end
end
end
describe "regression test for GH issue #1258" do
config <<-CONFIG
filter {
multiline {
pattern => "^\s"
what => "next"
add_tag => ["multi"]
}
}
CONFIG
sample [ " match", "nomatch" ] do
expect(subject).to be_a(LogStash::Event)
insist { subject["message"] } == " match\nnomatch"
end
end
describe "multiple match/nomatch" do
config <<-CONFIG
filter {
multiline {
pattern => "^\s"
what => "next"
add_tag => ["multi"]
}
}
CONFIG
sample [" match1", "nomatch1", " match2", "nomatch2"] do
expect(subject).to be_a(Array)
insist { subject.size } == 2
insist { subject[0]["message"] } == " match1\nnomatch1"
insist { subject[1]["message"] } == " match2\nnomatch2"
end
end
end