logstash-core 7.0.0.alpha2-java → 7.0.0.beta1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstash/agent.rb +62 -57
- data/lib/logstash/compiler/lscl.rb +2 -3
- data/lib/logstash/config/config_ast.rb +59 -17
- data/lib/logstash/environment.rb +1 -1
- data/lib/logstash/instrument/metric_store.rb +1 -1
- data/lib/logstash/instrument/periodic_poller/dlq.rb +5 -7
- data/lib/logstash/instrument/periodic_poller/pq.rb +6 -8
- data/lib/logstash/instrument/periodic_pollers.rb +3 -3
- data/lib/logstash/java_pipeline.rb +36 -15
- data/lib/logstash/patches/resolv.rb +0 -21
- data/lib/logstash/pipeline.rb +27 -10
- data/lib/logstash/pipeline_action/base.rb +1 -1
- data/lib/logstash/pipeline_action/create.rb +7 -13
- data/lib/logstash/pipeline_action/reload.rb +35 -12
- data/lib/logstash/pipeline_action/stop.rb +4 -6
- data/lib/logstash/pipeline_settings.rb +1 -1
- data/lib/logstash/pipelines_registry.rb +166 -0
- data/lib/logstash/settings.rb +5 -5
- data/lib/logstash/state_resolver.rb +5 -5
- data/lib/logstash/util/duration_formatter.rb +1 -1
- data/lib/logstash/util/safe_uri.rb +1 -0
- data/lib/logstash/util.rb +11 -1
- data/locales/en.yml +1 -1
- data/logstash-core.gemspec +17 -20
- data/spec/logstash/acked_queue_concurrent_stress_spec.rb +1 -1
- data/spec/logstash/agent/converge_spec.rb +25 -31
- data/spec/logstash/agent_spec.rb +5 -5
- data/spec/logstash/event_spec.rb +2 -2
- data/spec/logstash/instrument/wrapped_write_client_spec.rb +1 -1
- data/spec/logstash/legacy_ruby_event_spec.rb +6 -5
- data/spec/logstash/pipeline_action/create_spec.rb +9 -8
- data/spec/logstash/pipeline_action/reload_spec.rb +10 -9
- data/spec/logstash/pipeline_action/stop_spec.rb +4 -3
- data/spec/logstash/pipelines_registry_spec.rb +220 -0
- data/spec/logstash/queue_factory_spec.rb +2 -1
- data/spec/logstash/runner_spec.rb +2 -0
- data/spec/logstash/settings/array_coercible_spec.rb +1 -1
- data/spec/logstash/settings/bytes_spec.rb +2 -2
- data/spec/logstash/settings/port_range_spec.rb +1 -1
- data/spec/logstash/state_resolver_spec.rb +26 -22
- data/spec/logstash/util/safe_uri_spec.rb +40 -0
- data/spec/logstash/util/time_value_spec.rb +1 -1
- data/spec/logstash/util/wrapped_acked_queue_spec.rb +1 -1
- data/spec/support/matchers.rb +25 -19
- data/spec/support/shared_contexts.rb +3 -3
- data/versions-gem-copy.yml +6 -6
- metadata +73 -88
@@ -22,6 +22,8 @@ describe LogStash::Runner do
|
|
22
22
|
before :each do
|
23
23
|
clear_data_dir
|
24
24
|
|
25
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
26
|
+
|
25
27
|
allow(LogStash::Runner).to receive(:logger).and_return(logger)
|
26
28
|
allow(logger).to receive(:debug?).and_return(true)
|
27
29
|
allow(logger).to receive(:subscribe).with(any_args)
|
@@ -27,7 +27,7 @@ describe LogStash::Setting::ArrayCoercible do
|
|
27
27
|
|
28
28
|
describe "initialization" do
|
29
29
|
subject { described_class }
|
30
|
-
let(:element_class) {
|
30
|
+
let(:element_class) { Integer }
|
31
31
|
context "when given values of incorrect element class" do
|
32
32
|
let(:value) { "test" }
|
33
33
|
|
@@ -35,8 +35,8 @@ describe LogStash::Setting::Bytes do
|
|
35
35
|
|
36
36
|
before { subject.set(text) }
|
37
37
|
|
38
|
-
it "should coerce it to
|
39
|
-
expect(subject.value).to be_a(
|
38
|
+
it "should coerce it to an Integer" do
|
39
|
+
expect(subject.value).to be_a(::Integer)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -18,17 +18,17 @@ describe LogStash::StateResolver do
|
|
18
18
|
|
19
19
|
after do
|
20
20
|
# ensure that the the created pipeline are closed
|
21
|
-
running_pipelines.each { |_, pipeline| pipeline.close }
|
21
|
+
pipelines.running_pipelines.each { |_, pipeline| pipeline.close }
|
22
22
|
end
|
23
23
|
|
24
24
|
context "when no pipeline is running" do
|
25
|
-
let(:
|
25
|
+
let(:pipelines) { LogStash::PipelinesRegistry.new }
|
26
26
|
|
27
27
|
context "no pipeline configs is received" do
|
28
28
|
let(:pipeline_configs) { [] }
|
29
29
|
|
30
30
|
it "returns no action" do
|
31
|
-
expect(subject.resolve(
|
31
|
+
expect(subject.resolve(pipelines, pipeline_configs).size).to eq(0)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -36,7 +36,7 @@ describe LogStash::StateResolver do
|
|
36
36
|
let(:pipeline_configs) { [mock_pipeline_config(:hello_world)] }
|
37
37
|
|
38
38
|
it "returns some actions" do
|
39
|
-
expect(subject.resolve(
|
39
|
+
expect(subject.resolve(pipelines, pipeline_configs)).to have_actions(
|
40
40
|
[:create, :hello_world],
|
41
41
|
)
|
42
42
|
end
|
@@ -47,13 +47,17 @@ describe LogStash::StateResolver do
|
|
47
47
|
context "when a pipeline is running" do
|
48
48
|
let(:main_pipeline) { mock_pipeline(:main) }
|
49
49
|
let(:main_pipeline_config) { main_pipeline.pipeline_config }
|
50
|
-
let(:
|
50
|
+
let(:pipelines) do
|
51
|
+
r = LogStash::PipelinesRegistry.new
|
52
|
+
r.create_pipeline(:main, main_pipeline) { true }
|
53
|
+
r
|
54
|
+
end
|
51
55
|
|
52
56
|
context "when the pipeline config contains a new one and the existing" do
|
53
57
|
let(:pipeline_configs) { [mock_pipeline_config(:hello_world), main_pipeline_config ] }
|
54
58
|
|
55
59
|
it "creates the new one and keep the other one" do
|
56
|
-
expect(subject.resolve(
|
60
|
+
expect(subject.resolve(pipelines, pipeline_configs)).to have_actions(
|
57
61
|
[:create, :hello_world],
|
58
62
|
)
|
59
63
|
end
|
@@ -62,7 +66,7 @@ describe LogStash::StateResolver do
|
|
62
66
|
let(:pipeline_configs) { [mock_pipeline_config(:hello_world)] }
|
63
67
|
|
64
68
|
it "creates the new one and stop the old one one" do
|
65
|
-
expect(subject.resolve(
|
69
|
+
expect(subject.resolve(pipelines, pipeline_configs)).to have_actions(
|
66
70
|
[:create, :hello_world],
|
67
71
|
[:stop, :main]
|
68
72
|
)
|
@@ -73,7 +77,7 @@ describe LogStash::StateResolver do
|
|
73
77
|
let(:pipeline_configs) { [] }
|
74
78
|
|
75
79
|
it "stops the old one one" do
|
76
|
-
expect(subject.resolve(
|
80
|
+
expect(subject.resolve(pipelines, pipeline_configs)).to have_actions(
|
77
81
|
[:stop, :main]
|
78
82
|
)
|
79
83
|
end
|
@@ -83,7 +87,7 @@ describe LogStash::StateResolver do
|
|
83
87
|
let(:pipeline_configs) { [mock_pipeline_config(:main, "input { generator {}}")] }
|
84
88
|
|
85
89
|
it "reloads the old one one" do
|
86
|
-
expect(subject.resolve(
|
90
|
+
expect(subject.resolve(pipelines, pipeline_configs)).to have_actions(
|
87
91
|
[:reload, :main]
|
88
92
|
)
|
89
93
|
end
|
@@ -92,21 +96,21 @@ describe LogStash::StateResolver do
|
|
92
96
|
end
|
93
97
|
|
94
98
|
context "when we have a lot of pipeline running" do
|
95
|
-
let(:
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
99
|
+
let(:pipelines) do
|
100
|
+
r = LogStash::PipelinesRegistry.new
|
101
|
+
r.create_pipeline(:main1, mock_pipeline(:main1)) { true }
|
102
|
+
r.create_pipeline(:main2, mock_pipeline(:main2)) { true }
|
103
|
+
r.create_pipeline(:main3, mock_pipeline(:main3)) { true }
|
104
|
+
r.create_pipeline(:main4, mock_pipeline(:main4)) { true }
|
105
|
+
r.create_pipeline(:main5, mock_pipeline(:main5)) { true }
|
106
|
+
r.create_pipeline(:main6, mock_pipeline(:main6)) { true }
|
107
|
+
r
|
104
108
|
end
|
105
109
|
|
106
110
|
context "without system pipeline" do
|
107
111
|
let(:pipeline_configs) do
|
108
112
|
[
|
109
|
-
|
113
|
+
pipelines.get_pipeline(:main1).pipeline_config,
|
110
114
|
mock_pipeline_config(:main9),
|
111
115
|
mock_pipeline_config(:main5, "input { generator {}}"),
|
112
116
|
mock_pipeline_config(:main3, "input { generator {}}"),
|
@@ -115,7 +119,7 @@ describe LogStash::StateResolver do
|
|
115
119
|
end
|
116
120
|
|
117
121
|
it "generates actions required to converge" do
|
118
|
-
expect(subject.resolve(
|
122
|
+
expect(subject.resolve(pipelines, pipeline_configs)).to have_actions(
|
119
123
|
[:create, :main7],
|
120
124
|
[:create, :main9],
|
121
125
|
[:reload, :main3],
|
@@ -130,7 +134,7 @@ describe LogStash::StateResolver do
|
|
130
134
|
context "with system pipeline" do
|
131
135
|
let(:pipeline_configs) do
|
132
136
|
[
|
133
|
-
|
137
|
+
pipelines.get_pipeline(:main1).pipeline_config,
|
134
138
|
mock_pipeline_config(:main9),
|
135
139
|
mock_pipeline_config(:main5, "input { generator {}}"),
|
136
140
|
mock_pipeline_config(:main3, "input { generator {}}"),
|
@@ -140,7 +144,7 @@ describe LogStash::StateResolver do
|
|
140
144
|
end
|
141
145
|
|
142
146
|
it "creates the system pipeline before user defined pipelines" do
|
143
|
-
expect(subject.resolve(
|
147
|
+
expect(subject.resolve(pipelines, pipeline_configs)).to have_actions(
|
144
148
|
[:create, :monitoring],
|
145
149
|
[:create, :main7],
|
146
150
|
[:create, :main9],
|
@@ -32,5 +32,45 @@ module LogStash module Util
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
describe "#initialize" do
|
37
|
+
context 'when host is required' do
|
38
|
+
MALFORMED_URIS = ['http:/user:pass@localhost:9600', 'http:/localhost', 'http:/localhost:9600', 'h;localhost', 'http:://localhost']
|
39
|
+
|
40
|
+
context 'malformed uris via string' do
|
41
|
+
MALFORMED_URIS.each do |arg|
|
42
|
+
it "#{arg}: should raise an error" do
|
43
|
+
expect{LogStash::Util::SafeURI.new(arg)}.to raise_error(ArgumentError)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'malformed uris via java.net.URI' do
|
49
|
+
MALFORMED_URIS.each do |arg|
|
50
|
+
it "#{arg}: should raise an error" do
|
51
|
+
java_uri = java.net.URI.new(arg)
|
52
|
+
expect{LogStash::Util::SafeURI.new(java_uri)}.to raise_error(ArgumentError)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'malformed uris via Ruby URI' do
|
58
|
+
MALFORMED_URIS.each do |arg|
|
59
|
+
it "#{arg}: should raise an error" do
|
60
|
+
ruby_uri = URI.parse(arg)
|
61
|
+
expect{LogStash::Util::SafeURI.new(ruby_uri)}.to raise_error(ArgumentError)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'uris with a valid host' do
|
67
|
+
['http://user:pass@notlocalhost:9600', 'http://notlocalhost', 'https://notlocalhost:9600', '//notlocalhost', 'notlocalhost', 'notlocalhost:9200'].each do |arg|
|
68
|
+
it "#{arg}: should resolve host correctly" do
|
69
|
+
expect(LogStash::Util::SafeURI.new(arg).host).to eq('notlocalhost')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
35
75
|
end
|
36
76
|
end end
|
@@ -51,7 +51,7 @@ describe TimeValue do
|
|
51
51
|
a = TimeValue.from_value(32)
|
52
52
|
fail "should not parse"
|
53
53
|
rescue ArgumentError => e
|
54
|
-
expect(e.message).to eq("value is not a string: 32 [
|
54
|
+
expect(e.message).to eq("value is not a string: 32 [Integer]")
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -38,7 +38,7 @@ describe LogStash::WrappedAckedQueue do
|
|
38
38
|
let(:checkpoint_writes) { 1024 }
|
39
39
|
let(:checkpoint_interval) { 0 }
|
40
40
|
let(:path) { Stud::Temporary.directory }
|
41
|
-
let(:queue) { LogStash::WrappedAckedQueue.new(path, page_capacity, max_events, checkpoint_acks, checkpoint_writes, checkpoint_interval, max_bytes) }
|
41
|
+
let(:queue) { LogStash::WrappedAckedQueue.new(path, page_capacity, max_events, checkpoint_acks, checkpoint_writes, checkpoint_interval, false, max_bytes) }
|
42
42
|
|
43
43
|
after do
|
44
44
|
queue.close
|
data/spec/support/matchers.rb
CHANGED
@@ -51,44 +51,50 @@ end
|
|
51
51
|
|
52
52
|
RSpec::Matchers.define :have_pipeline? do |pipeline_config|
|
53
53
|
match do |agent|
|
54
|
-
pipeline =
|
55
|
-
|
54
|
+
pipeline = nil
|
55
|
+
try(30) do
|
56
|
+
pipeline = agent.get_pipeline(pipeline_config.pipeline_id)
|
57
|
+
expect(pipeline).to_not be_nil
|
58
|
+
end
|
56
59
|
expect(pipeline.config_str).to eq(pipeline_config.config_string)
|
60
|
+
expect(agent.running_pipelines.keys.map(&:to_s)).to include(pipeline_config.pipeline_id.to_s)
|
57
61
|
end
|
58
62
|
|
59
63
|
match_when_negated do |agent|
|
60
|
-
pipeline =
|
61
|
-
|
64
|
+
pipeline = nil
|
65
|
+
try(30) do
|
66
|
+
pipeline = agent.get_pipeline(pipeline_config.pipeline_id)
|
67
|
+
expect(pipeline).to_not be_nil
|
68
|
+
end
|
69
|
+
# either the pipeline_id is not in the running pipelines OR it is but have different configurations
|
70
|
+
expect(!agent.running_pipelines.keys.map(&:to_s).include?(pipeline_config.pipeline_id.to_s) || pipeline.config_str != pipeline_config.config_string).to be_truthy
|
62
71
|
end
|
63
72
|
end
|
64
73
|
|
65
74
|
RSpec::Matchers.define :have_running_pipeline? do |pipeline_config|
|
66
75
|
match do |agent|
|
67
|
-
|
76
|
+
pipeline = nil
|
77
|
+
try(30) do
|
68
78
|
pipeline = agent.get_pipeline(pipeline_config.pipeline_id)
|
69
79
|
expect(pipeline).to_not be_nil
|
70
|
-
expect(pipeline.config_str).to eq(pipeline_config.config_string)
|
71
|
-
expect(pipeline.running?).to be_truthy
|
72
80
|
end
|
81
|
+
expect(pipeline.config_str).to eq(pipeline_config.config_string)
|
82
|
+
expect(pipeline.running?).to be_truthy
|
83
|
+
expect(agent.running_pipelines.keys.map(&:to_s)).to include(pipeline_config.pipeline_id.to_s)
|
73
84
|
end
|
74
85
|
|
75
86
|
failure_message do |agent|
|
76
87
|
pipeline = agent.get_pipeline(pipeline_config.pipeline_id)
|
77
88
|
|
78
89
|
if pipeline.nil?
|
79
|
-
"Expected pipeline to exist and running, be we cannot find
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
Expected:
|
86
|
-
#{pipeline_config.config_string}
|
87
|
-
|
88
|
-
got:
|
89
|
-
#{pipeline.config_str}"
|
90
|
-
end
|
90
|
+
"Expected pipeline to exist and running, be we cannot find '#{pipeline_config.pipeline_id.to_s}' in the running pipelines '#{agent.running_pipelines.keys.join(",")}'"
|
91
|
+
else
|
92
|
+
if !pipeline.running?
|
93
|
+
"Found '#{pipeline_config.pipeline_id.to_s}' in the list of pipelines but its not running"
|
94
|
+
elsif pipeline.config_str != pipeline_config.config_string
|
95
|
+
"Found '#{pipeline_config.pipeline_id.to_s}' in the list of pipelines and running, but the config_string doesn't match,\nExpected:\n#{pipeline_config.config_string}\n\ngot:\n#{pipeline.config_str}"
|
91
96
|
end
|
97
|
+
end
|
92
98
|
end
|
93
99
|
|
94
100
|
match_when_negated do
|
@@ -26,12 +26,12 @@ shared_context "api setup" do
|
|
26
26
|
@agent.execute
|
27
27
|
pipeline_config = mock_pipeline_config(:main, "input { generator { id => '123' } } output { null {} }")
|
28
28
|
pipeline_creator = LogStash::PipelineAction::Create.new(pipeline_config, @agent.metric)
|
29
|
-
@
|
30
|
-
expect(pipeline_creator.execute(@agent, @
|
29
|
+
@pipelines_registry = LogStash::PipelinesRegistry.new
|
30
|
+
expect(pipeline_creator.execute(@agent, @pipelines_registry)).to be_truthy
|
31
31
|
end
|
32
32
|
|
33
33
|
after :all do
|
34
|
-
@
|
34
|
+
@pipelines_registry.running_pipelines.each do |_, pipeline|
|
35
35
|
pipeline.shutdown
|
36
36
|
pipeline.thread.join
|
37
37
|
end
|
data/versions-gem-copy.yml
CHANGED
@@ -7,21 +7,21 @@ logstash-core-plugin-api: 2.1.16
|
|
7
7
|
# jruby must reference a *released* version of jruby which can be downloaded from the official download url
|
8
8
|
# *and* for which jars artifacts are published for compile-time
|
9
9
|
jruby:
|
10
|
-
version: 9.
|
11
|
-
sha1:
|
10
|
+
version: 9.2.5.0
|
11
|
+
sha1: c78526ce98b1b4273d11989246cb9bf224ce9712
|
12
12
|
|
13
13
|
# jruby-runtime-override, if specified, will override the jruby version installed in vendor/jruby for logstash runtime only,
|
14
14
|
# not for the compile-time jars
|
15
15
|
#
|
16
16
|
#jruby-runtime-override:
|
17
|
-
# url: http://ci.jruby.org/snapshots/previous/jruby-bin-9.
|
18
|
-
# version: 9.
|
17
|
+
# url: http://ci.jruby.org/snapshots/previous/jruby-bin-9.2.0.0-SNAPSHOT.tar.gz
|
18
|
+
# version: 9.2.0.0-SNAPSHOT
|
19
19
|
# sha1: IGNORE
|
20
20
|
|
21
21
|
# Note: this file is copied to the root of logstash-core because its gemspec needs it when
|
22
22
|
# bundler evaluates the gemspec via bin/logstash
|
23
23
|
# Ensure Jackson version here is kept in sync with version used by jrjackson gem
|
24
|
-
jrjackson: 0.4.
|
25
|
-
jackson: 2.9.
|
24
|
+
jrjackson: 0.4.7
|
25
|
+
jackson: 2.9.8
|
26
26
|
|
27
27
|
# This is a copy the project level versions.yml into this gem's root and it is created when the gemspec is evaluated.
|