- Add test coverage for (?<name> ... ) oniguruma named captures.

This required a new version of jls-grok to fix it.
This commit is contained in:
Jordan Sissel 2012-11-16 22:04:05 -08:00
parent 2a97f4055e
commit e44d457f9d
2 changed files with 36 additions and 3 deletions

View file

@ -42,7 +42,7 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency "gelfd", ["0.2.0"] gem.add_runtime_dependency "gelfd", ["0.2.0"]
gem.add_runtime_dependency "gelf", ["1.3.2"] gem.add_runtime_dependency "gelf", ["1.3.2"]
gem.add_runtime_dependency "gmetric", ["0.1.3"] gem.add_runtime_dependency "gmetric", ["0.1.3"]
gem.add_runtime_dependency "jls-grok", ["0.10.9"] gem.add_runtime_dependency "jls-grok", ["0.10.10"]
gem.add_runtime_dependency "mail" gem.add_runtime_dependency "mail"
gem.add_runtime_dependency "mongo" gem.add_runtime_dependency "mongo"
gem.add_runtime_dependency "onstomp" gem.add_runtime_dependency "onstomp"

View file

@ -170,4 +170,37 @@ describe LogStash::Filters::Grok do
insist { subject["foo"] } == "yo" insist { subject["foo"] } == "yo"
end end
end end
describe "using oniguruma named captures (?<name>regex)" do
context "plain regexp" do
config <<-'CONFIG'
filter {
grok {
singles => true
pattern => "(?<foo>\w+)"
}
}
CONFIG
sample "hello world" do
reject { subject.tags }.include?("_grokparsefailure")
insist { subject["foo"] } == "hello"
end
end
context "grok patterns" do
config <<-'CONFIG'
filter {
grok {
singles => true
pattern => "(?<timestamp>%{DATE_EU} %{TIME})"
}
}
CONFIG
sample "fancy 2012-12-12 12:12:12" do
reject { subject.tags }.include?("_grokparsefailure")
insist { subject["timestamp"] } == "2012-12-12 12:12:12"
end
end
end
end end