logstash-core 6.0.0.alpha2-java → 6.0.0.beta1-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 +5 -5
- data/gemspec_jars.rb +6 -4
- data/lib/logstash-core/logstash-core.jar +0 -0
- data/lib/logstash-core/logstash-core.rb +2 -2
- data/lib/logstash-core/version.rb +1 -1
- data/lib/logstash-core_jars.rb +14 -10
- data/lib/logstash/agent.rb +4 -2
- data/lib/logstash/api/commands/default_metadata.rb +1 -1
- data/lib/logstash/api/commands/hot_threads_reporter.rb +8 -2
- data/lib/logstash/api/commands/node.rb +2 -2
- data/lib/logstash/api/commands/stats.rb +2 -2
- data/lib/logstash/bootstrap_check/bad_ruby.rb +2 -2
- data/lib/logstash/bootstrap_check/default_config.rb +2 -3
- data/lib/logstash/compiler.rb +12 -12
- data/lib/logstash/compiler/lscl.rb +17 -7
- data/lib/logstash/compiler/treetop_monkeypatches.rb +1 -0
- data/lib/logstash/config/config_ast.rb +11 -1
- data/lib/logstash/config/mixin.rb +5 -0
- data/lib/logstash/config/modules_common.rb +101 -0
- data/lib/logstash/config/source/base.rb +75 -0
- data/lib/logstash/config/source/local.rb +52 -50
- data/lib/logstash/config/source/modules.rb +55 -0
- data/lib/logstash/config/source/multi_local.rb +54 -10
- data/lib/logstash/config/source_loader.rb +1 -0
- data/lib/logstash/config/string_escape.rb +27 -0
- data/lib/logstash/elasticsearch_client.rb +142 -0
- data/lib/logstash/environment.rb +5 -1
- data/lib/logstash/event.rb +0 -1
- data/lib/logstash/instrument/global_metrics.rb +13 -0
- data/lib/logstash/instrument/metric_store.rb +16 -13
- data/lib/logstash/instrument/metric_type/counter.rb +6 -18
- data/lib/logstash/instrument/metric_type/gauge.rb +6 -12
- data/lib/logstash/instrument/periodic_poller/dlq.rb +19 -0
- data/lib/logstash/instrument/periodic_pollers.rb +3 -1
- data/lib/logstash/logging/logger.rb +43 -14
- data/lib/logstash/modules/cli_parser.rb +74 -0
- data/lib/logstash/modules/elasticsearch_config.rb +22 -0
- data/lib/logstash/modules/elasticsearch_importer.rb +37 -0
- data/lib/logstash/modules/elasticsearch_resource.rb +10 -0
- data/lib/logstash/modules/file_reader.rb +36 -0
- data/lib/logstash/modules/kibana_base.rb +24 -0
- data/lib/logstash/modules/kibana_client.rb +122 -0
- data/lib/logstash/modules/kibana_config.rb +125 -0
- data/lib/logstash/modules/kibana_dashboards.rb +36 -0
- data/lib/logstash/modules/kibana_importer.rb +17 -0
- data/lib/logstash/modules/kibana_resource.rb +10 -0
- data/lib/logstash/modules/kibana_settings.rb +40 -0
- data/lib/logstash/modules/logstash_config.rb +120 -0
- data/lib/logstash/modules/resource_base.rb +38 -0
- data/lib/logstash/modules/scaffold.rb +50 -0
- data/lib/logstash/modules/settings_merger.rb +23 -0
- data/lib/logstash/modules/util.rb +17 -0
- data/lib/logstash/namespace.rb +1 -0
- data/lib/logstash/pipeline.rb +66 -27
- data/lib/logstash/pipeline_settings.rb +1 -0
- data/lib/logstash/plugins/registry.rb +1 -0
- data/lib/logstash/runner.rb +47 -3
- data/lib/logstash/settings.rb +20 -1
- data/lib/logstash/util/dead_letter_queue_manager.rb +1 -1
- data/lib/logstash/util/safe_uri.rb +146 -11
- data/lib/logstash/util/thread_dump.rb +4 -3
- data/lib/logstash/util/wrapped_acked_queue.rb +28 -24
- data/lib/logstash/util/wrapped_synchronous_queue.rb +19 -20
- data/lib/logstash/version.rb +1 -1
- data/locales/en.yml +56 -1
- data/logstash-core.gemspec +6 -4
- data/spec/logstash/agent/converge_spec.rb +2 -2
- data/spec/logstash/agent_spec.rb +11 -3
- data/spec/logstash/api/modules/logging_spec.rb +13 -7
- data/spec/logstash/api/modules/node_plugins_spec.rb +23 -5
- data/spec/logstash/api/modules/node_spec.rb +17 -15
- data/spec/logstash/api/modules/node_stats_spec.rb +0 -1
- data/spec/logstash/api/modules/plugins_spec.rb +40 -9
- data/spec/logstash/api/modules/root_spec.rb +0 -1
- data/spec/logstash/api/rack_app_spec.rb +2 -1
- data/spec/logstash/compiler/compiler_spec.rb +54 -7
- data/spec/logstash/config/config_ast_spec.rb +47 -8
- data/spec/logstash/config/mixin_spec.rb +14 -2
- data/spec/logstash/config/pipeline_config_spec.rb +7 -7
- data/spec/logstash/config/source/local_spec.rb +5 -2
- data/spec/logstash/config/source/multi_local_spec.rb +56 -10
- data/spec/logstash/config/source_loader_spec.rb +1 -1
- data/spec/logstash/config/string_escape_spec.rb +24 -0
- data/spec/logstash/event_spec.rb +9 -0
- data/spec/logstash/filters/base_spec.rb +1 -1
- data/spec/logstash/instrument/metric_store_spec.rb +2 -3
- data/spec/logstash/instrument/metric_type/counter_spec.rb +0 -12
- data/spec/logstash/instrument/metric_type/gauge_spec.rb +1 -8
- data/spec/logstash/instrument/periodic_poller/dlq_spec.rb +17 -0
- data/spec/logstash/instrument/periodic_poller/jvm_spec.rb +1 -1
- data/spec/logstash/legacy_ruby_event_spec.rb +0 -9
- data/spec/logstash/legacy_ruby_timestamp_spec.rb +19 -14
- data/spec/logstash/modules/cli_parser_spec.rb +129 -0
- data/spec/logstash/modules/logstash_config_spec.rb +56 -0
- data/spec/logstash/modules/scaffold_spec.rb +239 -0
- data/spec/logstash/pipeline_dlq_commit_spec.rb +1 -1
- data/spec/logstash/pipeline_spec.rb +87 -20
- data/spec/logstash/runner_spec.rb +122 -5
- data/spec/logstash/setting_spec.rb +2 -2
- data/spec/logstash/settings/splittable_string_array_spec.rb +51 -0
- data/spec/logstash/timestamp_spec.rb +8 -2
- data/spec/logstash/util/safe_uri_spec.rb +16 -0
- data/spec/logstash/util/wrapped_acked_queue_spec.rb +63 -0
- data/spec/logstash/util/wrapped_synchronous_queue_spec.rb +0 -22
- data/spec/support/helpers.rb +1 -1
- data/spec/support/matchers.rb +21 -4
- metadata +102 -19
- data/lib/logstash/instrument/metric_type/base.rb +0 -31
- data/lib/logstash/program.rb +0 -14
- data/lib/logstash/string_interpolation.rb +0 -18
data/logstash-core.gemspec
CHANGED
@@ -24,14 +24,14 @@ Gem::Specification.new do |gem|
|
|
24
24
|
gem.add_runtime_dependency "clamp", "~> 0.6.5" #(MIT license) for command line args/flags
|
25
25
|
gem.add_runtime_dependency "filesize", "0.0.4" #(MIT license) for :bytes config validator
|
26
26
|
gem.add_runtime_dependency "gems", "~> 0.8.3" #(MIT license)
|
27
|
-
gem.add_runtime_dependency "concurrent-ruby", "1.0.0"
|
27
|
+
gem.add_runtime_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.5"
|
28
28
|
|
29
29
|
# Later versions are ruby 2.0 only. We should remove the rack dep once we support 9k
|
30
30
|
gem.add_runtime_dependency "rack", '1.6.6'
|
31
|
-
|
31
|
+
|
32
32
|
gem.add_runtime_dependency "sinatra", '~> 1.4', '>= 1.4.6'
|
33
33
|
gem.add_runtime_dependency 'puma', '~> 2.16'
|
34
|
-
gem.add_runtime_dependency "jruby-openssl", "0.9.
|
34
|
+
gem.add_runtime_dependency "jruby-openssl", "0.9.20" # >= 0.9.13 Required to support TLSv1.2
|
35
35
|
gem.add_runtime_dependency "chronic_duration", "0.10.6"
|
36
36
|
|
37
37
|
# TODO(sissel): Treetop 1.5.x doesn't seem to work well, but I haven't
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |gem|
|
|
43
43
|
|
44
44
|
# filetools and rakelib
|
45
45
|
gem.add_runtime_dependency "minitar", "~> 0.5.4"
|
46
|
-
gem.add_runtime_dependency "rubyzip", "~> 1.1
|
46
|
+
gem.add_runtime_dependency "rubyzip", "~> 1.2.1"
|
47
47
|
gem.add_runtime_dependency "thread_safe", "~> 0.3.5" #(Apache 2.0 license)
|
48
48
|
|
49
49
|
gem.add_runtime_dependency "jrjackson", "~> 0.4.2" #(Apache 2.0 license)
|
@@ -53,6 +53,8 @@ Gem::Specification.new do |gem|
|
|
53
53
|
# has an rdoc problem that causes a bundler exception. 3.3.9 is the current latest version
|
54
54
|
# which does not have this problem.
|
55
55
|
gem.add_runtime_dependency "ruby-maven", "~> 3.3.9"
|
56
|
+
gem.add_runtime_dependency "elasticsearch", "~> 5.0", ">= 5.0.4" # Ruby client for ES (Apache 2.0 license)
|
57
|
+
gem.add_runtime_dependency "manticore", '>= 0.5.4', '< 1.0.0'
|
56
58
|
|
57
59
|
eval(File.read(File.expand_path("../gemspec_jars.rb", __FILE__)))
|
58
60
|
end
|
@@ -131,7 +131,7 @@ describe LogStash::Agent do
|
|
131
131
|
end
|
132
132
|
|
133
133
|
context "is set to `TRUE`" do
|
134
|
-
let(:interval) {
|
134
|
+
let(:interval) { "10ms" }
|
135
135
|
let(:agent_settings) do
|
136
136
|
mock_settings(
|
137
137
|
"config.reload.automatic" => true,
|
@@ -165,7 +165,7 @@ describe LogStash::Agent do
|
|
165
165
|
it "it will keep trying to converge" do
|
166
166
|
agent_task = start_agent(subject)
|
167
167
|
|
168
|
-
sleep(interval * 20) # let the interval reload a few times
|
168
|
+
sleep(agent_settings.get("config.reload.interval") / 1_000_000_000.0 * 20) # let the interval reload a few times
|
169
169
|
expect(subject.pipelines_count).to eq(0)
|
170
170
|
expect(source_loader.fetch_count).to be > 1
|
171
171
|
|
data/spec/logstash/agent_spec.rb
CHANGED
@@ -9,6 +9,8 @@ require "fileutils"
|
|
9
9
|
require_relative "../support/helpers"
|
10
10
|
require_relative "../support/matchers"
|
11
11
|
|
12
|
+
java_import org.logstash.Timestamp
|
13
|
+
|
12
14
|
describe LogStash::Agent do
|
13
15
|
let(:agent_settings) { mock_settings({}) }
|
14
16
|
let(:agent_args) { {} }
|
@@ -81,6 +83,12 @@ describe LogStash::Agent do
|
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
86
|
+
describe "ephemeral_id" do
|
87
|
+
it "create a ephemeral id at creation time" do
|
88
|
+
expect(subject.ephemeral_id).to_not be_nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
84
92
|
describe "#execute" do
|
85
93
|
let(:config_string) { "input { generator { id => 'old'} } output { }" }
|
86
94
|
let(:mock_config_pipeline) { mock_pipeline_config(:main, config_string, pipeline_settings) }
|
@@ -202,7 +210,7 @@ describe LogStash::Agent do
|
|
202
210
|
let(:pipeline_config) { "input { generator { message => '${FOO}-bar' count => 1 } } filter { } output { file { path => '#{temporary_file}' } }" }
|
203
211
|
let(:agent_args) { {
|
204
212
|
"config.reload.automatic" => false,
|
205
|
-
"config.reload.interval" =>
|
213
|
+
"config.reload.interval" => "10ms",
|
206
214
|
"config.string" => pipeline_config
|
207
215
|
} }
|
208
216
|
|
@@ -386,7 +394,7 @@ describe LogStash::Agent do
|
|
386
394
|
it "sets the success reload timestamp" do
|
387
395
|
snapshot = subject.metric.collector.snapshot_metric
|
388
396
|
value = snapshot.metric_store.get_with_path("/stats/pipelines")[:stats][:pipelines][:main][:reloads][:last_success_timestamp].value
|
389
|
-
expect(value).to be_a(
|
397
|
+
expect(value).to be_a(Timestamp)
|
390
398
|
end
|
391
399
|
|
392
400
|
it "does not set the last reload error" do
|
@@ -415,7 +423,7 @@ describe LogStash::Agent do
|
|
415
423
|
it "sets the failure reload timestamp" do
|
416
424
|
snapshot = subject.metric.collector.snapshot_metric
|
417
425
|
value = snapshot.metric_store.get_with_path("/stats/pipelines")[:stats][:pipelines][:main][:reloads][:last_failure_timestamp].value
|
418
|
-
expect(value).to be_a(
|
426
|
+
expect(value).to be_a(Timestamp)
|
419
427
|
end
|
420
428
|
|
421
429
|
it "sets the last reload error" do
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "spec_helper"
|
3
|
+
require "json-schema"
|
3
4
|
require "sinatra"
|
4
5
|
require "logstash/api/modules/logging"
|
5
|
-
require "logstash/json"
|
6
6
|
|
7
7
|
describe LogStash::Api::Modules::Logging do
|
8
8
|
include_context "api setup"
|
@@ -12,20 +12,26 @@ describe LogStash::Api::Modules::Logging do
|
|
12
12
|
context "when setting a logger's log level" do
|
13
13
|
it "should return a positive acknowledgement on success" do
|
14
14
|
put '/', '{"logger.logstash": "ERROR"}'
|
15
|
-
|
16
|
-
|
15
|
+
expect(JSON::Validator.fully_validate(
|
16
|
+
{ "properties" => { "acknowledged" => { "enum" => [true] } } },
|
17
|
+
last_response.body)
|
18
|
+
).to be_empty
|
17
19
|
end
|
18
20
|
|
19
21
|
it "should throw error when level is invalid" do
|
20
22
|
put '/', '{"logger.logstash": "invalid"}'
|
21
|
-
|
22
|
-
|
23
|
+
expect(JSON::Validator.fully_validate(
|
24
|
+
{ "properties" => { "error" => { "enum" => ["invalid level[invalid] for logger[logstash]"] } } },
|
25
|
+
last_response.body)
|
26
|
+
).to be_empty
|
23
27
|
end
|
24
28
|
|
25
29
|
it "should throw error when key logger is invalid" do
|
26
30
|
put '/', '{"invalid" : "ERROR"}'
|
27
|
-
|
28
|
-
|
31
|
+
expect(JSON::Validator.fully_validate(
|
32
|
+
{ "properties" => { "error" => { "enum" => ["unrecognized option [invalid]"] } } },
|
33
|
+
last_response.body)
|
34
|
+
).to be_empty
|
29
35
|
end
|
30
36
|
end
|
31
37
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "spec_helper"
|
3
|
+
require "json-schema"
|
3
4
|
require "sinatra"
|
4
5
|
require "logstash/api/modules/plugins"
|
5
|
-
require "logstash/json"
|
6
6
|
|
7
7
|
describe LogStash::Api::Modules::Plugins do
|
8
8
|
include_context "api setup"
|
@@ -14,19 +14,37 @@ describe LogStash::Api::Modules::Plugins do
|
|
14
14
|
get "/"
|
15
15
|
end
|
16
16
|
|
17
|
-
let(:payload) { LogStash::Json.load(last_response.body) }
|
18
|
-
|
19
17
|
describe "retrieving plugins" do
|
20
18
|
it "should return OK" do
|
21
19
|
expect(last_response).to be_ok
|
22
20
|
end
|
23
21
|
|
24
22
|
it "should return a list of plugins" do
|
25
|
-
expect(
|
23
|
+
expect(JSON::Validator.fully_validate(
|
24
|
+
{
|
25
|
+
"properties" => {
|
26
|
+
"plugins" => {
|
27
|
+
"type" => "array"
|
28
|
+
},
|
29
|
+
"required" => ["plugins"]
|
30
|
+
}
|
31
|
+
},
|
32
|
+
last_response.body)
|
33
|
+
).to be_empty
|
26
34
|
end
|
27
35
|
|
28
36
|
it "should return the total number of plugins" do
|
29
|
-
expect(
|
37
|
+
expect(JSON::Validator.fully_validate(
|
38
|
+
{
|
39
|
+
"properties" => {
|
40
|
+
"total" => {
|
41
|
+
"type" => "number"
|
42
|
+
},
|
43
|
+
"required" => ["total"]
|
44
|
+
}
|
45
|
+
},
|
46
|
+
last_response.body)
|
47
|
+
).to be_empty
|
30
48
|
end
|
31
49
|
end
|
32
50
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "spec_helper"
|
3
|
+
require "json-schema"
|
3
4
|
require "sinatra"
|
4
5
|
require "logstash/api/modules/node"
|
5
|
-
require "logstash/json"
|
6
6
|
|
7
7
|
describe LogStash::Api::Modules::Node do
|
8
8
|
include_context "api setup"
|
@@ -19,7 +19,7 @@ describe LogStash::Api::Modules::Node do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should return a JSON object" do
|
22
|
-
expect
|
22
|
+
expect(JSON::Validator.validate({}, last_response.body)).to eq(true)
|
23
23
|
end
|
24
24
|
|
25
25
|
context "#threads count" do
|
@@ -28,14 +28,21 @@ describe LogStash::Api::Modules::Node do
|
|
28
28
|
get "/hot_threads?threads=5"
|
29
29
|
end
|
30
30
|
|
31
|
-
let(:payload) { LogStash::Json.load(last_response.body) }
|
32
|
-
|
33
31
|
it "should return a json payload content type" do
|
34
32
|
expect(last_response.content_type).to eq("application/json")
|
35
33
|
end
|
36
34
|
|
37
35
|
it "should return information for <= # requested threads" do
|
38
|
-
expect(
|
36
|
+
expect(JSON::Validator.fully_validate(
|
37
|
+
{
|
38
|
+
"properties" => {
|
39
|
+
"hot_threads" => {
|
40
|
+
"properties" => { "threads" => { "type" => "array", "maxItems" => 5 } }
|
41
|
+
}
|
42
|
+
}
|
43
|
+
},
|
44
|
+
last_response.body
|
45
|
+
)).to be_empty
|
39
46
|
end
|
40
47
|
end
|
41
48
|
|
@@ -51,14 +58,12 @@ describe LogStash::Api::Modules::Node do
|
|
51
58
|
get path
|
52
59
|
end
|
53
60
|
|
54
|
-
let(:payload) { last_response.body }
|
55
|
-
|
56
61
|
it "should return a text/plain content type" do
|
57
62
|
expect(last_response.content_type).to eq("text/plain;charset=utf-8")
|
58
63
|
end
|
59
64
|
|
60
65
|
it "should return a plain text payload" do
|
61
|
-
expect{
|
66
|
+
expect {JSON::Validator.fully_validate({}, payload)}.to raise_error
|
62
67
|
end
|
63
68
|
end
|
64
69
|
end
|
@@ -76,10 +81,8 @@ describe LogStash::Api::Modules::Node do
|
|
76
81
|
@threads.each { |t| t.kill } rescue nil
|
77
82
|
end
|
78
83
|
|
79
|
-
let(:payload) { last_response.body }
|
80
|
-
|
81
84
|
it "should return information for <= # requested threads" do
|
82
|
-
expect(
|
85
|
+
expect(last_response.body.scan(/thread name/).size).to eq(2)
|
83
86
|
end
|
84
87
|
end
|
85
88
|
|
@@ -97,10 +100,8 @@ describe LogStash::Api::Modules::Node do
|
|
97
100
|
expect(last_response.content_type).to eq("application/json")
|
98
101
|
end
|
99
102
|
|
100
|
-
let(:payload) { last_response.body }
|
101
|
-
|
102
103
|
it "should return a json payload" do
|
103
|
-
expect
|
104
|
+
expect(JSON::Validator.validate({}, last_response.body)).to eq(true)
|
104
105
|
end
|
105
106
|
end
|
106
107
|
end
|
@@ -115,7 +116,8 @@ describe LogStash::Api::Modules::Node do
|
|
115
116
|
"batch_size" => Numeric,
|
116
117
|
"batch_delay" => Numeric,
|
117
118
|
"config_reload_automatic" => Boolean,
|
118
|
-
"config_reload_interval" => Numeric
|
119
|
+
"config_reload_interval" => Numeric,
|
120
|
+
"dead_letter_queue_enabled" => Boolean
|
119
121
|
}
|
120
122
|
},
|
121
123
|
"os" => {
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "spec_helper"
|
3
|
+
require "json-schema"
|
3
4
|
require "sinatra"
|
4
5
|
require "logstash/api/modules/plugins"
|
5
6
|
require "logstash/json"
|
@@ -12,8 +13,6 @@ describe LogStash::Api::Modules::Plugins do
|
|
12
13
|
get "/"
|
13
14
|
end
|
14
15
|
|
15
|
-
let(:payload) { LogStash::Json.load(last_response.body) }
|
16
|
-
|
17
16
|
it "respond to plugins resource" do
|
18
17
|
expect(last_response).to be_ok
|
19
18
|
end
|
@@ -24,15 +23,31 @@ describe LogStash::Api::Modules::Plugins do
|
|
24
23
|
|
25
24
|
context "#schema" do
|
26
25
|
it "return the expected schema" do
|
27
|
-
expect(
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
expect(JSON::Validator.fully_validate(
|
27
|
+
{
|
28
|
+
"properties" => {
|
29
|
+
"plugins" => {
|
30
|
+
"type" => "array",
|
31
|
+
"items" => [
|
32
|
+
{
|
33
|
+
"type" => "object",
|
34
|
+
"required" => ["version", "name"]
|
35
|
+
}
|
36
|
+
]
|
37
|
+
},
|
38
|
+
"total" => { "type" => "number" }
|
39
|
+
},
|
40
|
+
"required" => ["plugins", "total"]
|
41
|
+
},
|
42
|
+
last_response.body)
|
43
|
+
).to be_empty
|
31
44
|
end
|
32
45
|
end
|
33
46
|
|
34
47
|
context "#values" do
|
35
48
|
|
49
|
+
let(:payload) { LogStash::Json.load(last_response.body) }
|
50
|
+
|
36
51
|
it "return totals of plugins" do
|
37
52
|
expect(payload["total"]).to eq(payload["plugins"].count)
|
38
53
|
end
|
@@ -46,9 +61,25 @@ describe LogStash::Api::Modules::Plugins do
|
|
46
61
|
end
|
47
62
|
|
48
63
|
it "return non empty version values" do
|
49
|
-
|
50
|
-
|
51
|
-
|
64
|
+
expect(JSON::Validator.fully_validate(
|
65
|
+
{ "properties" => { "plugins" => {
|
66
|
+
"type" => "array",
|
67
|
+
"items" => [
|
68
|
+
{
|
69
|
+
"type" => "object",
|
70
|
+
"properties" => {
|
71
|
+
"version" => {
|
72
|
+
"type" => "string",
|
73
|
+
"minLength" => 1
|
74
|
+
}
|
75
|
+
},
|
76
|
+
"required" => ["version"]
|
77
|
+
}
|
78
|
+
],
|
79
|
+
"minItems" => 1
|
80
|
+
} } },
|
81
|
+
last_response.body)
|
82
|
+
).to be_empty
|
52
83
|
end
|
53
84
|
end
|
54
85
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "logstash/api/rack_app"
|
2
|
+
require "json-schema"
|
2
3
|
require "rack/test"
|
3
4
|
|
4
5
|
describe LogStash::Api::RackApp do
|
@@ -55,7 +56,7 @@ describe LogStash::Api::RackApp do
|
|
55
56
|
end
|
56
57
|
|
57
58
|
it "should return valid JSON" do
|
58
|
-
expect
|
59
|
+
expect(JSON::Validator.validate({}, last_response.body)).to eq(true)
|
59
60
|
end
|
60
61
|
|
61
62
|
it "should log the error" do
|
@@ -10,6 +10,8 @@ describe LogStash::Compiler do
|
|
10
10
|
|
11
11
|
let(:source_protocol) { "test_proto" }
|
12
12
|
|
13
|
+
let(:settings) { mock_settings({}) }
|
14
|
+
|
13
15
|
# Static import of these useful enums
|
14
16
|
INPUT = Java::OrgLogstashConfigIr::PluginDefinition::Type::INPUT
|
15
17
|
FILTER = Java::OrgLogstashConfigIr::PluginDefinition::Type::FILTER
|
@@ -28,8 +30,8 @@ describe LogStash::Compiler do
|
|
28
30
|
|
29
31
|
describe "compiling to Pipeline" do
|
30
32
|
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
|
+
let(:source_with_metadata) { org.logstash.common.SourceWithMetadata.new(source_protocol, source_id, 0, 0, source) }
|
34
|
+
subject(:compiled) { puts "PCOMP"; described_class.compile_pipeline(source_with_metadata, settings) }
|
33
35
|
|
34
36
|
describe "compiling multiple sources" do
|
35
37
|
let(:sources) do
|
@@ -38,13 +40,18 @@ describe LogStash::Compiler do
|
|
38
40
|
"input { input_1 {} } filter { filter_1 {} } output { output_1 {} }"
|
39
41
|
]
|
40
42
|
end
|
43
|
+
|
41
44
|
let(:sources_with_metadata) do
|
42
45
|
sources.map.with_index do |source, idx|
|
43
|
-
org.logstash.common.SourceWithMetadata.new("#{source_protocol}_#{idx}", "#{source_id}_#{idx}", source)
|
46
|
+
org.logstash.common.SourceWithMetadata.new("#{source_protocol}_#{idx}", "#{source_id}_#{idx}", 0, 0, source)
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
47
|
-
subject(:pipeline) { described_class.compile_sources(
|
50
|
+
subject(:pipeline) { described_class.compile_sources(sources_with_metadata, settings) }
|
51
|
+
|
52
|
+
it "should generate a hash" do
|
53
|
+
expect(pipeline.unique_hash).to be_a(String)
|
54
|
+
end
|
48
55
|
|
49
56
|
it "should compile cleanly" do
|
50
57
|
expect(pipeline).to be_a(org.logstash.config.ir.PipelineIR)
|
@@ -56,7 +63,8 @@ describe LogStash::Compiler do
|
|
56
63
|
|
57
64
|
describe "applying protocol and id metadata" do
|
58
65
|
it "should apply the correct source metadata to all components" do
|
59
|
-
|
66
|
+
# TODO: seems to be a jruby regression we cannot currently call each on a stream
|
67
|
+
pipeline.get_plugin_vertices.each do |pv|
|
60
68
|
name_idx = pv.plugin_definition.name.split("_").last
|
61
69
|
source_protocol_idx = pv.source_with_metadata.protocol.split("_").last
|
62
70
|
source_id_idx = pv.source_with_metadata.id.split("_").last
|
@@ -91,9 +99,48 @@ describe LogStash::Compiler do
|
|
91
99
|
|
92
100
|
describe "compiling imperative" do
|
93
101
|
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) }
|
102
|
+
let(:source_with_metadata) { org.logstash.common.SourceWithMetadata.new(source_protocol, source_id, 0, 0, source) }
|
103
|
+
subject(:compiled) { described_class.compile_imperative(source_with_metadata, settings) }
|
104
|
+
|
105
|
+
context "when config.support_escapes" do
|
106
|
+
let(:parser) { LogStashCompilerLSCLGrammarParser.new }
|
107
|
+
|
108
|
+
let(:processed_value) { 'The computer says, "No"' }
|
109
|
+
|
110
|
+
let(:source) {
|
111
|
+
%q(
|
112
|
+
input {
|
113
|
+
foo {
|
114
|
+
bar => "The computer says, \"No\""
|
115
|
+
}
|
116
|
+
}
|
117
|
+
)
|
118
|
+
}
|
119
|
+
|
120
|
+
let(:compiled_string) do
|
121
|
+
compiled[:input].toGraph.vertices.toArray.first.getPluginDefinition.arguments["bar"]
|
122
|
+
end
|
123
|
+
|
124
|
+
before do
|
125
|
+
settings.set_value("config.support_escapes", process_escape_sequences)
|
126
|
+
end
|
96
127
|
|
128
|
+
context "is enabled" do
|
129
|
+
let(:process_escape_sequences) { true }
|
130
|
+
|
131
|
+
it "should process escape sequences" do
|
132
|
+
expect(compiled_string).to be == processed_value
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context "is false" do
|
137
|
+
let(:process_escape_sequences) { false }
|
138
|
+
|
139
|
+
it "should not process escape sequences" do
|
140
|
+
expect(compiled_string).not_to be == processed_value
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
97
144
|
describe "an empty file" do
|
98
145
|
let(:source) { "input {} output {}" }
|
99
146
|
|