Skip to content

Commit

Permalink
use jruby 9.1.9.0
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ph committed Jun 12, 2017
1 parent fae99f1 commit 76286b4
Show file tree
Hide file tree
Showing 33 changed files with 123 additions and 145 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ qa/.vm_ssh_config
qa/.vagrant
qa/acceptance/.vagrant
qa/Gemfile.lock
Gemfile.jruby-1.9.lock
Gemfile.jruby-2.3.lock
Gemfile
*.ipr
*.iws
Expand Down
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ cache:
- vendor/bundle
- ~/.gradle/
rvm:
- jruby-1.7.25
- jruby-9.1.9.0
jdk:
- oraclejdk8
env:
- INTEGRATION=false SPEC_OPTS="--order rand --format documentation"
- INTEGRATION=true SPEC_OPTS="--order rand --format documentation"
- INTEGRATION=false FEATURE_FLAG=persistent_queues SPEC_OPTS="--order rand --format documentation"
- INTEGRATION=true FEATURE_FLAG=persistent_queues SPEC_OPTS="--order rand --format documentation"
- INTEGRATION=false SPEC_OPTS="--order rand --format documentation" JRUBY_OPTS='-Xcompile.invokedynamic=false'
- INTEGRATION=true SPEC_OPTS="--order rand --format documentation" JRUBY_OPTS='-Xcompile.invokedynamic=false'
- INTEGRATION=false FEATURE_FLAG=persistent_queues SPEC_OPTS="--order rand --format documentation" JRUBY_OPTS='-Xcompile.invokedynamic=false'
- INTEGRATION=true FEATURE_FLAG=persistent_queues SPEC_OPTS="--order rand --format documentation" JRUBY_OPTS='-Xcompile.invokedynamic=false'
before_install:
- sudo apt-get remove -y docker-engine
- sudo apt-get install -y docker-engine
- sudo service docker stop
- sudo dockerd --disable-legacy-registry &>/dev/null &
- export JRUBY_OPTS=""
# Force bundler 1.12.5 because version 1.13 has issues, see https://github.com/fastlane/fastlane/issues/6065#issuecomment-246044617
- yes | gem uninstall -q -i /home/travis/.rvm/gems/jruby-1.7.25@global bundler
- yes | gem uninstall -q -i /home/travis/.rvm/gems/jruby-9.1.9.0@global bundler
- gem install bundler -v 1.12.5 --no-rdoc --no-ri --no-document --quiet
install:
- rake test:install-core
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ gem "file-dependencies", "0.1.6"
gem "ci_reporter_rspec", "1.0.0", :group => :development
gem "simplecov", :group => :development
gem "tins", "1.6", :group => :development
gem "rspec", "~> 3.1.0", :group => :development
gem "rspec", "~> 3.5", :group => :development
gem "logstash-devutils", :group => :development
gem "benchmark-ips", :group => :development
gem "octokit", "3.8.0", :group => :build
gem "stud", "~> 0.0.22", :group => :build
gem "fpm", "~> 1.3.3", :group => :build
gem "rubyzip", "~> 1.1.7", :group => :build
gem "rubyzip", "~> 1.2.1", :group => :build
gem "gems", "~> 0.8.3", :group => :build
gem "rack-test", :require => "rack/test", :group => :development
gem "flores", "~> 0.0.6", :group => :development
Expand Down
1 change: 1 addition & 0 deletions STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,4 @@ inconsistencies between ruby versions.

# This is good.
str[0, 1]

4 changes: 3 additions & 1 deletion bin/bundle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Signal.trap("INT") { exit 1 }

require_relative "../lib/bootstrap/environment"
::Gem.clear_paths
::Gem.paths = ENV['GEM_HOME'] = ENV['GEM_PATH'] = LogStash::Environment.logstash_gem_home

ENV['GEM_HOME'] = ENV['GEM_PATH'] = LogStash::Environment.logstash_gem_home
::Gem.paths = ENV

