logstash-core 6.8.23-java → 7.0.0.alpha1-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.
- checksums.yaml +4 -4
- data/lib/logstash/agent.rb +69 -85
- data/lib/logstash/api/modules/stats.rb +1 -1
- data/lib/logstash/compiler/lscl.rb +7 -7
- data/lib/logstash/config/config_ast.rb +1 -1
- data/lib/logstash/config/mixin.rb +1 -1
- data/lib/logstash/config/modules_common.rb +3 -3
- data/lib/logstash/dependency_report.rb +1 -2
- data/lib/logstash/environment.rb +4 -9
- data/lib/logstash/event.rb +1 -24
- data/lib/logstash/filter_delegator.rb +69 -2
- data/lib/logstash/filters/base.rb +2 -0
- data/lib/logstash/instrument/metric_store.rb +1 -1
- data/lib/logstash/instrument/periodic_poller/dlq.rb +7 -5
- data/lib/logstash/instrument/periodic_poller/jvm.rb +3 -3
- data/lib/logstash/instrument/periodic_poller/pq.rb +8 -6
- data/lib/logstash/instrument/periodic_pollers.rb +3 -3
- data/lib/logstash/java_pipeline.rb +11 -38
- data/lib/logstash/modules/kibana_config.rb +1 -1
- data/lib/logstash/modules/logstash_config.rb +1 -1
- data/lib/logstash/patches/resolv.rb +32 -17
- data/lib/logstash/pipeline.rb +11 -28
- data/lib/logstash/pipeline_action/base.rb +1 -1
- data/lib/logstash/pipeline_action/create.rb +13 -7
- data/lib/logstash/pipeline_action/reload.rb +12 -35
- data/lib/logstash/pipeline_action/stop.rb +6 -4
- data/lib/logstash/pipeline_settings.rb +1 -2
- data/lib/logstash/plugins/registry.rb +2 -5
- data/lib/logstash/runner.rb +0 -24
- 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 +0 -1
- data/lib/logstash/util/substitution_variables.rb +1 -22
- data/lib/logstash/util/thread_dump.rb +1 -1
- data/lib/logstash/util.rb +1 -11
- data/lib/logstash-core/version.rb +3 -1
- data/locales/en.yml +7 -16
- data/logstash-core.gemspec +11 -2
- data/spec/logstash/acked_queue_concurrent_stress_spec.rb +2 -2
- data/spec/logstash/agent/converge_spec.rb +31 -25
- data/spec/logstash/agent/metrics_spec.rb +1 -1
- data/spec/logstash/agent_spec.rb +7 -6
- data/spec/logstash/compiler/compiler_spec.rb +0 -28
- data/spec/logstash/config/config_ast_spec.rb +0 -15
- data/spec/logstash/config/mixin_spec.rb +2 -3
- data/spec/logstash/converge_result_spec.rb +1 -1
- data/spec/logstash/environment_spec.rb +4 -4
- data/spec/logstash/event_spec.rb +2 -10
- data/spec/logstash/filter_delegator_spec.rb +12 -2
- data/spec/logstash/filters/base_spec.rb +9 -45
- data/spec/logstash/instrument/periodic_poller/cgroup_spec.rb +2 -0
- data/spec/logstash/instrument/wrapped_write_client_spec.rb +1 -1
- data/spec/logstash/java_filter_delegator_spec.rb +11 -1
- data/spec/logstash/legacy_ruby_event_spec.rb +5 -6
- data/spec/logstash/patches_spec.rb +3 -1
- data/spec/logstash/pipeline_action/create_spec.rb +8 -14
- data/spec/logstash/pipeline_action/reload_spec.rb +9 -16
- data/spec/logstash/pipeline_action/stop_spec.rb +3 -4
- data/spec/logstash/queue_factory_spec.rb +1 -2
- data/spec/logstash/runner_spec.rb +0 -2
- 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/settings_spec.rb +0 -10
- data/spec/logstash/state_resolver_spec.rb +22 -26
- data/spec/logstash/util/safe_uri_spec.rb +0 -40
- data/spec/logstash/util/secretstore_spec.rb +1 -1
- data/spec/logstash/util/time_value_spec.rb +1 -1
- data/spec/logstash/util/wrapped_acked_queue_spec.rb +1 -1
- data/spec/logstash/webserver_spec.rb +5 -9
- data/spec/support/matchers.rb +19 -25
- data/spec/support/shared_contexts.rb +3 -3
- data/versions-gem-copy.yml +9 -9
- metadata +31 -44
- data/lib/logstash/patches/resolv_9270.rb +0 -2903
- data/lib/logstash/pipelines_registry.rb +0 -166
- data/lib/logstash/util/lazy_singleton.rb +0 -33
- data/spec/logstash/jruby_version_spec.rb +0 -15
- data/spec/logstash/pipelines_registry_spec.rb +0 -220
@@ -280,41 +280,6 @@ describe LogStash::Filters::NOOP do
|
|
280
280
|
end
|
281
281
|
end
|
282
282
|
|
283
|
-
describe "remove_field within @metadata" do
|
284
|
-
config <<-CONFIG
|
285
|
-
filter {
|
286
|
-
noop {
|
287
|
-
remove_field => ["[@metadata][f1]", "[@metadata][f2]", "[@metadata][f4][f5]"]
|
288
|
-
}
|
289
|
-
}
|
290
|
-
CONFIG
|
291
|
-
|
292
|
-
sample_one("type" => "noop", "@metadata" => {"f1" => "one", "f2" => { "f3" => "three"}, "f4" => { "f5" => "five", "f6" => "six"}, "f7" => "seven"}) do
|
293
|
-
expect(subject.include?("[@metadata][f1]")).to be_falsey
|
294
|
-
expect(subject.include?("[@metadata][f2]")).to be_falsey
|
295
|
-
expect(subject.include?("[@metadata][f4]")).to be_truthy
|
296
|
-
expect(subject.include?("[@metadata][f4][f5]")).to be_falsey
|
297
|
-
expect(subject.include?("[@metadata][f4][f6]")).to be_truthy
|
298
|
-
expect(subject.include?("[@metadata][f7]")).to be_truthy
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
describe "remove_field on @metadata" do
|
303
|
-
config <<-CONFIG
|
304
|
-
filter {
|
305
|
-
noop {
|
306
|
-
remove_field => ["[@metadata]"]
|
307
|
-
}
|
308
|
-
}
|
309
|
-
CONFIG
|
310
|
-
|
311
|
-
sample_one("type" => "noop", "@metadata" => {"f1" => "one", "f2" => { "f3" => "three"}}) do
|
312
|
-
expect(subject.include?("[@metadata]")).to be_truthy
|
313
|
-
expect(subject.include?("[@metadata][f1]")).to be_falsey
|
314
|
-
expect(subject.include?("[@metadata][f2]")).to be_falsey
|
315
|
-
end
|
316
|
-
end
|
317
|
-
|
318
283
|
describe "remove_field on array" do
|
319
284
|
config <<-CONFIG
|
320
285
|
filter {
|
@@ -345,17 +310,16 @@ describe LogStash::Filters::NOOP do
|
|
345
310
|
end
|
346
311
|
end
|
347
312
|
|
348
|
-
describe "when
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
CONFIG
|
313
|
+
describe "when neither add_tag nor remove_tag is specified, the tags field is left untouched" do
|
314
|
+
config <<-CONFIG
|
315
|
+
filter {
|
316
|
+
noop {}
|
317
|
+
}
|
318
|
+
CONFIG
|
355
319
|
|
356
|
-
|
357
|
-
|
358
|
-
end
|
320
|
+
sample_one("type" => "noop", "go" => "away", "tags" => {"blackhole" => "go"}) do
|
321
|
+
expect(subject.get("[tags][blackhole]")).to eq("go")
|
359
322
|
end
|
323
|
+
|
360
324
|
end
|
361
325
|
end
|
@@ -110,7 +110,7 @@ describe LogStash::WrappedWriteClient do
|
|
110
110
|
|
111
111
|
context "WrappedAckedQueue" do
|
112
112
|
let(:path) { Stud::Temporary.directory }
|
113
|
-
let(:queue) { LogStash::WrappedAckedQueue.new(path, 1024, 10, 1024, 1024, 1024,
|
113
|
+
let(:queue) { LogStash::WrappedAckedQueue.new(path, 1024, 10, 1024, 1024, 1024, 4096) }
|
114
114
|
|
115
115
|
before do
|
116
116
|
read_client.set_events_metric(metric.namespace([:stats, :events]))
|
@@ -6,7 +6,7 @@ require "support/shared_contexts"
|
|
6
6
|
|
7
7
|
java_import org.logstash.RubyUtil
|
8
8
|
|
9
|
-
describe LogStash::
|
9
|
+
describe LogStash::JavaFilterDelegator do
|
10
10
|
|
11
11
|
class MockGauge
|
12
12
|
def increment(_)
|
@@ -182,4 +182,14 @@ describe LogStash::FilterDelegator do
|
|
182
182
|
end
|
183
183
|
end
|
184
184
|
|
185
|
+
context "delegate methods to the original plugin" do
|
186
|
+
# I am not testing the behavior of these methods
|
187
|
+
# this is done in the plugin tests. I just want to make sure
|
188
|
+
# the proxy delegates the methods.
|
189
|
+
LogStash::FilterDelegator::DELEGATED_METHODS.each do |method|
|
190
|
+
it "delegate method: `#{method}` to the filter" do
|
191
|
+
expect(subject.respond_to?(method))
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
185
195
|
end
|
@@ -82,7 +82,7 @@ describe LogStash::Event do
|
|
82
82
|
expect(event.get("reference_test")).not_to eq(data)
|
83
83
|
end
|
84
84
|
|
85
|
-
it "should not return
|
85
|
+
it "should not return a Fixnum reference" do
|
86
86
|
data = 1
|
87
87
|
event = LogStash::Event.new({ "reference" => data })
|
88
88
|
LogStash::Util::Decorators.add_fields({"reference_test" => "%{reference}"}, event, "dummy-plugin")
|
@@ -98,12 +98,11 @@ describe LogStash::Event do
|
|
98
98
|
expect(subject.sprintf("bonjour")).to eq("bonjour")
|
99
99
|
end
|
100
100
|
|
101
|
-
it "should
|
101
|
+
it "should raise error when formatting %{+%s} when @timestamp field is missing" do
|
102
102
|
str = "hello-%{+%s}"
|
103
103
|
subj = subject.clone
|
104
104
|
subj.remove("[@timestamp]")
|
105
|
-
expect{ subj.sprintf(str) }.
|
106
|
-
expect(subj.sprintf(str)).to eq("hello-")
|
105
|
+
expect{ subj.sprintf(str) }.to raise_error(LogStash::Error)
|
107
106
|
end
|
108
107
|
|
109
108
|
it "should report a time with %{+format} syntax", :if => RUBY_ENGINE == "jruby" do
|
@@ -116,11 +115,11 @@ describe LogStash::Event do
|
|
116
115
|
expect(subject.sprintf("foo %{+YYYY-MM-dd} %{type}")).to eq("foo 2013-01-01 sprintf")
|
117
116
|
end
|
118
117
|
|
119
|
-
it "should
|
118
|
+
it "should raise error with %{+format} syntax when @timestamp field is missing", :if => RUBY_ENGINE == "jruby" do
|
120
119
|
str = "logstash-%{+YYYY}"
|
121
120
|
subj = subject.clone
|
122
121
|
subj.remove("[@timestamp]")
|
123
|
-
expect{ subj.sprintf(str) }.
|
122
|
+
expect{ subj.sprintf(str) }.to raise_error(LogStash::Error)
|
124
123
|
end
|
125
124
|
|
126
125
|
it "should report fields with %{field} syntax" do
|
@@ -36,7 +36,9 @@ describe "OpenSSL defaults" do
|
|
36
36
|
# https://github.com/jordansissel/ruby-flores/blob/master/spec/flores/pki_integration_spec.rb
|
37
37
|
# since these helpers were created to fix this particular issue
|
38
38
|
let(:csr) { Flores::PKI::CertificateSigningRequest.new }
|
39
|
-
|
39
|
+
# Here, I use a 1024-bit key for faster tests.
|
40
|
+
# Please do not use such small keys in production.
|
41
|
+
let(:key_bits) { 1024 }
|
40
42
|
let(:key) { OpenSSL::PKey::RSA.generate(key_bits, 65537) }
|
41
43
|
let(:certificate_duration) { Flores::Random.number(1..86400) }
|
42
44
|
|
@@ -2,14 +2,13 @@
|
|
2
2
|
require "spec_helper"
|
3
3
|
require_relative "../../support/helpers"
|
4
4
|
require_relative "../../support/matchers"
|
5
|
-
require "logstash/pipelines_registry"
|
6
5
|
require "logstash/pipeline_action/create"
|
7
6
|
require "logstash/inputs/generator"
|
8
7
|
|
9
8
|
describe LogStash::PipelineAction::Create do
|
10
9
|
let(:metric) { LogStash::Instrument::NullMetric.new(LogStash::Instrument::Collector.new) }
|
11
|
-
let(:pipeline_config) { mock_pipeline_config(:main, "input {
|
12
|
-
let(:pipelines) {
|
10
|
+
let(:pipeline_config) { mock_pipeline_config(:main, "input { generator { id => '123' } } output { null {} }") }
|
11
|
+
let(:pipelines) { java.util.concurrent.ConcurrentHashMap.new }
|
13
12
|
let(:agent) { double("agent") }
|
14
13
|
|
15
14
|
before do
|
@@ -19,7 +18,7 @@ describe LogStash::PipelineAction::Create do
|
|
19
18
|
subject { described_class.new(pipeline_config, metric) }
|
20
19
|
|
21
20
|
after do
|
22
|
-
pipelines.
|
21
|
+
pipelines.each do |_, pipeline|
|
23
22
|
pipeline.shutdown
|
24
23
|
pipeline.thread.join
|
25
24
|
end
|
@@ -34,32 +33,28 @@ describe LogStash::PipelineAction::Create do
|
|
34
33
|
let(:pipeline_config) { mock_pipeline_config(:main, "input { generator { count => 1 } } output { null {} }") }
|
35
34
|
|
36
35
|
it "returns a successful execution status" do
|
37
|
-
allow(agent).to receive(:exclusive) { |&arg| arg.call }
|
38
36
|
expect(subject.execute(agent, pipelines)).to be_truthy
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
42
40
|
context "when the pipeline successfully start" do
|
43
41
|
it "adds the pipeline to the current pipelines" do
|
44
|
-
allow(agent).to receive(:exclusive) { |&arg| arg.call }
|
45
42
|
expect { subject.execute(agent, pipelines) }.to change(pipelines, :size).by(1)
|
46
43
|
end
|
47
44
|
|
48
45
|
it "starts the pipeline" do
|
49
|
-
allow(agent).to receive(:exclusive) { |&arg| arg.call }
|
50
46
|
subject.execute(agent, pipelines)
|
51
|
-
expect(pipelines
|
47
|
+
expect(pipelines[:main].running?).to be_truthy
|
52
48
|
end
|
53
49
|
|
54
50
|
it "returns a successful execution status" do
|
55
|
-
allow(agent).to receive(:exclusive) { |&arg| arg.call }
|
56
51
|
expect(subject.execute(agent, pipelines)).to be_truthy
|
57
52
|
end
|
58
53
|
end
|
59
54
|
|
60
55
|
context "when the pipeline doesn't start" do
|
61
56
|
context "with a syntax error" do
|
62
|
-
let(:pipeline_config) { mock_pipeline_config(:main, "input {
|
57
|
+
let(:pipeline_config) { mock_pipeline_config(:main, "input { generator { id => '123' } } output { stdout ") } # bad syntax
|
63
58
|
|
64
59
|
it "raises the exception upstream" do
|
65
60
|
expect { subject.execute(agent, pipelines) }.to raise_error
|
@@ -67,18 +62,17 @@ describe LogStash::PipelineAction::Create do
|
|
67
62
|
end
|
68
63
|
|
69
64
|
context "with an error raised during `#register`" do
|
70
|
-
let(:pipeline_config) { mock_pipeline_config(:main, "input {
|
65
|
+
let(:pipeline_config) { mock_pipeline_config(:main, "input { generator { id => '123' } } filter { ruby { init => '1/0' code => '1+2' } } output { null {} }") }
|
71
66
|
|
72
67
|
it "returns false" do
|
73
|
-
allow(agent).to receive(:exclusive) { |&arg| arg.call }
|
74
68
|
expect(subject.execute(agent, pipelines)).not_to be_a_successful_action
|
75
69
|
end
|
76
70
|
end
|
77
71
|
end
|
78
72
|
|
79
73
|
context "when sorting create action" do
|
80
|
-
let(:pipeline_config) { mock_pipeline_config(:main, "input {
|
81
|
-
let(:system_pipeline_config) { mock_pipeline_config(:main_2, "input {
|
74
|
+
let(:pipeline_config) { mock_pipeline_config(:main, "input { generator { id => '123' } } output { null {} }") }
|
75
|
+
let(:system_pipeline_config) { mock_pipeline_config(:main_2, "input { generator { id => '123' } } output { null {} }", { "pipeline.system" => true }) }
|
82
76
|
|
83
77
|
it "should give higher priority to system pipeline" do
|
84
78
|
action_user_pipeline = described_class.new(pipeline_config, metric)
|
@@ -2,16 +2,15 @@
|
|
2
2
|
require "spec_helper"
|
3
3
|
require_relative "../../support/helpers"
|
4
4
|
require_relative "../../support/matchers"
|
5
|
-
require "logstash/pipelines_registry"
|
6
5
|
require "logstash/pipeline_action/reload"
|
7
6
|
|
8
7
|
describe LogStash::PipelineAction::Reload do
|
9
8
|
let(:metric) { LogStash::Instrument::NullMetric.new(LogStash::Instrument::Collector.new) }
|
10
9
|
let(:pipeline_id) { :main }
|
11
|
-
let(:new_pipeline_config) { mock_pipeline_config(pipeline_id, "input {
|
12
|
-
let(:pipeline_config) { "input {
|
10
|
+
let(:new_pipeline_config) { mock_pipeline_config(pipeline_id, "input { generator { id => 'new' } } output { null {} }", { "pipeline.reloadable" => true}) }
|
11
|
+
let(:pipeline_config) { "input { generator {} } output { null {} }" }
|
13
12
|
let(:pipeline) { mock_pipeline_from_string(pipeline_config, mock_settings("pipeline.reloadable" => true)) }
|
14
|
-
let(:pipelines) {
|
13
|
+
let(:pipelines) { chm = java.util.concurrent.ConcurrentHashMap.new; chm[pipeline_id] = pipeline; chm }
|
15
14
|
let(:agent) { double("agent") }
|
16
15
|
|
17
16
|
subject { described_class.new(new_pipeline_config, metric) }
|
@@ -22,7 +21,7 @@ describe LogStash::PipelineAction::Reload do
|
|
22
21
|
end
|
23
22
|
|
24
23
|
after do
|
25
|
-
pipelines.
|
24
|
+
pipelines.each do |_, pipeline|
|
26
25
|
pipeline.shutdown
|
27
26
|
pipeline.thread.join
|
28
27
|
end
|
@@ -34,20 +33,17 @@ describe LogStash::PipelineAction::Reload do
|
|
34
33
|
|
35
34
|
context "when existing pipeline and new pipeline are both reloadable" do
|
36
35
|
it "stop the previous pipeline" do
|
37
|
-
allow(agent).to receive(:exclusive) { |&arg| arg.call }
|
38
36
|
expect { subject.execute(agent, pipelines) }.to change(pipeline, :running?).from(true).to(false)
|
39
37
|
end
|
40
38
|
|
41
39
|
it "start the new pipeline" do
|
42
|
-
allow(agent).to receive(:exclusive) { |&arg| arg.call }
|
43
40
|
subject.execute(agent, pipelines)
|
44
|
-
expect(pipelines
|
41
|
+
expect(pipelines[pipeline_id].running?).to be_truthy
|
45
42
|
end
|
46
43
|
|
47
44
|
it "run the new pipeline code" do
|
48
|
-
allow(agent).to receive(:exclusive) { |&arg| arg.call }
|
49
45
|
subject.execute(agent, pipelines)
|
50
|
-
expect(pipelines
|
46
|
+
expect(pipelines[pipeline_id].config_hash).to eq(new_pipeline_config.config_hash)
|
51
47
|
end
|
52
48
|
end
|
53
49
|
|
@@ -62,30 +58,27 @@ describe LogStash::PipelineAction::Reload do
|
|
62
58
|
end
|
63
59
|
|
64
60
|
context "when the new pipeline is not reloadable" do
|
65
|
-
let(:new_pipeline_config) { mock_pipeline_config(pipeline_id, "input {
|
61
|
+
let(:new_pipeline_config) { mock_pipeline_config(pipeline_id, "input { generator { id => 'new' } } output { null {} }", { "pipeline.reloadable" => false}) }
|
66
62
|
|
67
63
|
it "cannot successfully execute the action" do
|
68
|
-
allow(agent).to receive(:exclusive) { |&arg| arg.call }
|
69
64
|
expect(subject.execute(agent, pipelines)).not_to be_a_successful_action
|
70
65
|
end
|
71
66
|
end
|
72
67
|
|
73
68
|
context "when the new pipeline has syntax errors" do
|
74
|
-
let(:new_pipeline_config) { mock_pipeline_config(pipeline_id, "input
|
69
|
+
let(:new_pipeline_config) { mock_pipeline_config(pipeline_id, "input generator { id => 'new' } } output { null {} }", { "pipeline.reloadable" => false}) }
|
75
70
|
|
76
71
|
it "cannot successfully execute the action" do
|
77
|
-
allow(agent).to receive(:exclusive) { |&arg| arg.call }
|
78
72
|
expect(subject.execute(agent, pipelines)).not_to be_a_successful_action
|
79
73
|
end
|
80
74
|
end
|
81
75
|
|
82
76
|
context "when there is an error in the register" do
|
83
77
|
before do
|
84
|
-
allow_any_instance_of(LogStash::Inputs::
|
78
|
+
allow_any_instance_of(LogStash::Inputs::Generator).to receive(:register).and_raise("Bad value")
|
85
79
|
end
|
86
80
|
|
87
81
|
it "cannot successfully execute the action" do
|
88
|
-
allow(agent).to receive(:exclusive) { |&arg| arg.call }
|
89
82
|
expect(subject.execute(agent, pipelines)).not_to be_a_successful_action
|
90
83
|
end
|
91
84
|
end
|
@@ -1,15 +1,14 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "spec_helper"
|
3
3
|
require_relative "../../support/helpers"
|
4
|
-
require "logstash/pipelines_registry"
|
5
4
|
require "logstash/pipeline_action/stop"
|
6
5
|
require "logstash/pipeline"
|
7
6
|
|
8
7
|
describe LogStash::PipelineAction::Stop do
|
9
|
-
let(:pipeline_config) { "input {
|
8
|
+
let(:pipeline_config) { "input { generator {} } output { null {} }" }
|
10
9
|
let(:pipeline_id) { :main }
|
11
10
|
let(:pipeline) { mock_pipeline_from_string(pipeline_config) }
|
12
|
-
let(:pipelines) { chm =
|
11
|
+
let(:pipelines) { chm = java.util.concurrent.ConcurrentHashMap.new; chm[:main] = pipeline; chm }
|
13
12
|
let(:agent) { double("agent") }
|
14
13
|
|
15
14
|
subject { described_class.new(pipeline_id) }
|
@@ -32,6 +31,6 @@ describe LogStash::PipelineAction::Stop do
|
|
32
31
|
end
|
33
32
|
|
34
33
|
it "removes the pipeline from the running pipelines" do
|
35
|
-
expect { subject.execute(agent, pipelines) }.to change { pipelines.
|
34
|
+
expect { subject.execute(agent, pipelines) }.to change { pipelines.include?(pipeline_id) }.from(true).to(false)
|
36
35
|
end
|
37
36
|
end
|
@@ -14,7 +14,6 @@ describe LogStash::QueueFactory do
|
|
14
14
|
LogStash::Setting::Numeric.new("queue.checkpoint.acks", 1024),
|
15
15
|
LogStash::Setting::Numeric.new("queue.checkpoint.writes", 1024),
|
16
16
|
LogStash::Setting::Numeric.new("queue.checkpoint.interval", 1000),
|
17
|
-
LogStash::Setting::Boolean.new("queue.checkpoint.retry", false),
|
18
17
|
LogStash::Setting::String.new("pipeline.id", pipeline_id),
|
19
18
|
LogStash::Setting::PositiveInteger.new("pipeline.batch.size", 125),
|
20
19
|
LogStash::Setting::PositiveInteger.new("pipeline.workers", LogStash::Config::CpuCoreStrategy.maximum)
|
@@ -47,7 +46,7 @@ describe LogStash::QueueFactory do
|
|
47
46
|
let(:queue_path) { ::File.join(settings.get("path.queue"), pipeline_id) }
|
48
47
|
|
49
48
|
after :each do
|
50
|
-
FileUtils.
|
49
|
+
FileUtils.rmdir(queue_path)
|
51
50
|
end
|
52
51
|
|
53
52
|
it "creates a queue directory based on the pipeline id" do
|
@@ -22,8 +22,6 @@ 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
|
-
|
27
25
|
allow(LogStash::Runner).to receive(:logger).and_return(logger)
|
28
26
|
allow(logger).to receive(:debug?).and_return(true)
|
29
27
|
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) { Fixnum }
|
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 a Fixnum" do
|
39
|
+
expect(subject.value).to be_a(Fixnum)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -158,11 +158,6 @@ describe LogStash::Settings do
|
|
158
158
|
|
159
159
|
before :each do
|
160
160
|
LogStash::SETTINGS.set("keystore.file", File.join(File.dirname(__FILE__), "../../src/test/resources/logstash.keystore.with.default.pass"))
|
161
|
-
LogStash::Util::SubstitutionVariables.send(:reset_secret_store)
|
162
|
-
end
|
163
|
-
|
164
|
-
after(:each) do
|
165
|
-
LogStash::Util::SubstitutionVariables.send(:reset_secret_store)
|
166
161
|
end
|
167
162
|
|
168
163
|
context "placeholders in flat logstash.yml" do
|
@@ -216,7 +211,6 @@ describe LogStash::Settings do
|
|
216
211
|
|
217
212
|
before :each do
|
218
213
|
LogStash::SETTINGS.set("keystore.file", File.join(File.dirname(__FILE__), "../../src/test/resources/logstash.keystore.with.default.pass"))
|
219
|
-
LogStash::Util::SubstitutionVariables.send(:reset_secret_store)
|
220
214
|
end
|
221
215
|
|
222
216
|
before do
|
@@ -231,10 +225,6 @@ describe LogStash::Settings do
|
|
231
225
|
ENV.delete('a')
|
232
226
|
end
|
233
227
|
|
234
|
-
after(:each) do
|
235
|
-
LogStash::Util::SubstitutionVariables.send(:reset_secret_store)
|
236
|
-
end
|
237
|
-
|
238
228
|
subject do
|
239
229
|
settings = described_class.new
|
240
230
|
settings.register(LogStash::Setting::ArrayCoercible.new("host", String, []))
|
@@ -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
|
-
|
21
|
+
running_pipelines.each { |_, pipeline| pipeline.close }
|
22
22
|
end
|
23
23
|
|
24
24
|
context "when no pipeline is running" do
|
25
|
-
let(:
|
25
|
+
let(:running_pipelines) { {} }
|
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(running_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(running_pipelines, pipeline_configs)).to have_actions(
|
40
40
|
[:create, :hello_world],
|
41
41
|
)
|
42
42
|
end
|
@@ -47,17 +47,13 @@ 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(:
|
51
|
-
r = LogStash::PipelinesRegistry.new
|
52
|
-
r.create_pipeline(:main, main_pipeline) { true }
|
53
|
-
r
|
54
|
-
end
|
50
|
+
let(:running_pipelines) { { :main => main_pipeline } }
|
55
51
|
|
56
52
|
context "when the pipeline config contains a new one and the existing" do
|
57
53
|
let(:pipeline_configs) { [mock_pipeline_config(:hello_world), main_pipeline_config ] }
|
58
54
|
|
59
55
|
it "creates the new one and keep the other one" do
|
60
|
-
expect(subject.resolve(
|
56
|
+
expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
|
61
57
|
[:create, :hello_world],
|
62
58
|
)
|
63
59
|
end
|
@@ -66,7 +62,7 @@ describe LogStash::StateResolver do
|
|
66
62
|
let(:pipeline_configs) { [mock_pipeline_config(:hello_world)] }
|
67
63
|
|
68
64
|
it "creates the new one and stop the old one one" do
|
69
|
-
expect(subject.resolve(
|
65
|
+
expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
|
70
66
|
[:create, :hello_world],
|
71
67
|
[:stop, :main]
|
72
68
|
)
|
@@ -77,7 +73,7 @@ describe LogStash::StateResolver do
|
|
77
73
|
let(:pipeline_configs) { [] }
|
78
74
|
|
79
75
|
it "stops the old one one" do
|
80
|
-
expect(subject.resolve(
|
76
|
+
expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
|
81
77
|
[:stop, :main]
|
82
78
|
)
|
83
79
|
end
|
@@ -87,7 +83,7 @@ describe LogStash::StateResolver do
|
|
87
83
|
let(:pipeline_configs) { [mock_pipeline_config(:main, "input { generator {}}")] }
|
88
84
|
|
89
85
|
it "reloads the old one one" do
|
90
|
-
expect(subject.resolve(
|
86
|
+
expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
|
91
87
|
[:reload, :main]
|
92
88
|
)
|
93
89
|
end
|
@@ -96,21 +92,21 @@ describe LogStash::StateResolver do
|
|
96
92
|
end
|
97
93
|
|
98
94
|
context "when we have a lot of pipeline running" do
|
99
|
-
let(:
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
95
|
+
let(:running_pipelines) do
|
96
|
+
{
|
97
|
+
:main1 => mock_pipeline(:main1),
|
98
|
+
:main2 => mock_pipeline(:main2),
|
99
|
+
:main3 => mock_pipeline(:main3),
|
100
|
+
:main4 => mock_pipeline(:main4),
|
101
|
+
:main5 => mock_pipeline(:main5),
|
102
|
+
:main6 => mock_pipeline(:main6),
|
103
|
+
}
|
108
104
|
end
|
109
105
|
|
110
106
|
context "without system pipeline" do
|
111
107
|
let(:pipeline_configs) do
|
112
108
|
[
|
113
|
-
|
109
|
+
running_pipelines[:main1].pipeline_config,
|
114
110
|
mock_pipeline_config(:main9),
|
115
111
|
mock_pipeline_config(:main5, "input { generator {}}"),
|
116
112
|
mock_pipeline_config(:main3, "input { generator {}}"),
|
@@ -119,7 +115,7 @@ describe LogStash::StateResolver do
|
|
119
115
|
end
|
120
116
|
|
121
117
|
it "generates actions required to converge" do
|
122
|
-
expect(subject.resolve(
|
118
|
+
expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
|
123
119
|
[:create, :main7],
|
124
120
|
[:create, :main9],
|
125
121
|
[:reload, :main3],
|
@@ -134,7 +130,7 @@ describe LogStash::StateResolver do
|
|
134
130
|
context "with system pipeline" do
|
135
131
|
let(:pipeline_configs) do
|
136
132
|
[
|
137
|
-
|
133
|
+
running_pipelines[:main1].pipeline_config,
|
138
134
|
mock_pipeline_config(:main9),
|
139
135
|
mock_pipeline_config(:main5, "input { generator {}}"),
|
140
136
|
mock_pipeline_config(:main3, "input { generator {}}"),
|
@@ -144,7 +140,7 @@ describe LogStash::StateResolver do
|
|
144
140
|
end
|
145
141
|
|
146
142
|
it "creates the system pipeline before user defined pipelines" do
|
147
|
-
expect(subject.resolve(
|
143
|
+
expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
|
148
144
|
[:create, :monitoring],
|
149
145
|
[:create, :main7],
|
150
146
|
[:create, :main9],
|
@@ -32,45 +32,5 @@ 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
|
75
35
|
end
|
76
36
|
end end
|
@@ -12,7 +12,7 @@ describe SecretStoreExt do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should be not exist" do
|
15
|
-
expect(subject.exists(LogStash::SETTINGS.get_setting("keystore.file").value, LogStash::SETTINGS.get_setting("keystore.classname").value)).to
|
15
|
+
expect(subject.exists(LogStash::SETTINGS.get_setting("keystore.file").value, LogStash::SETTINGS.get_setting("keystore.classname").value)).to be_falsey
|
16
16
|
expect(subject.getIfExists(LogStash::SETTINGS.get_setting("keystore.file").value, LogStash::SETTINGS.get_setting("keystore.classname").value)).to be_nil
|
17
17
|
end
|
18
18
|
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 [Fixnum]")
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|