- Push a logstash-test script to aid in debugging common logstash setup

problems.
This commit is contained in:
Jordan Sissel 2010-11-29 21:01:25 -08:00
parent 710d7a6eda
commit 2b14cba4eb
5 changed files with 92 additions and 4 deletions

View file

@ -6,7 +6,7 @@ task :package do
end
task :publish do
latest_gem = %x{ls -t logstash*.gem}.split("\n").first
latest_gem = %x{ls -t logstash-[0-9]*.gem}.split("\n").first
system("gem push #{latest_gem}")
latest_lite_gem = %x{ls -t logstash-lite*.gem}.split("\n").first
system("gem push #{latest_lite_gem}")

86
bin/logstash-test Executable file
View file

@ -0,0 +1,86 @@
#!/usr/bin/env ruby
require "rubygems"
require "optparse"
$:.unshift "#{File.dirname(__FILE__)}/../lib"
$:.unshift "#{File.dirname(__FILE__)}/../test"
#require "logstash/test_syntax"
#require "logstash/filters/test_date"
#require "logstash/filters/test_multiline"
def check_lib(lib, provider, optional=true, message=nil)
begin
require lib
puts "+ Found #{optional ? "optional" : "required"} library '#{lib}'"
return { :optional => optional, :found => true }
rescue LoadError => e
puts "- Missing #{optional ? "optional" : "required"} library '#{lib}' - try 'gem install #{provider}'#{optional ? " if you want this library" : ""}. #{message}"
return { :optional => optional, :found => false }
end
end
def report_ruby_version
puts "Running #{RUBY_VERSION}p#{RUBY_PATCHLEVEL} on #{RUBY_PLATFORM}"
end
def check_libraries
results = []
results << check_lib("em-http-request", "em-http-request", true,
"needed for ElasticSearch input, output, and logstash-web support.")
results << check_lib("em-mongo", "em-mongo", true,
"needed for the mongodb output.")
results << check_lib("grok", "jls-grok", true,
"needed for the grok filter.")
results << check_lib("em-websocket", "em-websocket", true,
"needed for websocket output")
results << check_lib("rack", "rack", true,
"needed for logstash-web")
results << check_lib("amqp", "amqp", true,
"needed for AMQP input and output")
results << check_lib("sinatra/async", "async_sinatra", true,
"needed for logstash-web")
results << check_lib("uuidtools", "uuidtools", true,
"needed for AMQP input and output")
results << check_lib("ap", "awesome_print", true,
"improve logstash debug logging output")
results << check_lib("eventmachine", "eventmachine", false,
"required for logstash to function")
missing_required = results.count { |r| !r[:optional] and !r[:found] }
if missing_required == 0
puts "All required libraries found :)"
else
suffix = (missing_required > 1) ? "ies" : "y"
puts "FATAL: Missing #{missing_required} required librar#{suffix}"
return false
end
return true
end
def run_tests
require "logstash/test_syntax"
require "logstash/filters/test_date"
require "logstash/filters/test_multiline"
return Test::Unit::AutoRunner.run
end
def main(args)
report_ruby_version
if !check_libraries
puts "Library check failed."
return 1
end
if !run_tests
puts "Test suite failed."
return 1
end
return 0
end
exit(main(ARGV))

View file

@ -40,6 +40,7 @@ Gem::Specification.new do |spec|
spec.bindir = "bin"
spec.executables << "logstash"
spec.executables << "logstash-web"
spec.executables << "logstash-test"
spec.author = "Jordan Sissel"
spec.email = "jls@semicomplete.com"

View file

@ -40,6 +40,7 @@ Gem::Specification.new do |spec|
spec.bindir = "bin"
spec.executables << "logstash"
spec.executables << "logstash-web"
spec.executables << "logstash-test"
spec.author = "Jordan Sissel"
spec.email = "jls@semicomplete.com"

View file

@ -1,6 +1,6 @@
require "rubygems"
$:.unshift "#{File.dirname(__FILE__)}/../lib/"
require "test_syntax"
require "filters/test_date"
require "filters/test_multiline"
require "logstash/test_syntax"
require "logstash/filters/test_date"
require "logstash/filters/test_multiline"