ENV["BUNDLE_GEMFILE"] = LogStash::Environment::GEMFILE_PATH

Expand Down
9 changes: 5 additions & 4 deletions lib/bootstrap/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def setup!(options = {})
# make sure we use our own installed bundler
LogStash::Rubygems.patch!
::Gem.clear_paths
::Gem.paths = ENV['GEM_HOME'] = ENV['GEM_PATH'] = Environment.logstash_gem_home
ENV['GEM_HOME'] = ENV['GEM_PATH'] = Environment.logstash_gem_home
::Gem.paths = ENV

# set BUNDLE_GEMFILE ENV before requiring bundler to avoid bundler recurse and load unrelated Gemfile(s)
ENV["BUNDLE_GEMFILE"] = Environment::GEMFILE_PATH
Expand Down Expand Up @@ -89,8 +90,8 @@ def invoke!(options = {})
# require "logstash/patches/rubygems" # patch rubygems before clear_paths
LogStash::Rubygems.patch!
::Gem.clear_paths
::Gem.paths = ENV['GEM_HOME'] = ENV['GEM_PATH'] = LogStash::Environment.logstash_gem_home

ENV['GEM_HOME'] = ENV['GEM_PATH'] = LogStash::Environment.logstash_gem_home
::Gem.paths = ENV
# set BUNDLE_GEMFILE ENV before requiring bundler to avoid bundler recurse and load unrelated Gemfile(s).
# in the context of calling Bundler::CLI this is not really required since Bundler::CLI will look at
# Bundler.settings[:gemfile] unlike Bundler.setup. For the sake of consistency and defensive/future proofing, let's keep it here.
Expand All @@ -106,7 +107,7 @@ def invoke!(options = {})
)
end
# create Gemfile.jruby-1.9.lock from template iff a template exists it itself does not exist
lock_template = ::File.join(ENV["LOGSTASH_HOME"], "Gemfile.jruby-1.9.lock.release")
lock_template = ::File.join(ENV["LOGSTASH_HOME"], "Gemfile.jruby-2.3.lock.release")
if ::File.exists?(lock_template) && !::File.exists?(Environment::LOCKFILE)
FileUtils.copy(lock_template, Environment::LOCKFILE)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bootstrap/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Environment
GEMFILE_PATH = ::File.join(LOGSTASH_HOME, "Gemfile")
LOCAL_GEM_PATH = ::File.join(LOGSTASH_HOME, 'vendor', 'local_gems')
CACHE_PATH = ::File.join(LOGSTASH_HOME, "vendor", "cache")
LOCKFILE = Pathname.new(::File.join(LOGSTASH_HOME, "Gemfile.jruby-1.9.lock"))
LOCKFILE = Pathname.new(::File.join(LOGSTASH_HOME, "Gemfile.jruby-2.3.lock"))
GEMFILE = Pathname.new(::File.join(LOGSTASH_HOME, "Gemfile"))

# @return [String] the ruby version string bundler uses to craft its gem path
Expand Down
7 changes: 7 additions & 0 deletions lib/pluginmanager/bundler/logstash_injector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require "bundler/injector"
require "bundler/shared_helpers"
require "pluginmanager/gemfile"
require "rubygems/specification"
require "pathname"


Expand All @@ -23,6 +24,12 @@ def default_bundle_dir
module Bundler
class LogstashInjector < ::Bundler::Injector
def self.inject!(new_deps, options = { :gemfile => LogStash::Environment::GEMFILE, :lockfile => LogStash::Environment::LOCKFILE })
# Make sure all the available Specifications
# are loaded before trying to inject any new gems
# If we dont do this, we will have a stale index that wont have the gems
# that we just have installed.
::Gem::Specification.reset

gemfile = options.delete(:gemfile)
lockfile = options.delete(:lockfile)

Expand Down
63 changes: 0 additions & 63 deletions lib/pluginmanager/custom_gem_indexer.rb

