logstash/rakelib/test.rake
Pier-Hugues Pellerin 76286b4f0e use jruby 9.1.9.0
Work done by @guyboertje and @ph

Since JRuby 1.7.25 is now EOL we are migrating Logstash to use JRuby 9k and JDK8 only,
Not much needed updating to make this work, its was mostly a drop in replacement from the previous version.

The major point was the change in the implementation of Time in JRuby, JRuby now use `java.time`
instead of joda time, this allow JRuby to have nanoseconds precision on time object.
2017-06-12 12:35:10 -04:00

90 lines
3.6 KiB
Ruby

# we need to call exit explicitly in order to set the proper exit code, otherwise
# most common CI systems can not know whats up with this tests.
require "pluginmanager/util"
require 'pathname'
namespace "test" do
desc "run the java tests"
task "core-java" do
exit(1) unless system './gradlew clean test --info'
end
desc "run all core specs"
task "core" => ["core-slow"]
def default_spec_command
["bin/rspec", "-fd", "--pattern", "spec/unit/**/*_spec.rb,logstash-core/spec/**/*_spec.rb"]
end
desc "run all core specs"
task "core-slow" => ["core-java"] do
exit 1 unless system(*default_spec_command)
end
desc "run core specs excluding slower tests like stress tests"
task "core-fast" do
exit 1 unless system(*(default_spec_command.concat(["--tag", "~stress_test"])))
end
desc "run all core specs in fail-fast mode"
task "core-fail-fast" do
exit 1 unless system(*(default_spec_command.concat(["--fail-fast"])))
end
desc "run all installed plugins specs"
task "plugins" do
plugins_to_exclude = ENV.fetch("EXCLUDE_PLUGIN", "").split(",")
# grab all spec files using the live plugins gem specs. this allows correctly also running the specs
# of a local plugin dir added using the Gemfile :path option. before this, any local plugin spec would
# not be run because they were not under the vendor/bundle/jruby/2.0/gems path
test_files = LogStash::PluginManager.find_plugins_gem_specs.map do |spec|
if plugins_to_exclude.size > 0
if !plugins_to_exclude.include?(Pathname.new(spec.gem_dir).basename.to_s)
Rake::FileList[File.join(spec.gem_dir, "spec/{input,filter,codec,output}s/*_spec.rb")]
end
else
Rake::FileList[File.join(spec.gem_dir, "spec/{input,filter,codec,output}s/*_spec.rb")]
end
end.flatten.compact
# "--format=documentation"
exit(RSpec::Core::Runner.run(["--order", "rand", test_files]))
end
task "install-core" => ["bootstrap", "plugin:install-core", "plugin:install-development-dependencies"]
task "install-default" => ["bootstrap", "plugin:install-default", "plugin:install-development-dependencies"]
task "install-all" => ["bootstrap", "plugin:install-all", "plugin:install-development-dependencies"]
task "install-vendor-plugins" => ["bootstrap", "plugin:install-vendor", "plugin:install-development-dependencies"]
task "install-jar-dependencies-plugins" => ["bootstrap", "plugin:install-jar-dependencies", "plugin:install-development-dependencies"]
# Setup simplecov to group files per functional modules, like this is easier to spot places with small coverage
task "setup-simplecov" do
require "simplecov"
SimpleCov.start do
# Skip non core related directories and files.
["vendor/", "spec/", "bootstrap/rspec", "Gemfile", "gemspec"].each do |pattern|
add_filter pattern
end
add_group "bootstrap", "bootstrap/" # This module is used during bootstrapping of LS
add_group "plugin manager", "pluginmanager/" # Code related to the plugin manager
add_group "core" do |src_file| # The LS core codebase
/logstash\/\w+.rb/.match(src_file.filename)
end
add_group "core-util", "logstash/util" # Set of LS utils module
add_group "core-config", "logstash/config" # LS Configuration modules
add_group "core-patches", "logstash/patches" # Patches used to overcome known issues in dependencies.
# LS Core plugins code base.
add_group "core-plugins", [ "logstash/codecs", "logstash/filters", "logstash/outputs", "logstash/inputs" ]
end
task.reenable
end
end
task "test" => [ "test:core" ]