Skip to content

Instantly share code, notes, and snippets.

@obazoud
Created January 20, 2014 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obazoud/8528711 to your computer and use it in GitHub Desktop.
Save obazoud/8528711 to your computer and use it in GitHub Desktop.
Logstash RSpec
require "test_utils"
files = Dir['./etc/*_filters_*.conf']
@@configuration = String.new
files.sort.each do |file|
@@configuration << File.read(file)
end
describe "my format" do
extend LogStash::RSpec
config(@@configuration)
sample({
"message" => '2013/12/03 04:17:41.357 +0100|prod|',
"type" => "xxx"
}) do
insist { subject["tags"] }.nil?
insist { subject }.include?("log_date")
insist { subject["log_date"] } == '2013/12/03 04:17:41.357 +0100'
insist { subject }.include?("@timestamp")
insist { subject["@timestamp"] } == '2013-12-03T04:17:41.357Z'
insist { subject }.include?("serverName")
insist { subject["serverName"] } == 'prod'
end
end
java -jar /opt/logstash/logstash-x.x.x-flatjar.jar rspec --color spec/*_spec.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment