logstash-core 6.0.0.alpha1-java → 6.0.0.alpha2-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-core/logstash-core.jar +0 -0
- data/lib/logstash-core/version.rb +1 -1
- data/lib/logstash/agent.rb +81 -45
- data/lib/logstash/api/commands/hot_threads_reporter.rb +3 -3
- data/lib/logstash/api/commands/node.rb +13 -6
- data/lib/logstash/api/commands/stats.rb +18 -6
- data/lib/logstash/api/modules/node.rb +7 -0
- data/lib/logstash/api/modules/node_stats.rb +12 -5
- data/lib/logstash/bootstrap_check/default_config.rb +3 -7
- data/lib/logstash/compiler.rb +33 -15
- data/lib/logstash/compiler/lscl.rb +16 -8
- data/lib/logstash/config/mixin.rb +5 -42
- data/lib/logstash/config/pipeline_config.rb +1 -1
- data/lib/logstash/config/source/local.rb +28 -13
- data/lib/logstash/config/source/multi_local.rb +72 -0
- data/lib/logstash/config/source_loader.rb +1 -2
- data/lib/logstash/environment.rb +12 -3
- data/lib/logstash/execution_context.rb +7 -3
- data/lib/logstash/inputs/base.rb +2 -0
- data/lib/logstash/instrument/metric_type.rb +0 -2
- data/lib/logstash/instrument/periodic_poller/jvm.rb +5 -5
- data/lib/logstash/instrument/periodic_poller/pq.rb +1 -1
- data/lib/logstash/outputs/base.rb +2 -0
- data/lib/logstash/pipeline.rb +31 -14
- data/lib/logstash/pipeline_action/create.rb +1 -2
- data/lib/logstash/pipeline_action/reload.rb +2 -1
- data/lib/logstash/pipeline_settings.rb +50 -0
- data/lib/logstash/plugin.rb +1 -0
- data/lib/logstash/runner.rb +7 -5
- data/lib/logstash/settings.rb +11 -3
- data/lib/logstash/shutdown_watcher.rb +26 -0
- data/lib/logstash/state_resolver.rb +1 -3
- data/lib/logstash/util/dead_letter_queue_manager.rb +61 -0
- data/lib/logstash/util/environment_variables.rb +43 -0
- data/lib/logstash/util/thread_dump.rb +3 -1
- data/lib/logstash/version.rb +1 -1
- data/locales/en.yml +4 -0
- data/logstash-core.gemspec +4 -1
- data/spec/logstash/agent/converge_spec.rb +36 -35
- data/spec/logstash/agent_spec.rb +48 -177
- data/spec/{api/lib/commands/stats.rb → logstash/api/commands/stats_spec.rb} +7 -2
- data/spec/{api/lib → logstash/api}/errors_spec.rb +1 -1
- data/spec/{api/lib/api → logstash/api/modules}/logging_spec.rb +1 -10
- data/spec/{api/lib/api → logstash/api/modules}/node_plugins_spec.rb +1 -2
- data/spec/{api/lib/api → logstash/api/modules}/node_spec.rb +9 -8
- data/spec/{api/lib/api → logstash/api/modules}/node_stats_spec.rb +11 -9
- data/spec/{api/lib/api → logstash/api/modules}/plugins_spec.rb +4 -3
- data/spec/{api/lib/api → logstash/api/modules}/root_spec.rb +2 -2
- data/spec/{api/lib → logstash/api}/rack_app_spec.rb +0 -0
- data/spec/logstash/compiler/compiler_spec.rb +72 -9
- data/spec/logstash/config/source/local_spec.rb +20 -4
- data/spec/logstash/config/source/multi_local_spec.rb +113 -0
- data/spec/logstash/execution_context_spec.rb +14 -4
- data/spec/logstash/inputs/base_spec.rb +1 -1
- data/spec/logstash/instrument/wrapped_write_client_spec.rb +34 -19
- data/spec/logstash/output_delegator_spec.rb +1 -1
- data/spec/logstash/outputs/base_spec.rb +1 -1
- data/spec/logstash/pipeline_action/reload_spec.rb +1 -1
- data/spec/logstash/pipeline_action/stop_spec.rb +1 -1
- data/spec/logstash/pipeline_dlq_commit_spec.rb +107 -0
- data/spec/logstash/pipeline_pq_file_spec.rb +3 -1
- data/spec/logstash/pipeline_reporter_spec.rb +2 -1
- data/spec/logstash/pipeline_spec.rb +54 -43
- data/spec/logstash/runner_spec.rb +27 -36
- data/spec/logstash/settings/array_coercible_spec.rb +65 -0
- data/spec/logstash/settings_spec.rb +91 -0
- data/spec/logstash/shutdown_watcher_spec.rb +10 -16
- data/spec/logstash/state_resolver_spec.rb +6 -4
- data/spec/support/helpers.rb +16 -3
- data/spec/support/shared_contexts.rb +26 -2
- metadata +42 -39
- data/lib/logstash/instrument/metric_type/mean.rb +0 -33
- data/spec/api/lib/api/support/resource_dsl_methods.rb +0 -87
- data/spec/api/spec_helper.rb +0 -106
@@ -1,10 +1,15 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe LogStash::Api::Commands::Stats do
|
5
|
+
include_context "api setup"
|
5
6
|
|
6
7
|
let(:report_method) { :run }
|
7
|
-
subject(:report)
|
8
|
+
subject(:report) do
|
9
|
+
factory = ::LogStash::Api::CommandFactory.new(LogStash::Api::Service.new(@agent))
|
10
|
+
|
11
|
+
factory.build(:stats).send(report_method)
|
12
|
+
end
|
8
13
|
|
9
14
|
let(:report_class) { described_class }
|
10
15
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
2
|
+
require "spec_helper"
|
3
3
|
require "sinatra"
|
4
4
|
require "logstash/api/modules/logging"
|
5
5
|
require "logstash/json"
|
@@ -10,15 +10,6 @@ describe LogStash::Api::Modules::Logging do
|
|
10
10
|
describe "#logging" do
|
11
11
|
|
12
12
|
context "when setting a logger's log level" do
|
13
|
-
before(:all) do
|
14
|
-
@runner = LogStashRunner.new
|
15
|
-
@runner.start
|
16
|
-
end
|
17
|
-
|
18
|
-
after(:all) do
|
19
|
-
@runner.stop
|
20
|
-
end
|
21
|
-
|
22
13
|
it "should return a positive acknowledgement on success" do
|
23
14
|
put '/', '{"logger.logstash": "ERROR"}'
|
24
15
|
payload = LogStash::Json.load(last_response.body)
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
require_relative "../../../support/shared_examples"
|
2
|
+
require "spec_helper"
|
4
3
|
require "sinatra"
|
5
4
|
require "logstash/api/modules/node"
|
6
5
|
require "logstash/json"
|
@@ -110,12 +109,14 @@ describe LogStash::Api::Modules::Node do
|
|
110
109
|
extend ResourceDSLMethods
|
111
110
|
|
112
111
|
root_structure = {
|
113
|
-
"
|
114
|
-
"
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
112
|
+
"pipelines" => {
|
113
|
+
"main" => {
|
114
|
+
"workers" => Numeric,
|
115
|
+
"batch_size" => Numeric,
|
116
|
+
"batch_delay" => Numeric,
|
117
|
+
"config_reload_automatic" => Boolean,
|
118
|
+
"config_reload_interval" => Numeric
|
119
|
+
}
|
119
120
|
},
|
120
121
|
"os" => {
|
121
122
|
"name" => String,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
4
|
require "sinatra"
|
5
5
|
require "logstash/api/modules/node_stats"
|
6
6
|
require "logstash/json"
|
@@ -73,13 +73,15 @@ describe LogStash::Api::Modules::NodeStats do
|
|
73
73
|
"load_average" => { "1m" => Numeric }
|
74
74
|
}
|
75
75
|
},
|
76
|
-
"
|
77
|
-
"
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
76
|
+
"pipelines" => {
|
77
|
+
"main" => {
|
78
|
+
"events" => {
|
79
|
+
"duration_in_millis" => Numeric,
|
80
|
+
"in" => Numeric,
|
81
|
+
"filtered" => Numeric,
|
82
|
+
"out" => Numeric,
|
83
|
+
"queue_push_duration_in_millis" => Numeric
|
84
|
+
}
|
83
85
|
}
|
84
86
|
},
|
85
87
|
"reloads" => {
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
require_relative "../../../support/shared_examples"
|
2
|
+
require "spec_helper"
|
4
3
|
require "sinatra"
|
5
4
|
require "logstash/api/modules/plugins"
|
6
5
|
require "logstash/json"
|
@@ -40,7 +39,9 @@ describe LogStash::Api::Modules::Plugins do
|
|
40
39
|
|
41
40
|
it "return a list of available plugins" do
|
42
41
|
payload["plugins"].each do |plugin|
|
43
|
-
expect
|
42
|
+
expect do
|
43
|
+
Gem::Specification.find_by_name(plugin["name"])
|
44
|
+
end.not_to raise_error
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
File without changes
|
@@ -8,15 +8,65 @@ describe LogStash::Compiler do
|
|
8
8
|
Java::OrgLogstashConfigIr::DSL
|
9
9
|
end
|
10
10
|
|
11
|
+
let(:source_protocol) { "test_proto" }
|
12
|
+
|
11
13
|
# Static import of these useful enums
|
12
14
|
INPUT = Java::OrgLogstashConfigIr::PluginDefinition::Type::INPUT
|
13
15
|
FILTER = Java::OrgLogstashConfigIr::PluginDefinition::Type::FILTER
|
14
16
|
OUTPUT = Java::OrgLogstashConfigIr::PluginDefinition::Type::OUTPUT
|
15
17
|
CODEC = Java::OrgLogstashConfigIr::PluginDefinition::Type::OUTPUT
|
16
18
|
|
19
|
+
shared_examples_for("component source_with_metadata") do
|
20
|
+
it "should set the correct protocol" do
|
21
|
+
expect(component.source_with_metadata.protocol).to eq(source_protocol)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should set the id to the source id" do
|
25
|
+
expect(component.source_with_metadata.id).to eq(source_id)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
17
29
|
describe "compiling to Pipeline" do
|
18
|
-
subject(:
|
19
|
-
|
30
|
+
subject(:source_id) { "fake_sourcefile" }
|
31
|
+
let(:source_with_metadata) { org.logstash.common.SourceWithMetadata.new(source_protocol, source_id, source) }
|
32
|
+
subject(:compiled) { described_class.compile_pipeline(source_with_metadata) }
|
33
|
+
|
34
|
+
describe "compiling multiple sources" do
|
35
|
+
let(:sources) do
|
36
|
+
[
|
37
|
+
"input { input_0 {} } filter { filter_0 {} } output { output_0 {} }",
|
38
|
+
"input { input_1 {} } filter { filter_1 {} } output { output_1 {} }"
|
39
|
+
]
|
40
|
+
end
|
41
|
+
let(:sources_with_metadata) do
|
42
|
+
sources.map.with_index do |source, idx|
|
43
|
+
org.logstash.common.SourceWithMetadata.new("#{source_protocol}_#{idx}", "#{source_id}_#{idx}", source)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
subject(:pipeline) { described_class.compile_sources(*sources_with_metadata) }
|
48
|
+
|
49
|
+
it "should compile cleanly" do
|
50
|
+
expect(pipeline).to be_a(org.logstash.config.ir.PipelineIR)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should provide the original source" do
|
54
|
+
expect(pipeline.original_source).to eq(sources.join("\n"))
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "applying protocol and id metadata" do
|
58
|
+
it "should apply the correct source metadata to all components" do
|
59
|
+
pipeline.plugin_vertices.each do |pv|
|
60
|
+
name_idx = pv.plugin_definition.name.split("_").last
|
61
|
+
source_protocol_idx = pv.source_with_metadata.protocol.split("_").last
|
62
|
+
source_id_idx = pv.source_with_metadata.id.split("_").last
|
63
|
+
|
64
|
+
expect(name_idx).to eq(source_protocol_idx)
|
65
|
+
expect(name_idx).to eq(source_id_idx)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
20
70
|
|
21
71
|
describe "complex configs" do
|
22
72
|
shared_examples_for "compilable LSCL files" do |path|
|
@@ -40,8 +90,9 @@ describe LogStash::Compiler do
|
|
40
90
|
end
|
41
91
|
|
42
92
|
describe "compiling imperative" do
|
43
|
-
let(:
|
44
|
-
|
93
|
+
let(:source_id) { "fake_sourcefile" }
|
94
|
+
let(:source_with_metadata) { org.logstash.common.SourceWithMetadata.new(source_protocol, source_id, source) }
|
95
|
+
subject(:compiled) { described_class.compile_imperative(source_with_metadata) }
|
45
96
|
|
46
97
|
describe "an empty file" do
|
47
98
|
let(:source) { "input {} output {}" }
|
@@ -63,7 +114,7 @@ describe LogStash::Compiler do
|
|
63
114
|
let(:source) { "input { generator {} } output { }" }
|
64
115
|
|
65
116
|
it "should attach correct source text for components" do
|
66
|
-
expect(compiled[:input].
|
117
|
+
expect(compiled[:input].source_with_metadata.getText).to eql("generator {}")
|
67
118
|
end
|
68
119
|
end
|
69
120
|
|
@@ -106,6 +157,10 @@ describe LogStash::Compiler do
|
|
106
157
|
it "should contain the single input" do
|
107
158
|
expect(input).to ir_eql(j.iPlugin(INPUT, "generator"))
|
108
159
|
end
|
160
|
+
|
161
|
+
it_should_behave_like("component source_with_metadata") do
|
162
|
+
let(:component) { input }
|
163
|
+
end
|
109
164
|
end
|
110
165
|
|
111
166
|
describe "two inputs" do
|
@@ -190,12 +245,12 @@ describe LogStash::Compiler do
|
|
190
245
|
end
|
191
246
|
|
192
247
|
it "should attach source_with_metadata with correct info to the statements" do
|
193
|
-
meta = compiled_section.statements.first.
|
248
|
+
meta = compiled_section.statements.first.source_with_metadata
|
194
249
|
expect(meta.text).to eql("aplugin { count => 1 }")
|
195
250
|
expect(meta.line).to eql(2)
|
196
251
|
expect(meta.column).to eql(13)
|
197
|
-
expect(meta.id).to eql(
|
198
|
-
expect(compiled_section.statements.first.
|
252
|
+
expect(meta.id).to eql(source_id)
|
253
|
+
expect(compiled_section.statements.first.source_with_metadata)
|
199
254
|
expect(compiled_section)
|
200
255
|
end
|
201
256
|
end
|
@@ -559,9 +614,13 @@ describe LogStash::Compiler do
|
|
559
614
|
describe "a single filter" do
|
560
615
|
let(:source) { "input { } filter { grok {} } output { }" }
|
561
616
|
|
562
|
-
it "should contain the single
|
617
|
+
it "should contain the single filter" do
|
563
618
|
expect(filter).to ir_eql(j.iPlugin(FILTER, "grok"))
|
564
619
|
end
|
620
|
+
|
621
|
+
it_should_behave_like("component source_with_metadata") do
|
622
|
+
let(:component) { filter }
|
623
|
+
end
|
565
624
|
end
|
566
625
|
|
567
626
|
it_should_behave_like "complex grammar", :filter
|
@@ -576,6 +635,10 @@ describe LogStash::Compiler do
|
|
576
635
|
it "should contain the single input" do
|
577
636
|
expect(output).to ir_eql(j.iPlugin(OUTPUT, "stdout"))
|
578
637
|
end
|
638
|
+
|
639
|
+
it_should_behave_like("component source_with_metadata") do
|
640
|
+
let(:component) { output }
|
641
|
+
end
|
579
642
|
end
|
580
643
|
|
581
644
|
it_should_behave_like "complex grammar", :output
|
@@ -292,8 +292,9 @@ describe LogStash::Config::Source::Local do
|
|
292
292
|
)
|
293
293
|
end
|
294
294
|
|
295
|
-
|
296
|
-
|
295
|
+
# this should be impossible as the bootstrap checks should catch this
|
296
|
+
it "raises an exception" do
|
297
|
+
expect { subject.pipeline_configs }.to raise_error
|
297
298
|
end
|
298
299
|
end
|
299
300
|
|
@@ -353,13 +354,28 @@ describe LogStash::Config::Source::Local do
|
|
353
354
|
)
|
354
355
|
end
|
355
356
|
|
356
|
-
it "
|
357
|
-
expect
|
357
|
+
it "raises an exception" do
|
358
|
+
expect { subject.pipeline_configs }.to raise_error
|
358
359
|
end
|
359
360
|
end
|
360
361
|
end
|
361
362
|
|
362
363
|
context "incomplete configuration" do
|
364
|
+
context "when using path.config" do
|
365
|
+
let(:config_string) { filter_block }
|
366
|
+
let(:config_path) do
|
367
|
+
file = Stud::Temporary.file
|
368
|
+
path = file.path
|
369
|
+
file.write(config_string)
|
370
|
+
path
|
371
|
+
end
|
372
|
+
let(:settings) { mock_settings( "path.config" => config_path) }
|
373
|
+
|
374
|
+
it "doesn't add anything" do
|
375
|
+
expect(subject.pipeline_configs.first.config_string).not_to include(LogStash::Config::Defaults.output, LogStash::Config::Defaults.input)
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
363
379
|
context "when the input block is missing" do
|
364
380
|
let(:settings) { mock_settings( "config.string" => "#{filter_block} #{output_block}") }
|
365
381
|
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/config/source/multi_local"
|
3
|
+
require "rspec/expectations"
|
4
|
+
require "stud/temporary"
|
5
|
+
require "fileutils"
|
6
|
+
require "pathname"
|
7
|
+
require_relative "../../../support/helpers"
|
8
|
+
require_relative "../../../support/matchers"
|
9
|
+
require "spec_helper"
|
10
|
+
require "webmock/rspec"
|
11
|
+
|
12
|
+
describe LogStash::Config::Source::MultiLocal do
|
13
|
+
subject { described_class.new(settings) }
|
14
|
+
let(:settings) { mock_settings({}) }
|
15
|
+
let(:pipelines_yaml_location) { "" }
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
allow(subject).to receive(:pipelines_yaml_location).and_return(pipelines_yaml_location)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#match?" do
|
22
|
+
context "when `config.string` is set" do
|
23
|
+
let(:settings) do
|
24
|
+
mock_settings("config.string" => "")
|
25
|
+
end
|
26
|
+
it "returns false" do
|
27
|
+
expect(subject.match?).to be_falsey
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "when `config.path` are set`" do
|
32
|
+
let(:config_file) { temporary_file("") }
|
33
|
+
|
34
|
+
let(:settings) do
|
35
|
+
mock_settings("path.config" => config_file)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns false" do
|
39
|
+
expect(subject.match?).to be_falsey
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "when both `config.string` and `path.config` are set" do
|
44
|
+
let(:settings) do
|
45
|
+
mock_settings("config.string" => "", "path.config" => temporary_file(""))
|
46
|
+
end
|
47
|
+
it "returns false" do
|
48
|
+
expect(subject.match?).to be_falsey
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when neither `config.path` nor `path.config` are set`" do
|
53
|
+
it "returns true" do
|
54
|
+
expect(subject.match?).to be_truthy
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
describe "#detect_duplicate_pipelines" do
|
59
|
+
let(:retrieved_pipelines) { [{}] }
|
60
|
+
let(:retrieved_pipelines_configs) { retrieved_pipelines.map {|h| mock_settings(h) } }
|
61
|
+
context "when there are duplicate pipeline ids" do
|
62
|
+
let(:retrieved_pipelines) do
|
63
|
+
[
|
64
|
+
{"pipeline.id" => "main", "config.string" => ""},
|
65
|
+
{"pipeline.id" => "main", "config.string" => ""},
|
66
|
+
]
|
67
|
+
end
|
68
|
+
it "should raise a ConfigurationError" do
|
69
|
+
expect { subject.detect_duplicate_pipelines(retrieved_pipelines_configs) }.to raise_error(::LogStash::ConfigurationError)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
context "when there are no duplicate pipeline ids" do
|
73
|
+
let(:retrieved_pipelines) do
|
74
|
+
[
|
75
|
+
{"pipeline.id" => "main", "config.string" => ""},
|
76
|
+
{"pipeline.id" => "backup", "config.string" => ""},
|
77
|
+
]
|
78
|
+
end
|
79
|
+
it "should not raise an error" do
|
80
|
+
expect { subject.detect_duplicate_pipelines(retrieved_pipelines_configs) }.to_not raise_error
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "#pipeline_configs" do
|
86
|
+
let(:retrieved_pipelines) do
|
87
|
+
[
|
88
|
+
{ "pipeline.id" => "main", "config.string" => "" },
|
89
|
+
{ "pipeline.id" => "backup", "config.string" => "" }
|
90
|
+
]
|
91
|
+
end
|
92
|
+
before(:each) do
|
93
|
+
allow(subject).to receive(:retrieve_yaml_pipelines).and_return(retrieved_pipelines)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should return instances of PipelineConfig" do
|
97
|
+
configs = subject.pipeline_configs
|
98
|
+
expect(configs).to be_a(Array)
|
99
|
+
expect(subject.pipeline_configs.first).to be_a(::LogStash::Config::PipelineConfig)
|
100
|
+
expect(subject.pipeline_configs.last).to be_a(::LogStash::Config::PipelineConfig)
|
101
|
+
end
|
102
|
+
|
103
|
+
context "using non pipeline related settings" do
|
104
|
+
let(:retrieved_pipelines) do [
|
105
|
+
{ "pipeline.id" => "main", "config.string" => "", "http.port" => 22222 },
|
106
|
+
]
|
107
|
+
end
|
108
|
+
it "should raise and error" do
|
109
|
+
expect { subject.pipeline_configs }.to raise_error(ArgumentError)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|