This file was deleted.

8 changes: 4 additions & 4 deletions lib/pluginmanager/gem_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module LogStash module PluginManager
# - Generate the specifications
# - Copy the data in the right folders
class GemInstaller
GEM_HOME = Pathname.new(::File.join(LogStash::Environment::BUNDLE_DIR, "jruby", "1.9"))
GEM_HOME = Pathname.new(::File.join(LogStash::Environment::BUNDLE_DIR, "jruby", "2.3.0"))
SPECIFICATIONS_DIR = "specifications"
GEMS_DIR = "gems"
CACHE_DIR = "cache"
Expand All @@ -28,8 +28,8 @@ def install
create_destination_folders
extract_files
write_specification
display_post_install_message
copy_gem_file_to_cache
post_install_message
end

def self.install(gem_file, display_post_install_message = false, gem_home = GEM_HOME)
Expand Down Expand Up @@ -69,8 +69,8 @@ def write_specification
end
end

def display_post_install_message
PluginManager.ui.info(spec.post_install_message) if display_post_install_message?
def post_install_message
spec.post_install_message if display_post_install_message?
end

def display_post_install_message?
Expand Down
16 changes: 9 additions & 7 deletions lib/pluginmanager/pack_installer/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require "pluginmanager/ui"
require "pluginmanager/bundler/logstash_injector"
require "pluginmanager/gem_installer"
require "pluginmanager/custom_gem_indexer"
require "pluginmanager/errors"
require "pluginmanager/pack_installer/pack"
require "bootstrap/util/compress"
Expand All @@ -29,24 +28,27 @@ def execute
pack = LogStash::PluginManager::PackInstaller::Pack.new(uncompressed_path)
raise PluginManager::InvalidPackError, "The pack must contains at least one plugin" unless pack.valid?

local_source = LogStash::PluginManager::CustomGemIndexer.index(uncompressed_path)
# Install the gems to make them available locally when bundler does his local resolution
post_install_messages = []
pack.gems.each do |packed_gem|
PluginManager.ui.debug("Installing, #{packed_gem.name}, version: #{packed_gem.version} file: #{packed_gem.file}")
post_install_messages << LogStash::PluginManager::GemInstaller::install(packed_gem.file, packed_gem.plugin?)
end

# Try to add the gems to the current gemfile and lock file, if successful
# both of them will be updated. This injector is similar to Bundler's own injector class
# minus the support for additionals source and doing local resolution only.
::Bundler::LogstashInjector.inject!(pack)

# When successful its safe to install the gem and their specifications in the bundle directory
pack.gems.each do |packed_gem|
PluginManager.ui.debug("Installing, #{packed_gem.name}, version: #{packed_gem.version} file: #{packed_gem.file}")
LogStash::PluginManager::GemInstaller::install(packed_gem.file, packed_gem.plugin?)
post_install_messages.compact.each do |message|
PluginManager.ui.info(message)
end

PluginManager.ui.info("Install successful")
rescue ::Bundler::BundlerError => e
raise PluginManager::InstallError.new(e), "An error occurred went installing plugins"
ensure
FileUtils.rm_rf(uncompressed_path) if uncompressed_path && Dir.exist?(uncompressed_path)
FileUtils.rm_rf(local_source) if local_source && Dir.exist?(local_source)
end

private
Expand Down
4 changes: 2 additions & 2 deletions logstash-core/lib/logstash/bootstrap_check/bad_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
module LogStash module BootstrapCheck
class BadRuby
def self.check(settings)
if RUBY_VERSION < "1.9.2"
raise LogStash::BootstrapCheckError, "Ruby 1.9.2 or later is required. (You are running: " + RUBY_VERSION + ")"
if RUBY_VERSION < "2.0"
raise LogStash::BootstrapCheckError, "Ruby 2.0 or later is required. (You are running: " + RUBY_VERSION + ")"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions logstash-core/logstash-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Gem::Specification.new do |gem|

