Skip to content

Commit

Permalink
- Push a logstash-test script to aid in debugging common logstash setup
Browse files Browse the repository at this point in the history
  problems.
  • Loading branch information
jordansissel committed Nov 30, 2010
1 parent 710d7a6 commit 2b14cba
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
86 changes: 86 additions & 0 deletions bin/logstash-test
Original file line number Diff line number Diff line change
@@ -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))


1 change: 1 addition & 0 deletions logstash-lite.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"
Expand Down
1 change: 1 addition & 0 deletions logstash.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"
Expand Down
6 changes: 3 additions & 3 deletions test/run.rb
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 2b14cba

Please sign in to comment.