logstash-core 5.6.16-java → 6.0.0.alpha1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemspec_jars.rb +4 -7
- data/lib/logstash-core/logstash-core.jar +0 -0
- data/lib/logstash-core/version.rb +4 -8
- data/lib/logstash-core_jars.rb +12 -26
- data/lib/logstash/agent.rb +261 -246
- data/lib/logstash/api/commands/default_metadata.rb +1 -1
- data/lib/logstash/api/commands/hot_threads_reporter.rb +5 -11
- data/lib/logstash/api/commands/node.rb +3 -2
- data/lib/logstash/api/commands/stats.rb +3 -2
- data/lib/logstash/bootstrap_check/bad_java.rb +16 -0
- data/lib/logstash/bootstrap_check/bad_ruby.rb +12 -0
- data/lib/logstash/bootstrap_check/default_config.rb +17 -0
- data/lib/logstash/compiler.rb +38 -0
- data/lib/logstash/compiler/lscl.rb +566 -0
- data/lib/logstash/compiler/lscl/lscl_grammar.rb +3503 -0
- data/lib/logstash/compiler/treetop_monkeypatches.rb +92 -0
- data/lib/logstash/config/config_ast.rb +4 -82
- data/lib/logstash/config/mixin.rb +73 -41
- data/lib/logstash/config/pipeline_config.rb +48 -0
- data/lib/logstash/config/source/base.rb +16 -0
- data/lib/logstash/config/source/local.rb +215 -0
- data/lib/logstash/config/source_loader.rb +125 -0
- data/lib/logstash/converge_result.rb +103 -0
- data/lib/logstash/environment.rb +6 -19
- data/lib/logstash/errors.rb +2 -0
- data/lib/logstash/execution_context.rb +4 -7
- data/lib/logstash/filter_delegator.rb +6 -9
- data/lib/logstash/inputs/base.rb +0 -2
- data/lib/logstash/instrument/collector.rb +5 -7
- data/lib/logstash/instrument/metric_store.rb +12 -12
- data/lib/logstash/instrument/metric_type/mean.rb +0 -5
- data/lib/logstash/instrument/namespaced_metric.rb +0 -4
- data/lib/logstash/instrument/namespaced_null_metric.rb +0 -4
- data/lib/logstash/instrument/null_metric.rb +0 -10
- data/lib/logstash/instrument/periodic_poller/cgroup.rb +85 -168
- data/lib/logstash/instrument/periodic_poller/jvm.rb +5 -5
- data/lib/logstash/instrument/periodic_poller/pq.rb +3 -7
- data/lib/logstash/instrument/periodic_pollers.rb +1 -3
- data/lib/logstash/instrument/wrapped_write_client.rb +24 -33
- data/lib/logstash/logging/logger.rb +15 -47
- data/lib/logstash/namespace.rb +0 -1
- data/lib/logstash/output_delegator.rb +5 -7
- data/lib/logstash/outputs/base.rb +0 -2
- data/lib/logstash/pipeline.rb +159 -87
- data/lib/logstash/pipeline_action.rb +13 -0
- data/lib/logstash/pipeline_action/base.rb +29 -0
- data/lib/logstash/pipeline_action/create.rb +47 -0
- data/lib/logstash/pipeline_action/reload.rb +48 -0
- data/lib/logstash/pipeline_action/stop.rb +23 -0
- data/lib/logstash/plugin.rb +0 -1
- data/lib/logstash/plugins/hooks_registry.rb +6 -0
- data/lib/logstash/plugins/registry.rb +0 -1
- data/lib/logstash/program.rb +14 -0
- data/lib/logstash/queue_factory.rb +5 -1
- data/lib/logstash/runner.rb +58 -80
- data/lib/logstash/settings.rb +3 -27
- data/lib/logstash/state_resolver.rb +41 -0
- data/lib/logstash/util/java_version.rb +6 -0
- data/lib/logstash/util/safe_uri.rb +12 -148
- data/lib/logstash/util/thread_dump.rb +4 -7
- data/lib/logstash/util/wrapped_acked_queue.rb +36 -39
- data/lib/logstash/util/wrapped_synchronous_queue.rb +29 -39
- data/lib/logstash/version.rb +10 -8
- data/locales/en.yml +3 -54
- data/logstash-core.gemspec +8 -35
- data/spec/{logstash/api/modules → api/lib/api}/logging_spec.rb +10 -1
- data/spec/{logstash/api/modules → api/lib/api}/node_plugins_spec.rb +2 -1
- data/spec/{logstash/api/modules → api/lib/api}/node_spec.rb +3 -3
- data/spec/{logstash/api/modules → api/lib/api}/node_stats_spec.rb +3 -7
- data/spec/{logstash/api/modules → api/lib/api}/plugins_spec.rb +3 -4
- data/spec/{logstash/api/modules → api/lib/api}/root_spec.rb +2 -2
- data/spec/api/lib/api/support/resource_dsl_methods.rb +87 -0
- data/spec/{logstash/api/commands/stats_spec.rb → api/lib/commands/stats.rb} +2 -7
- data/spec/{logstash/api → api/lib}/errors_spec.rb +1 -1
- data/spec/{logstash/api → api/lib}/rack_app_spec.rb +0 -0
- data/spec/api/spec_helper.rb +106 -0
- data/spec/logstash/agent/converge_spec.rb +286 -0
- data/spec/logstash/agent/metrics_spec.rb +244 -0
- data/spec/logstash/agent_spec.rb +213 -225
- data/spec/logstash/compiler/compiler_spec.rb +584 -0
- data/spec/logstash/config/config_ast_spec.rb +8 -47
- data/spec/logstash/config/mixin_spec.rb +2 -42
- data/spec/logstash/config/pipeline_config_spec.rb +75 -0
- data/spec/logstash/config/source/local_spec.rb +395 -0
- data/spec/logstash/config/source_loader_spec.rb +122 -0
- data/spec/logstash/converge_result_spec.rb +179 -0
- data/spec/logstash/event_spec.rb +0 -66
- data/spec/logstash/execution_context_spec.rb +8 -12
- data/spec/logstash/filter_delegator_spec.rb +12 -24
- data/spec/logstash/inputs/base_spec.rb +7 -5
- data/spec/logstash/instrument/periodic_poller/cgroup_spec.rb +92 -225
- data/spec/logstash/instrument/periodic_poller/jvm_spec.rb +1 -1
- data/spec/logstash/instrument/periodic_poller/os_spec.rb +32 -29
- data/spec/logstash/instrument/wrapped_write_client_spec.rb +33 -33
- data/spec/logstash/legacy_ruby_event_spec.rb +13 -4
- data/spec/logstash/output_delegator_spec.rb +11 -20
- data/spec/logstash/outputs/base_spec.rb +7 -5
- data/spec/logstash/pipeline_action/create_spec.rb +83 -0
- data/spec/logstash/pipeline_action/reload_spec.rb +83 -0
- data/spec/logstash/pipeline_action/stop_spec.rb +37 -0
- data/spec/logstash/pipeline_pq_file_spec.rb +1 -1
- data/spec/logstash/pipeline_spec.rb +81 -137
- data/spec/logstash/plugin_spec.rb +2 -1
- data/spec/logstash/plugins/hooks_registry_spec.rb +6 -0
- data/spec/logstash/queue_factory_spec.rb +13 -1
- data/spec/logstash/runner_spec.rb +29 -140
- data/spec/logstash/settings/writable_directory_spec.rb +10 -13
- data/spec/logstash/settings_spec.rb +0 -91
- data/spec/logstash/state_resolver_spec.rb +156 -0
- data/spec/logstash/timestamp_spec.rb +2 -6
- data/spec/logstash/util/java_version_spec.rb +22 -0
- data/spec/logstash/util/safe_uri_spec.rb +0 -56
- data/spec/logstash/util/wrapped_synchronous_queue_spec.rb +22 -0
- data/spec/support/helpers.rb +9 -11
- data/spec/support/matchers.rb +96 -6
- data/spec/support/mocks_classes.rb +80 -0
- data/spec/support/shared_contexts.rb +2 -27
- metadata +100 -149
- data/lib/logstash/config/loader.rb +0 -107
- data/lib/logstash/config/modules_common.rb +0 -103
- data/lib/logstash/config/source/modules.rb +0 -55
- data/lib/logstash/config/string_escape.rb +0 -27
- data/lib/logstash/dependency_report.rb +0 -131
- data/lib/logstash/dependency_report_runner.rb +0 -17
- data/lib/logstash/elasticsearch_client.rb +0 -142
- data/lib/logstash/instrument/global_metrics.rb +0 -13
- data/lib/logstash/instrument/periodic_poller/dlq.rb +0 -24
- data/lib/logstash/modules/cli_parser.rb +0 -74
- data/lib/logstash/modules/elasticsearch_config.rb +0 -22
- data/lib/logstash/modules/elasticsearch_importer.rb +0 -37
- data/lib/logstash/modules/elasticsearch_resource.rb +0 -10
- data/lib/logstash/modules/file_reader.rb +0 -36
- data/lib/logstash/modules/kibana_base.rb +0 -24
- data/lib/logstash/modules/kibana_client.rb +0 -124
- data/lib/logstash/modules/kibana_config.rb +0 -105
- data/lib/logstash/modules/kibana_dashboards.rb +0 -36
- data/lib/logstash/modules/kibana_importer.rb +0 -17
- data/lib/logstash/modules/kibana_resource.rb +0 -10
- data/lib/logstash/modules/kibana_settings.rb +0 -40
- data/lib/logstash/modules/logstash_config.rb +0 -120
- data/lib/logstash/modules/resource_base.rb +0 -38
- data/lib/logstash/modules/scaffold.rb +0 -52
- data/lib/logstash/modules/settings_merger.rb +0 -23
- data/lib/logstash/modules/util.rb +0 -17
- data/lib/logstash/util/dead_letter_queue_manager.rb +0 -61
- data/lib/logstash/util/environment_variables.rb +0 -43
- data/spec/logstash/config/loader_spec.rb +0 -38
- data/spec/logstash/config/string_escape_spec.rb +0 -24
- data/spec/logstash/instrument/periodic_poller/dlq_spec.rb +0 -17
- data/spec/logstash/modules/logstash_config_spec.rb +0 -56
- data/spec/logstash/modules/scaffold_spec.rb +0 -234
- data/spec/logstash/pipeline_dlq_commit_spec.rb +0 -109
- data/spec/logstash/settings/splittable_string_array_spec.rb +0 -51
- data/spec/logstash/util/wrapped_acked_queue_spec.rb +0 -49
- data/versions-gem-copy.yml +0 -12
@@ -3,17 +3,17 @@ require "spec_helper"
|
|
3
3
|
require "logstash/settings"
|
4
4
|
require "tmpdir"
|
5
5
|
require "socket" # for UNIXSocket
|
6
|
-
require "fileutils"
|
7
6
|
|
8
7
|
describe LogStash::Setting::WritableDirectory do
|
8
|
+
let(:mode_rx) { 0555 }
|
9
9
|
# linux is 108, Macos is 104, so use a safe value
|
10
10
|
# Stud::Temporary.pathname, will exceed that size without adding anything
|
11
11
|
let(:parent) { File.join(Dir.tmpdir, Time.now.to_f.to_s) }
|
12
12
|
let(:path) { File.join(parent, "fancy") }
|
13
13
|
|
14
14
|
before { Dir.mkdir(parent) }
|
15
|
-
after { Dir.exist?(path) &&
|
16
|
-
after {
|
15
|
+
after { Dir.exist?(path) && Dir.unlink(path) rescue nil }
|
16
|
+
after { Dir.unlink(parent) }
|
17
17
|
|
18
18
|
shared_examples "failure" do
|
19
19
|
before { subject.set(path) }
|
@@ -44,9 +44,8 @@ describe LogStash::Setting::WritableDirectory do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
context "and the directory cannot be created" do
|
47
|
+
before { File.chmod(mode_rx, parent) }
|
47
48
|
it "should fail" do
|
48
|
-
# using chmod does not work on Windows better mock and_raise("message")
|
49
|
-
expect(FileUtils).to receive(:mkdir_p).and_raise("foobar")
|
50
49
|
expect { subject.value }.to raise_error
|
51
50
|
end
|
52
51
|
end
|
@@ -67,8 +66,7 @@ describe LogStash::Setting::WritableDirectory do
|
|
67
66
|
end
|
68
67
|
|
69
68
|
context "but is not writable" do
|
70
|
-
|
71
|
-
before { expect(File).to receive(:writable?).and_return(false) }
|
69
|
+
before { File.chmod(0, path) }
|
72
70
|
it_behaves_like "failure"
|
73
71
|
end
|
74
72
|
end
|
@@ -86,13 +84,12 @@ describe LogStash::Setting::WritableDirectory do
|
|
86
84
|
before { socket } # realize `socket` value
|
87
85
|
after { socket.close }
|
88
86
|
it_behaves_like "failure"
|
89
|
-
end
|
87
|
+
end
|
90
88
|
|
91
|
-
|
92
89
|
context "but is a symlink" do
|
93
|
-
before {
|
90
|
+
before { File::symlink("whatever", path) }
|
94
91
|
it_behaves_like "failure"
|
95
|
-
end
|
92
|
+
end
|
96
93
|
end
|
97
94
|
|
98
95
|
context "when the directory is missing" do
|
@@ -117,8 +114,8 @@ describe LogStash::Setting::WritableDirectory do
|
|
117
114
|
|
118
115
|
context "and cannot be created" do
|
119
116
|
before do
|
120
|
-
#
|
121
|
-
|
117
|
+
# Remove write permission on the parent
|
118
|
+
File.chmod(mode_rx, parent)
|
122
119
|
end
|
123
120
|
|
124
121
|
it_behaves_like "failure"
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "spec_helper"
|
3
|
-
require "logstash/util/environment_variables"
|
4
3
|
require "logstash/settings"
|
5
4
|
require "fileutils"
|
6
5
|
|
@@ -147,94 +146,4 @@ describe LogStash::Settings do
|
|
147
146
|
end
|
148
147
|
end
|
149
148
|
end
|
150
|
-
|
151
|
-
describe "#from_yaml" do
|
152
|
-
|
153
|
-
context "env placeholders in flat logstash.yml" do
|
154
|
-
|
155
|
-
after do
|
156
|
-
ENV.delete('SOME_LOGSTASH_SPEC_ENV_VAR')
|
157
|
-
ENV.delete('some.logstash.spec.env.var')
|
158
|
-
end
|
159
|
-
|
160
|
-
subject do
|
161
|
-
settings = described_class.new
|
162
|
-
settings.register(LogStash::Setting::String.new("interpolated", "missing"))
|
163
|
-
settings.register(LogStash::Setting::String.new("with_dot", "missing"))
|
164
|
-
settings
|
165
|
-
end
|
166
|
-
|
167
|
-
let(:values) {{
|
168
|
-
"interpolated" => "${SOME_LOGSTASH_SPEC_ENV_VAR}",
|
169
|
-
"with_dot" => "${some.logstash.spec.env.var}"
|
170
|
-
}}
|
171
|
-
let(:yaml_path) do
|
172
|
-
p = Stud::Temporary.pathname
|
173
|
-
FileUtils.mkdir_p(p)
|
174
|
-
|
175
|
-
::File.open(::File.join(p, "logstash.yml"), "w+") do |f|
|
176
|
-
f.write(YAML.dump(values))
|
177
|
-
end
|
178
|
-
p
|
179
|
-
end
|
180
|
-
|
181
|
-
it "can interpolate environment into settings" do
|
182
|
-
expect(subject.get('interpolated')).to eq("missing")
|
183
|
-
expect(subject.get('with_dot')).to eq("missing")
|
184
|
-
ENV['SOME_LOGSTASH_SPEC_ENV_VAR'] = "correct_setting"
|
185
|
-
ENV['some.logstash.spec.env.var'] = "correct_setting_for_dotted"
|
186
|
-
subject.from_yaml(yaml_path)
|
187
|
-
expect(subject.get('interpolated')).to eq("correct_setting")
|
188
|
-
expect(subject.get('with_dot')).to eq("correct_setting_for_dotted")
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
context "env placeholders in nested logstash.yml" do
|
194
|
-
|
195
|
-
before do
|
196
|
-
ENV['lsspecdomain'] = "domain1"
|
197
|
-
ENV['lsspecdomain2'] = "domain2"
|
198
|
-
end
|
199
|
-
|
200
|
-
after do
|
201
|
-
ENV.delete('lsspecdomain')
|
202
|
-
ENV.delete('lsspecdomain2')
|
203
|
-
end
|
204
|
-
|
205
|
-
subject do
|
206
|
-
settings = described_class.new
|
207
|
-
settings.register(LogStash::Setting::ArrayCoercible.new("host", String, []))
|
208
|
-
settings.register(LogStash::Setting::ArrayCoercible.new("modules", Hash, []))
|
209
|
-
settings
|
210
|
-
end
|
211
|
-
|
212
|
-
let(:values) {{
|
213
|
-
"host" => ["dev1.${lsspecdomain}", "dev2.${lsspecdomain}"],
|
214
|
-
"modules" => [
|
215
|
-
{"name" => "${lsspecdomain}", "testing" => "${lsspecdomain}"},
|
216
|
-
{"name" => "${lsspecdomain2}", "testing" => "${lsspecdomain2}"}
|
217
|
-
]
|
218
|
-
}}
|
219
|
-
let(:yaml_path) do
|
220
|
-
p = Stud::Temporary.pathname
|
221
|
-
FileUtils.mkdir_p(p)
|
222
|
-
|
223
|
-
::File.open(::File.join(p, "logstash.yml"), "w+") do |f|
|
224
|
-
f.write(YAML.dump(values))
|
225
|
-
end
|
226
|
-
p
|
227
|
-
end
|
228
|
-
|
229
|
-
it "can interpolate environment into settings" do
|
230
|
-
expect(subject.get('host')).to match_array([])
|
231
|
-
expect(subject.get('modules')).to match_array([])
|
232
|
-
subject.from_yaml(yaml_path)
|
233
|
-
expect(subject.get('host')).to match_array(["dev1.domain1", "dev2.domain1"])
|
234
|
-
expect(subject.get('modules')).to match_array([
|
235
|
-
{"name" => "domain1", "testing" => "domain1"},
|
236
|
-
{"name" => "domain2", "testing" => "domain2"}
|
237
|
-
])
|
238
|
-
end
|
239
|
-
end
|
240
149
|
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
require_relative "../support/helpers"
|
4
|
+
require_relative "../support/matchers"
|
5
|
+
require "logstash/state_resolver"
|
6
|
+
require "logstash/config/pipeline_config"
|
7
|
+
require "logstash/instrument/null_metric"
|
8
|
+
require "logstash/pipeline"
|
9
|
+
require "ostruct"
|
10
|
+
require "digest"
|
11
|
+
|
12
|
+
describe LogStash::StateResolver do
|
13
|
+
subject { described_class.new(metric) }
|
14
|
+
let(:metric) { LogStash::Instrument::NullMetric.new }
|
15
|
+
|
16
|
+
before do
|
17
|
+
clear_data_dir
|
18
|
+
end
|
19
|
+
|
20
|
+
after do
|
21
|
+
# ensure that the the created pipeline are closed
|
22
|
+
running_pipelines.each { |_, pipeline| pipeline.close }
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when no pipeline is running" do
|
26
|
+
let(:running_pipelines) { {} }
|
27
|
+
|
28
|
+
context "no pipeline configs is received" do
|
29
|
+
let(:pipeline_configs) { [] }
|
30
|
+
|
31
|
+
it "returns no action" do
|
32
|
+
expect(subject.resolve(running_pipelines, pipeline_configs).size).to eq(0)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "we receive some pipeline configs" do
|
37
|
+
let(:pipeline_configs) { [mock_pipeline_config(:hello_world)] }
|
38
|
+
|
39
|
+
it "returns some actions" do
|
40
|
+
expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
|
41
|
+
[:create, :hello_world],
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "when some pipeline are running" do
|
48
|
+
context "when a pipeline is running" do
|
49
|
+
let(:running_pipelines) { { :main => mock_pipeline(:main) } }
|
50
|
+
|
51
|
+
context "when the pipeline config contains a new one and the existing" do
|
52
|
+
let(:pipeline_configs) { [mock_pipeline_config(:hello_world), mock_pipeline_config(:main)] }
|
53
|
+
|
54
|
+
it "creates the new one and keep the other one" do
|
55
|
+
expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
|
56
|
+
[:create, :hello_world],
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
context "when the pipeline config contains only the new one" do
|
61
|
+
let(:pipeline_configs) { [mock_pipeline_config(:hello_world)] }
|
62
|
+
|
63
|
+
it "creates the new one and stop the old one one" do
|
64
|
+
expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
|
65
|
+
[:create, :hello_world],
|
66
|
+
[:stop, :main]
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "when the pipeline config contains no pipeline" do
|
72
|
+
let(:pipeline_configs) { [] }
|
73
|
+
|
74
|
+
it "stops the old one one" do
|
75
|
+
expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
|
76
|
+
[:stop, :main]
|
77
|
+
)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "when pipeline config contains an updated pipeline" do
|
82
|
+
let(:pipeline_configs) { [mock_pipeline_config(:main, "input { generator {}}")] }
|
83
|
+
|
84
|
+
it "reloads the old one one" do
|
85
|
+
expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
|
86
|
+
[:reload, :main]
|
87
|
+
)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "when we have a lot of pipeline running" do
|
94
|
+
let(:running_pipelines) do
|
95
|
+
{
|
96
|
+
:main1 => mock_pipeline(:main1),
|
97
|
+
:main2 => mock_pipeline(:main2),
|
98
|
+
:main3 => mock_pipeline(:main3),
|
99
|
+
:main4 => mock_pipeline(:main4),
|
100
|
+
:main5 => mock_pipeline(:main5),
|
101
|
+
:main6 => mock_pipeline(:main6),
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
context "without system pipeline" do
|
106
|
+
let(:pipeline_configs) do
|
107
|
+
[
|
108
|
+
mock_pipeline_config(:main1),
|
109
|
+
mock_pipeline_config(:main9),
|
110
|
+
mock_pipeline_config(:main5, "input { generator {}}"),
|
111
|
+
mock_pipeline_config(:main3, "input { generator {}}"),
|
112
|
+
mock_pipeline_config(:main7)
|
113
|
+
]
|
114
|
+
end
|
115
|
+
|
116
|
+
it "generates actions required to converge" do
|
117
|
+
expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
|
118
|
+
[:create, :main7],
|
119
|
+
[:create, :main9],
|
120
|
+
[:reload, :main3],
|
121
|
+
[:reload, :main5],
|
122
|
+
[:stop, :main2],
|
123
|
+
[:stop, :main4],
|
124
|
+
[:stop, :main6]
|
125
|
+
)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context "with system pipeline" do
|
130
|
+
let(:pipeline_configs) do
|
131
|
+
[
|
132
|
+
mock_pipeline_config(:main1),
|
133
|
+
mock_pipeline_config(:main9),
|
134
|
+
mock_pipeline_config(:main5, "input { generator {}}"),
|
135
|
+
mock_pipeline_config(:main3, "input { generator {}}"),
|
136
|
+
mock_pipeline_config(:main7),
|
137
|
+
mock_pipeline_config(:monitoring, "input { generator {}}", { "pipeline.system" => true }),
|
138
|
+
]
|
139
|
+
end
|
140
|
+
|
141
|
+
it "creates the system pipeline before user defined pipelines" do
|
142
|
+
expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
|
143
|
+
[:create, :monitoring],
|
144
|
+
[:create, :main7],
|
145
|
+
[:create, :main9],
|
146
|
+
[:reload, :main3],
|
147
|
+
[:reload, :main5],
|
148
|
+
[:stop, :main2],
|
149
|
+
[:stop, :main4],
|
150
|
+
[:stop, :main6]
|
151
|
+
)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -7,10 +7,10 @@ describe LogStash::Timestamp do
|
|
7
7
|
context "constructors" do
|
8
8
|
it "should work" do
|
9
9
|
t = LogStash::Timestamp.new
|
10
|
-
expect(t.time.to_i).to be_within(
|
10
|
+
expect(t.time.to_i).to be_within(1).of Time.now.to_i
|
11
11
|
|
12
12
|
t = LogStash::Timestamp.now
|
13
|
-
expect(t.time.to_i).to be_within(
|
13
|
+
expect(t.time.to_i).to be_within(1).of Time.now.to_i
|
14
14
|
|
15
15
|
now = Time.now.utc
|
16
16
|
t = LogStash::Timestamp.new(now)
|
@@ -30,10 +30,6 @@ describe LogStash::Timestamp do
|
|
30
30
|
expect{LogStash::Timestamp.new("foobar")}.to raise_error
|
31
31
|
end
|
32
32
|
|
33
|
-
it "should copy itself correctly on clone and dup" do
|
34
|
-
expect(LogStash::Timestamp.now.clone.to_java).not_to be_nil
|
35
|
-
expect(LogStash::Timestamp.now.dup.to_java).not_to be_nil
|
36
|
-
end
|
37
33
|
end
|
38
34
|
|
39
35
|
end
|
@@ -39,6 +39,28 @@ describe "LogStash::Util::JavaVersion" do
|
|
39
39
|
expect(mod.bad_java_version?("pwi3270sr9fp10-20150708_01 (SR9 FP10)")).to be_falsey
|
40
40
|
end
|
41
41
|
|
42
|
+
context ".validate_java_version!" do
|
43
|
+
context "with good version" do
|
44
|
+
before do
|
45
|
+
expect(mod).to receive(:version).and_return("1.8.0")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "doesn't raise an error" do
|
49
|
+
expect { mod.validate_java_version! }.not_to raise_error
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "with a bad version" do
|
54
|
+
before do
|
55
|
+
expect(mod).to receive(:version).and_return("1.7.0").twice
|
56
|
+
end
|
57
|
+
|
58
|
+
it "raises an error" do
|
59
|
+
expect { mod.validate_java_version! }.to raise_error RuntimeError, /Java version 1.8.0 or later/
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
42
64
|
describe "parsing java versions" do
|
43
65
|
it "should return nil on a nil version" do
|
44
66
|
expect(mod.parse_java_version(nil)).to be_nil
|
@@ -16,61 +16,5 @@ module LogStash module Util
|
|
16
16
|
expect(cloned_safe_uri.query).to eq("a=b")
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
20
|
-
describe "handling escapable fields" do
|
21
|
-
let(:user) { "u%20" }
|
22
|
-
let(:password) { "p%20ss" }
|
23
|
-
let(:path) { "/a%20/path" }
|
24
|
-
let(:query) { "a%20query&another=es%3dq" }
|
25
|
-
let(:fragment) { "spacey%20fragment" }
|
26
|
-
subject { LogStash::Util::SafeURI.new("http://#{user}:#{password}@example.net#{path}?#{query}\##{fragment}") }
|
27
|
-
|
28
|
-
[:user, :password, :path, :query, :fragment].each do |field|
|
29
|
-
it "should not escape the #{field} field" do
|
30
|
-
expected = self.send(field)
|
31
|
-
expect(subject.send(field)).to eq(expected)
|
32
|
-
end
|
33
|
-
end
|
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
19
|
end
|
76
20
|
end end
|
@@ -4,6 +4,28 @@ require "logstash/util/wrapped_synchronous_queue"
|
|
4
4
|
require "logstash/instrument/collector"
|
5
5
|
|
6
6
|
describe LogStash::Util::WrappedSynchronousQueue do
|
7
|
+
context "#offer" do
|
8
|
+
context "queue is blocked" do
|
9
|
+
it "fails and give feedback" do
|
10
|
+
expect(subject.offer("Bonjour", 2)).to be_falsey
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "queue is not blocked" do
|
15
|
+
before do
|
16
|
+
@consumer = Thread.new { loop { subject.take } }
|
17
|
+
sleep(0.1)
|
18
|
+
end
|
19
|
+
|
20
|
+
after do
|
21
|
+
@consumer.kill
|
22
|
+
end
|
23
|
+
|
24
|
+
it "inserts successfully" do
|
25
|
+
expect(subject.offer("Bonjour", 20)).to be_truthy
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
7
29
|
|
8
30
|
describe "queue clients" do
|
9
31
|
context "when requesting a write client" do
|