gem.add_runtime_dependency "sinatra", '~> 1.4', '>= 1.4.6'
gem.add_runtime_dependency 'puma', '~> 2.16'
gem.add_runtime_dependency "jruby-openssl", "0.9.16" # >= 0.9.13 Required to support TLSv1.2
gem.add_runtime_dependency "jruby-openssl", "0.9.20" # >= 0.9.13 Required to support TLSv1.2
gem.add_runtime_dependency "chronic_duration", "0.10.6"

# TODO(sissel): Treetop 1.5.x doesn't seem to work well, but I haven't
Expand All @@ -43,7 +43,7 @@ Gem::Specification.new do |gem|

# filetools and rakelib
gem.add_runtime_dependency "minitar", "~> 0.5.4"
gem.add_runtime_dependency "rubyzip", "~> 1.1.7"
gem.add_runtime_dependency "rubyzip", "~> 1.2.1"
gem.add_runtime_dependency "thread_safe", "~> 0.3.5" #(Apache 2.0 license)

gem.add_runtime_dependency "jrjackson", "~> 0.4.2" #(Apache 2.0 license)
Expand Down
3 changes: 2 additions & 1 deletion logstash-core/spec/logstash/compiler/compiler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def j

describe "applying protocol and id metadata" do
it "should apply the correct source metadata to all components" do
pipeline.plugin_vertices.each do |pv|
# TODO: seems to be a jruby regression we cannot currently call each on a stream
pipeline.get_plugin_vertices.each do |pv|
name_idx = pv.plugin_definition.name.split("_").last
source_protocol_idx = pv.source_with_metadata.protocol.split("_").last
source_id_idx = pv.source_with_metadata.id.split("_").last
Expand Down
2 changes: 1 addition & 1 deletion logstash-core/spec/logstash/filters/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def filter(event)
end

it "should provide class public API" do
[:register, :filter, :multi_filter, :execute, :threadsafe?, :filter_matched, :filter?, :close].each do |method|
[:register, :filter, :multi_filter, :execute, :threadsafe?, :close].each do |method|
expect(subject).to respond_to(method)
end
end
Expand Down
16 changes: 8 additions & 8 deletions logstash-core/spec/logstash/legacy_ruby_timestamp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
end

it "should coerce iso8601 string" do
t = Time.now
t = DateTime.now.to_time
ts = LogStash::Timestamp.new(t)
expect(LogStash::Timestamp.coerce(ts.to_iso8601).to_i).to eq(t.to_i)
end
Expand Down Expand Up @@ -57,27 +57,27 @@
end

it "should allow unary operation +" do
current = Time.now
current = DateTime.now.to_time
t = LogStash::Timestamp.new(current) + 10
expect(t).to eq(current + 10)
end

describe "subtraction" do
it "should work on a timestamp object" do
t = Time.now
t = DateTime.now.to_time
current = LogStash::Timestamp.new(t)
future = LogStash::Timestamp.new(t + 10)
expect(future - current).to eq(10)
end

it "should work on with time object" do
current = Time.now
current = DateTime.now.to_time
t = LogStash::Timestamp.new(current + 10)
expect(t - current).to eq(10)
end

it "should work with numeric value" do
current = Time.now
current = DateTime.now.to_time
t = LogStash::Timestamp.new(current + 10)
expect(t - 10).to eq(current)
end
Expand All @@ -96,15 +96,15 @@
end

context "numeric casting methods" do
let (:now) {Time.now}
let(:now) { Time.now }
subject { LogStash::Timestamp.new(now) }

it "should support to_i" do
expect(subject.to_i).to eq(now.to_i)
expect(subject.to_i).to be_kind_of(Integer)
end

it "should support to_f" do
expect(subject.to_f).to eq(now.to_f)
expect(subject.to_f).to be_kind_of(Float)
end
end

Expand Down
Loading

0 comments on commit 76286b4

Please sign in to comment.