logstash-core 2.1.3-java → 2.2.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of logstash-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/logstash-core.rb +1 -3
- data/lib/logstash-core/logstash-core.rb +3 -0
- data/lib/logstash-core/version.rb +8 -0
- data/lib/logstash/agent.rb +48 -20
- data/lib/logstash/codecs/base.rb +2 -2
- data/lib/logstash/config/config_ast.rb +8 -3
- data/lib/logstash/environment.rb +0 -16
- data/lib/logstash/filters/base.rb +9 -5
- data/lib/logstash/inputs/base.rb +1 -1
- data/lib/logstash/output_delegator.rb +150 -0
- data/lib/logstash/outputs/base.rb +37 -40
- data/lib/logstash/pipeline.rb +259 -178
- data/lib/logstash/pipeline_reporter.rb +114 -0
- data/lib/logstash/plugin.rb +1 -1
- data/lib/logstash/{shutdown_controller.rb → shutdown_watcher.rb} +10 -37
- data/lib/logstash/util.rb +17 -0
- data/lib/logstash/util/decorators.rb +14 -7
- data/lib/logstash/util/worker_threads_default_printer.rb +4 -4
- data/lib/logstash/util/wrapped_synchronous_queue.rb +41 -0
- data/lib/logstash/version.rb +10 -2
- data/locales/en.yml +8 -3
- data/logstash-core.gemspec +5 -3
- data/spec/{core/conditionals_spec.rb → conditionals_spec.rb} +0 -0
- data/spec/{core/config_spec.rb → logstash/config/config_ast_spec.rb} +0 -0
- data/spec/{core/config_cpu_core_strategy_spec.rb → logstash/config/cpu_core_strategy_spec.rb} +0 -0
- data/spec/{core/config_defaults_spec.rb → logstash/config/defaults_spec.rb} +0 -0
- data/spec/{core/config_mixin_spec.rb → logstash/config/mixin_spec.rb} +0 -0
- data/spec/{core → logstash}/environment_spec.rb +0 -0
- data/spec/{filters → logstash/filters}/base_spec.rb +0 -0
- data/spec/{inputs → logstash/inputs}/base_spec.rb +0 -0
- data/spec/{lib/logstash → logstash}/java_integration_spec.rb +0 -0
- data/spec/{util → logstash}/json_spec.rb +0 -0
- data/spec/logstash/output_delegator_spec.rb +126 -0
- data/spec/logstash/outputs/base_spec.rb +40 -0
- data/spec/logstash/pipeline_reporter_spec.rb +85 -0
- data/spec/{core → logstash}/pipeline_spec.rb +128 -16
- data/spec/{core → logstash}/plugin_spec.rb +47 -1
- data/spec/logstash/runner_spec.rb +68 -0
- data/spec/{core/shutdown_controller_spec.rb → logstash/shutdown_watcher_spec.rb} +17 -11
- data/spec/{util → logstash/util}/buftok_spec.rb +0 -0
- data/spec/{util → logstash/util}/charset_spec.rb +0 -0
- data/spec/{util → logstash/util}/defaults_printer_spec.rb +4 -4
- data/spec/{util → logstash/util}/java_version_spec.rb +0 -0
- data/spec/{util → logstash/util}/plugin_version_spec.rb +0 -0
- data/spec/{util → logstash/util}/unicode_trimmer_spec.rb +0 -0
- data/spec/{util → logstash/util}/worker_threads_default_printer_spec.rb +8 -8
- data/spec/logstash/util/wrapped_synchronous_queue_spec.rb +28 -0
- data/spec/{util_spec.rb → logstash/util_spec.rb} +0 -0
- metadata +74 -81
- data/lib/logstash/event.rb +0 -275
- data/lib/logstash/patches/bundler.rb +0 -36
- data/lib/logstash/sized_queue.rb +0 -8
- data/lib/logstash/string_interpolation.rb +0 -140
- data/lib/logstash/timestamp.rb +0 -97
- data/lib/logstash/util/accessors.rb +0 -123
- data/spec/core/event_spec.rb +0 -518
- data/spec/core/runner_spec.rb +0 -40
- data/spec/core/timestamp_spec.rb +0 -84
- data/spec/coverage_helper.rb +0 -24
- data/spec/lib/logstash/bundler_spec.rb +0 -121
- data/spec/license_spec.rb +0 -67
- data/spec/outputs/base_spec.rb +0 -26
- data/spec/plugin_manager/install_spec.rb +0 -28
- data/spec/plugin_manager/update_spec.rb +0 -39
- data/spec/plugin_manager/util_spec.rb +0 -71
- data/spec/spec_helper.rb +0 -11
- data/spec/util/accessors_spec.rb +0 -170
- data/spec/util/compress_spec.rb +0 -121
- data/spec/util/gemfile_spec.rb +0 -212
- data/spec/util/retryable_spec.rb +0 -139
data/spec/core/runner_spec.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "spec_helper"
|
3
|
-
require "logstash/runner"
|
4
|
-
require "stud/task"
|
5
|
-
|
6
|
-
class NullRunner
|
7
|
-
def run(args); end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe LogStash::Runner do
|
11
|
-
|
12
|
-
context "argument parsing" do
|
13
|
-
it "should run agent" do
|
14
|
-
expect(Stud::Task).to receive(:new).once.and_return(nil)
|
15
|
-
args = ["agent", "-e", ""]
|
16
|
-
expect(subject.run(args)).to eq(nil)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should run agent help" do
|
20
|
-
expect(subject).to receive(:show_help).once.and_return(nil)
|
21
|
-
args = ["agent", "-h"]
|
22
|
-
expect(subject.run(args).wait).to eq(0)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should show help with no arguments" do
|
26
|
-
expect($stderr).to receive(:puts).once.and_return("No command given")
|
27
|
-
expect($stderr).to receive(:puts).once
|
28
|
-
args = []
|
29
|
-
expect(subject.run(args).wait).to eq(1)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should show help for unknown commands" do
|
33
|
-
expect($stderr).to receive(:puts).once.and_return("No such command welp")
|
34
|
-
expect($stderr).to receive(:puts).once
|
35
|
-
args = ["welp"]
|
36
|
-
expect(subject.run(args).wait).to eq(1)
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
data/spec/core/timestamp_spec.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "spec_helper"
|
3
|
-
require "logstash/timestamp"
|
4
|
-
|
5
|
-
describe LogStash::Timestamp do
|
6
|
-
|
7
|
-
it "should parse its own iso8601 output" do
|
8
|
-
t = Time.now
|
9
|
-
ts = LogStash::Timestamp.new(t)
|
10
|
-
expect(LogStash::Timestamp.parse_iso8601(ts.to_iso8601).to_i).to eq(t.to_i)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should coerce iso8601 string" do
|
14
|
-
t = Time.now
|
15
|
-
ts = LogStash::Timestamp.new(t)
|
16
|
-
expect(LogStash::Timestamp.coerce(ts.to_iso8601).to_i).to eq(t.to_i)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should coerce Time" do
|
20
|
-
t = Time.now
|
21
|
-
expect(LogStash::Timestamp.coerce(t).to_i).to eq(t.to_i)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should coerce Timestamp" do
|
25
|
-
t = LogStash::Timestamp.now
|
26
|
-
expect(LogStash::Timestamp.coerce(t).to_i).to eq(t.to_i)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should raise on invalid string coerce" do
|
30
|
-
expect{LogStash::Timestamp.coerce("foobar")}.to raise_error LogStash::TimestampParserError
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should return nil on invalid object coerce" do
|
34
|
-
expect(LogStash::Timestamp.coerce(:foobar)).to be_nil
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should support to_json" do
|
38
|
-
expect(LogStash::Timestamp.parse_iso8601("2014-09-23T00:00:00-0800").to_json).to eq("\"2014-09-23T08:00:00.000Z\"")
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should support to_json and ignore arguments" do
|
42
|
-
expect(LogStash::Timestamp.parse_iso8601("2014-09-23T00:00:00-0800").to_json(:some => 1, :argumnents => "test")).to eq("\"2014-09-23T08:00:00.000Z\"")
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should support timestamp comparaison" do
|
46
|
-
current = LogStash::Timestamp.new(Time.now)
|
47
|
-
future = LogStash::Timestamp.new(Time.now + 100)
|
48
|
-
|
49
|
-
expect(future > current).to eq(true)
|
50
|
-
expect(future < current).to eq(false)
|
51
|
-
expect(current == current).to eq(true)
|
52
|
-
|
53
|
-
expect(current <=> current).to eq(0)
|
54
|
-
expect(current <=> future).to eq(-1)
|
55
|
-
expect(future <=> current).to eq(1)
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should allow unary operation +" do
|
59
|
-
current = Time.now
|
60
|
-
t = LogStash::Timestamp.new(current) + 10
|
61
|
-
expect(t).to eq(current + 10)
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "subtraction" do
|
65
|
-
it "should work on a timestamp object" do
|
66
|
-
t = Time.now
|
67
|
-
current = LogStash::Timestamp.new(t)
|
68
|
-
future = LogStash::Timestamp.new(t + 10)
|
69
|
-
expect(future - current).to eq(10)
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should work on with time object" do
|
73
|
-
current = Time.now
|
74
|
-
t = LogStash::Timestamp.new(current + 10)
|
75
|
-
expect(t - current).to eq(10)
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should work with numeric value" do
|
79
|
-
current = Time.now
|
80
|
-
t = LogStash::Timestamp.new(current + 10)
|
81
|
-
expect(t - 10).to eq(current)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
data/spec/coverage_helper.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# Useful module to help loading all logstash content when
|
3
|
-
# running coverage analysis
|
4
|
-
module CoverageHelper
|
5
|
-
|
6
|
-
##
|
7
|
-
# Skip list used to avoid loading certain patterns within
|
8
|
-
# the logstash directories, this patterns are excluded becuause
|
9
|
-
# of potential problems or because they are going to be loaded
|
10
|
-
# in another way.
|
11
|
-
##
|
12
|
-
SKIP_LIST = Regexp.union([
|
13
|
-
/^lib\/bootstrap\/rspec.rb$/,
|
14
|
-
/^lib\/logstash\/util\/prctl.rb$/
|
15
|
-
])
|
16
|
-
|
17
|
-
def self.eager_load
|
18
|
-
Dir.glob("lib/**/*.rb") do |file|
|
19
|
-
next if file =~ SKIP_LIST
|
20
|
-
require file
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "spec_helper"
|
3
|
-
require "bundler/cli"
|
4
|
-
|
5
|
-
describe LogStash::Bundler do
|
6
|
-
context "capture_stdout" do
|
7
|
-
it "should capture stdout from block" do
|
8
|
-
original_stdout = $stdout
|
9
|
-
output, exception = LogStash::Bundler.capture_stdout do
|
10
|
-
expect($stdout).not_to eq(original_stdout)
|
11
|
-
puts("foobar")
|
12
|
-
end
|
13
|
-
expect($stdout).to eq(original_stdout)
|
14
|
-
expect(output).to eq("foobar\n")
|
15
|
-
expect(exception).to eq(nil)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should capture stdout and report exception from block" do
|
19
|
-
output, exception = LogStash::Bundler.capture_stdout do
|
20
|
-
puts("foobar")
|
21
|
-
raise(StandardError, "baz")
|
22
|
-
end
|
23
|
-
expect(output).to eq("foobar\n")
|
24
|
-
expect(exception).to be_a(StandardError)
|
25
|
-
expect(exception.message).to eq("baz")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'when invoking bundler' do
|
30
|
-
original_stderr = $stderr
|
31
|
-
|
32
|
-
subject { LogStash::Bundler.invoke!(options) }
|
33
|
-
|
34
|
-
# by default we want to fail fast on the test
|
35
|
-
let(:options) { { :install => true, :max_tries => 0, :without => [:development]} }
|
36
|
-
let(:bundler_args) { LogStash::Bundler.bundler_arguments(options) }
|
37
|
-
|
38
|
-
before do
|
39
|
-
$stderr = StringIO.new
|
40
|
-
|
41
|
-
expect(::Bundler).to receive(:reset!).at_least(1)
|
42
|
-
end
|
43
|
-
|
44
|
-
after do
|
45
|
-
expect(::Bundler.settings[:path]).to eq(LogStash::Environment::BUNDLE_DIR)
|
46
|
-
expect(::Bundler.settings[:gemfile]).to eq(LogStash::Environment::GEMFILE_PATH)
|
47
|
-
expect(::Bundler.settings[:without]).to eq(options.fetch(:without, []).join(':'))
|
48
|
-
|
49
|
-
expect(ENV['GEM_PATH']).to eq(LogStash::Environment.logstash_gem_home)
|
50
|
-
|
51
|
-
$stderr = original_stderr
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should call Bundler::CLI.start with the correct arguments' do
|
55
|
-
expect(::Bundler::CLI).to receive(:start).with(bundler_args)
|
56
|
-
LogStash::Bundler.invoke!(options)
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'abort with an exception' do
|
60
|
-
it 'gem conflict' do
|
61
|
-
allow(::Bundler::CLI).to receive(:start).with(bundler_args) { raise ::Bundler::VersionConflict.new('conflict') }
|
62
|
-
expect { subject }.to raise_error(::Bundler::VersionConflict)
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'gem is not found' do
|
66
|
-
allow(::Bundler::CLI).to receive(:start).with(bundler_args) { raise ::Bundler::GemNotFound.new('conflict') }
|
67
|
-
expect { subject }.to raise_error(::Bundler::GemNotFound)
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'on max retries' do
|
71
|
-
options.merge!({ :max_tries => 2 })
|
72
|
-
expect(::Bundler::CLI).to receive(:start).with(bundler_args).at_most(options[:max_tries] + 1) { raise RuntimeError }
|
73
|
-
expect { subject }.to raise_error(RuntimeError)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context 'when generating bundler arguments' do
|
79
|
-
subject { LogStash::Bundler.bundler_arguments(options) }
|
80
|
-
let(:options) { {} }
|
81
|
-
|
82
|
-
context 'when installing' do
|
83
|
-
let(:options) { { :install => true } }
|
84
|
-
|
85
|
-
it 'should call bundler install' do
|
86
|
-
expect(subject).to include('install')
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'with the cleaning option' do
|
90
|
-
it 'should add the --clean arguments' do
|
91
|
-
options.merge!(:clean => true)
|
92
|
-
expect(subject).to include('install','--clean')
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
context "when updating" do
|
98
|
-
let(:options) { { :update => 'logstash-input-stdin' } }
|
99
|
-
|
100
|
-
context 'with a specific plugin' do
|
101
|
-
it 'should call `bundle update plugin-name`' do
|
102
|
-
expect(subject).to include('update', 'logstash-input-stdin')
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'with the cleaning option' do
|
107
|
-
it 'should ignore the clean option' do
|
108
|
-
options.merge!(:clean => true)
|
109
|
-
expect(subject).not_to include('--clean')
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
context "when only specifying clean" do
|
115
|
-
let(:options) { { :clean => true } }
|
116
|
-
it 'should call the `bundle clean`' do
|
117
|
-
expect(subject).to include('clean')
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
data/spec/license_spec.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'rakelib/default_plugins'
|
4
|
-
|
5
|
-
describe "Project licenses" do
|
6
|
-
|
7
|
-
let(:expected_licenses) {
|
8
|
-
##
|
9
|
-
# Expected licenses are Apache License 2.0, BSD license, MIT license and the ruby one,
|
10
|
-
# this not exclude that this list change in the feature.
|
11
|
-
##
|
12
|
-
Regexp.union([ /mit/,
|
13
|
-
/apache*/,
|
14
|
-
/bsd/,
|
15
|
-
/artistic 2.*/,
|
16
|
-
/ruby/,
|
17
|
-
/lgpl/])
|
18
|
-
}
|
19
|
-
|
20
|
-
##
|
21
|
-
# This licenses are skipped from the license test of many reasons, check
|
22
|
-
# the exact dependency for detailed information.
|
23
|
-
##
|
24
|
-
let(:skipped_dependencies) do
|
25
|
-
[
|
26
|
-
# Skipped because of already included and bundled within JRuby so checking here is redundant.
|
27
|
-
# Need to take action about jruby licenses to enable again or keep skeeping.
|
28
|
-
"jruby-openssl"
|
29
|
-
]
|
30
|
-
end
|
31
|
-
|
32
|
-
shared_examples "runtime license test" do
|
33
|
-
|
34
|
-
subject(:gem_name) do |example|
|
35
|
-
example.metadata[:example_group][:parent_example_group][:description]
|
36
|
-
end
|
37
|
-
|
38
|
-
let(:spec) { Gem::Specification.find_all_by_name(gem_name)[0] }
|
39
|
-
|
40
|
-
it "have an expected license" do
|
41
|
-
spec.licenses.each do |license|
|
42
|
-
expect(license.downcase).to match(expected_licenses)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
it "has runtime dependencies with expected licenses" do
|
47
|
-
spec.runtime_dependencies.map { |dep| dep.to_spec }.each do |runtime_spec|
|
48
|
-
next unless runtime_spec
|
49
|
-
next if skipped_dependencies.include?(runtime_spec.name)
|
50
|
-
runtime_spec.licenses.each do |license|
|
51
|
-
expect(license.downcase).to match(expected_licenses)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "logstash-core" do
|
58
|
-
it_behaves_like "runtime license test"
|
59
|
-
end
|
60
|
-
|
61
|
-
installed_plugins.each do |plugin|
|
62
|
-
describe plugin do
|
63
|
-
it_behaves_like "runtime license test"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
data/spec/outputs/base_spec.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
# use a dummy NOOP output to test Outputs::Base
|
5
|
-
class LogStash::Outputs::NOOP < LogStash::Outputs::Base
|
6
|
-
config_name "noop"
|
7
|
-
milestone 2
|
8
|
-
|
9
|
-
config :dummy_option, :validate => :string
|
10
|
-
|
11
|
-
def register; end
|
12
|
-
|
13
|
-
def receive(event)
|
14
|
-
return output?(event)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "LogStash::Outputs::Base#worker_setup" do
|
19
|
-
it "should create workers using original parameters except workers = 1" do
|
20
|
-
params = { "dummy_option" => "potatoes", "codec" => "json", "workers" => 2 }
|
21
|
-
worker_params = params.dup; worker_params["workers"] = 1
|
22
|
-
output = LogStash::Outputs::NOOP.new(params.dup)
|
23
|
-
expect(LogStash::Outputs::NOOP).to receive(:new).twice.with(worker_params).and_call_original
|
24
|
-
output.worker_setup
|
25
|
-
end
|
26
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'pluginmanager/main'
|
4
|
-
|
5
|
-
describe LogStash::PluginManager::Install do
|
6
|
-
let(:cmd) { LogStash::PluginManager::Install.new("install") }
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
expect(cmd).to receive(:validate_cli_options!).and_return(nil)
|
10
|
-
end
|
11
|
-
|
12
|
-
context "when validating plugins" do
|
13
|
-
let(:sources) { ["https://rubygems.org", "http://localhost:9292"] }
|
14
|
-
|
15
|
-
before(:each) do
|
16
|
-
expect(cmd).to receive(:plugins_gems).and_return([["dummy", nil]])
|
17
|
-
expect(cmd).to receive(:install_gems_list!).and_return(nil)
|
18
|
-
expect(cmd).to receive(:remove_unused_locally_installed_gems!).and_return(nil)
|
19
|
-
cmd.verify = true
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should load all the sources defined in the Gemfile" do
|
23
|
-
expect(cmd.gemfile.gemset).to receive(:sources).and_return(sources)
|
24
|
-
expect(LogStash::PluginManager).to receive(:logstash_plugin?).with("dummy", nil, {:rubygems_source => sources}).and_return(true)
|
25
|
-
cmd.execute
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'pluginmanager/main'
|
4
|
-
|
5
|
-
describe LogStash::PluginManager::Update do
|
6
|
-
let(:cmd) { LogStash::PluginManager::Update.new("update") }
|
7
|
-
let(:sources) { cmd.gemfile.gemset.sources }
|
8
|
-
|
9
|
-
before(:each) do
|
10
|
-
expect(cmd).to receive(:find_latest_gem_specs).and_return({})
|
11
|
-
allow(cmd).to receive(:warn_local_gems).and_return(nil)
|
12
|
-
expect(cmd).to receive(:display_updated_plugins).and_return(nil)
|
13
|
-
expect_any_instance_of(LogStash::Bundler).to receive(:invoke!).with(:clean => true)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "pass all gem sources to the bundle update command" do
|
17
|
-
sources = cmd.gemfile.gemset.sources
|
18
|
-
expect_any_instance_of(LogStash::Bundler).to receive(:invoke!).with(:update => [], :rubygems_source => sources)
|
19
|
-
cmd.execute
|
20
|
-
end
|
21
|
-
|
22
|
-
context "when skipping validation" do
|
23
|
-
let(:cmd) { LogStash::PluginManager::Update.new("update") }
|
24
|
-
let(:plugin) { OpenStruct.new(:name => "dummy", :options => {} ) }
|
25
|
-
|
26
|
-
before(:each) do
|
27
|
-
expect(cmd.gemfile).to receive(:find).with(plugin).and_return(plugin)
|
28
|
-
expect(cmd.gemfile).to receive(:save).and_return(nil)
|
29
|
-
expect(cmd).to receive(:plugins_to_update).and_return([plugin])
|
30
|
-
expect_any_instance_of(LogStash::Bundler).to receive(:invoke!).with(:update => [plugin], :rubygems_source => sources).and_return(nil)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "skips version verification when ask for it" do
|
34
|
-
cmd.verify = false
|
35
|
-
expect(cmd).to_not receive(:validates_version)
|
36
|
-
cmd.execute
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'pluginmanager/util'
|
4
|
-
require 'gems'
|
5
|
-
|
6
|
-
describe LogStash::PluginManager do
|
7
|
-
|
8
|
-
describe "fetching plugin information" do
|
9
|
-
let(:plugin_name) { "logstash-output-elasticsearch" }
|
10
|
-
|
11
|
-
let(:version_data) do
|
12
|
-
[ { "authors"=>"Elastic", "built_at"=>"2015-08-11T00:00:00.000Z", "description"=>"Output events to elasticsearch",
|
13
|
-
"downloads_count"=>1638, "metadata"=>{"logstash_group"=>"output", "logstash_plugin"=>"true"}, "number"=>"2.0.0.pre",
|
14
|
-
"summary"=>"Logstash Output to Elasticsearch", "platform"=>"java", "ruby_version"=>">= 0", "prerelease"=>true,
|
15
|
-
"licenses"=>["apache-2.0"], "requirements"=>[], "sha"=>"194b27099c13605a882a3669e2363fdecccaab1de48dd44b0cda648dd5516799"},
|
16
|
-
{ "authors"=>"Elastic", "built_at"=>"2015-08-10T00:00:00.000Z", "description"=>"Output events to elasticsearch",
|
17
|
-
"downloads_count"=>1638, "metadata"=>{"logstash_group"=>"output", "logstash_plugin"=>"true"}, "number"=>"1.0.7",
|
18
|
-
"summary"=>"Logstash Output to Elasticsearch", "platform"=>"java", "ruby_version"=>">= 0", "prerelease"=>false,
|
19
|
-
"licenses"=>["apache-2.0"], "requirements"=>[], "sha"=>"194b27099c13605a882a3669e2363fdecccaab1de48dd44b0cda648dd5516799"},
|
20
|
-
{ "authors"=>"Elastic", "built_at"=>"2015-08-09T00:00:00.000Z", "description"=>"Output events to elasticsearch",
|
21
|
-
"downloads_count"=>1638, "metadata"=>{"logstash_group"=>"output", "logstash_plugin"=>"true"}, "number"=>"1.0.4",
|
22
|
-
"summary"=>"Logstash Output to Elasticsearch", "platform"=>"java", "ruby_version"=>">= 0", "prerelease"=>false,
|
23
|
-
"licenses"=>["apache-2.0"], "requirements"=>[], "sha"=>"194b27099c13605a882a3669e2363fdecccaab1de48dd44b0cda648dd5516799"} ]
|
24
|
-
end
|
25
|
-
|
26
|
-
before(:each) do
|
27
|
-
allow(Gems).to receive(:versions).with(plugin_name).and_return(version_data)
|
28
|
-
end
|
29
|
-
|
30
|
-
context "fetch plugin info" do
|
31
|
-
it "should search for the last version infomation non prerelease" do
|
32
|
-
version_info = LogStash::PluginManager.fetch_latest_version_info(plugin_name)
|
33
|
-
expect(version_info["number"]).to eq("1.0.7")
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
it "should search for the last version infomation with prerelease" do
|
38
|
-
version_info = LogStash::PluginManager.fetch_latest_version_info(plugin_name, :pre => true)
|
39
|
-
expect(version_info["number"]).to eq("2.0.0.pre")
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "a logstash_plugin validation" do
|
45
|
-
let(:plugin) { "foo" }
|
46
|
-
let(:version) { "9.0.0.0" }
|
47
|
-
|
48
|
-
let(:sources) { ["http://source.01", "http://source.02"] }
|
49
|
-
let(:options) { {:rubygems_source => sources} }
|
50
|
-
|
51
|
-
let(:gemset) { double("gemset") }
|
52
|
-
let(:gemfile) { double("gemfile") }
|
53
|
-
let(:dep) { double("dep") }
|
54
|
-
let(:fetcher) { double("fetcher") }
|
55
|
-
|
56
|
-
before(:each) do
|
57
|
-
allow(gemfile).to receive(:gemset).and_return(gemset)
|
58
|
-
allow(gemset).to receive(:sources).and_return(sources)
|
59
|
-
expect(fetcher).to receive(:spec_for_dependency).and_return([[],[]])
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should load all available sources" do
|
63
|
-
expect(subject).to receive(:plugin_file?).and_return(false)
|
64
|
-
expect(Gem::Dependency).to receive(:new).and_return(dep)
|
65
|
-
expect(Gem::SpecFetcher).to receive(:fetcher).and_return(fetcher)
|
66
|
-
|
67
|
-
subject.logstash_plugin?(plugin, version, options)
|
68
|
-
expect(Gem.sources.map { |source| source }).to eq(sources)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|