- fix runners and test launcher

This commit is contained in:
Jordan Sissel 2011-06-30 17:51:35 -07:00
parent 529e6c726e
commit e98f463fac
5 changed files with 19 additions and 91 deletions

View file

@ -1,90 +1,8 @@
#!/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("thin", "thin", 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")
results << check_lib("json", "json", 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 "#{File.dirname(__FILE__)}/../test/run"
return Test::Unit::AutoRunner.run
end
def main(args)
report_ruby_version
# TODO(sissel): Add a way to call out specific things to test, like
# logstash-web, elasticsearch, mongodb, syslog, etc.
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))
require "logstash/runner"
ARGV.unshift("test")
LogStash::Runner.new.main(ARGV)

View file

@ -271,7 +271,8 @@ class LogStash::Agent
public
def wait
@thread.join
end
return 0
end # def wait
public
def run_with_config(config)

View file

@ -1,4 +1,6 @@
require "rubygems"
$: << File.join(File.dirname(__FILE__), "..")
$: << File.join(File.dirname(__FILE__), "..", "..", "test")
require "logstash/namespace"
class LogStash::Runner
@ -11,7 +13,11 @@ class LogStash::Runner
args = run(args)
end
@runners.each { |r| r.wait }
status = []
@runners.each { |r| status << r.wait }
# Avoid running test/unit's at_exit crap
java.lang.System.exit(status.first)
end # def self.main
def run(args)
@ -30,7 +36,10 @@ class LogStash::Runner
return web.run(args)
end,
"test" => lambda do
require "logstash_test_runner"
require "logstash/test"
test = LogStash::Test.new
@runners << test
return test.run(args)
end
} # commands
@ -48,7 +57,7 @@ class LogStash::Runner
end
return args
end # def self.run
end # def run
end # class LogStash::Runner
if $0 == __FILE__

View file

@ -92,6 +92,7 @@ class LogStash::Web::Runner
public
def wait
@thread.join
return 0
end # def wait
end # class LogStash::Web::Runner

View file

@ -31,5 +31,4 @@ skip "logstash/inputs/test_file"
skip "logstash/inputs/test_syslog"
skip "logstash/inputs/test_stomp"
Test::Unit::AutoRunner.run
#Test::Unit::AutoRunner.run