mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
Start working on a better test suite
This commit is contained in:
parent
553b588414
commit
c100edcaf0
4 changed files with 42 additions and 0 deletions
3
spec/IDEAS
Normal file
3
spec/IDEAS
Normal file
|
@ -0,0 +1,3 @@
|
|||
* 'sample' input
|
||||
* configure filters
|
||||
* test events after filtering
|
18
spec/apache_example.rb
Normal file
18
spec/apache_example.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require "test_utils"
|
||||
|
||||
describe "apache common log format" do
|
||||
extend LogStash::RSpec
|
||||
config <<-CONFIG
|
||||
filter {
|
||||
grok {
|
||||
pattern => "%{COMBINEDAPACHELOG}"
|
||||
}
|
||||
}
|
||||
CONFIG
|
||||
|
||||
sample '198.151.8.4 - - [29/Aug/2012:20:17:38 -0400] "GET /favicon.ico HTTP/1.1" 200 3638 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0.1"' do
|
||||
it "should not have tag _grokparsefailure" do
|
||||
reject { subject["@tags"] }.include?("_grokparsefailure")
|
||||
end
|
||||
end
|
||||
end
|
0
spec/helpers.rb
Normal file
0
spec/helpers.rb
Normal file
21
spec/test_utils.rb
Normal file
21
spec/test_utils.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require "insist"
|
||||
|
||||
module LogStash
|
||||
module RSpec
|
||||
def config(configstr)
|
||||
require "logstash/config/file"
|
||||
@config = LogStash::Config::File.new(nil, configstr)
|
||||
end # def config
|
||||
|
||||
def sample(event, &block)
|
||||
subject do
|
||||
{
|
||||
"foo" => "bar",
|
||||
"@tags" => [ "foo" ]
|
||||
}
|
||||
end
|
||||
context("when processing #{event.inspect}", &block)
|
||||
end # def sample
|
||||
end # module RSpec
|
||||
end # module LogStash
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue