logstash-core 5.0.0.alpha2.snapshot2-java → 5.0.0.alpha3-java
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of logstash-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/logstash-core/version.rb +1 -1
- data/lib/logstash/agent.rb +48 -31
- data/lib/logstash/api/{lib/helpers/app_helpers.rb → app_helpers.rb} +0 -0
- data/lib/logstash/api/command_factory.rb +34 -0
- data/lib/logstash/api/commands/base.rb +25 -0
- data/lib/logstash/api/commands/stats.rb +105 -0
- data/lib/logstash/api/commands/system/basicinfo_command.rb +23 -0
- data/lib/logstash/api/commands/system/plugins_command.rb +35 -0
- data/lib/logstash/api/modules/base.rb +43 -0
- data/lib/logstash/api/modules/node.rb +24 -0
- data/lib/logstash/api/modules/node_stats.rb +59 -0
- data/lib/logstash/api/modules/plugins.rb +15 -0
- data/lib/logstash/api/modules/root.rb +15 -0
- data/lib/logstash/api/modules/stats.rb +63 -0
- data/lib/logstash/api/rack_app.rb +33 -0
- data/lib/logstash/api/service.rb +73 -0
- data/lib/logstash/config/config_ast.rb +23 -18
- data/lib/logstash/config/loader.rb +4 -4
- data/lib/logstash/config/mixin.rb +10 -21
- data/lib/logstash/environment.rb +29 -0
- data/lib/logstash/filters/base.rb +2 -2
- data/lib/logstash/inputs/base.rb +2 -2
- data/lib/logstash/instrument/collector.rb +1 -1
- data/lib/logstash/instrument/metric_store.rb +11 -1
- data/lib/logstash/instrument/periodic_poller/base.rb +2 -0
- data/lib/logstash/instrument/periodic_poller/jvm.rb +47 -2
- data/lib/logstash/logging/json.rb +21 -0
- data/lib/logstash/output_delegator.rb +2 -2
- data/lib/logstash/patches/clamp.rb +69 -0
- data/lib/logstash/pipeline.rb +36 -69
- data/lib/logstash/plugin.rb +1 -1
- data/lib/logstash/runner.rb +171 -146
- data/lib/logstash/settings.rb +267 -0
- data/lib/logstash/util/decorators.rb +6 -6
- data/lib/logstash/util/java_version.rb +1 -10
- data/lib/logstash/util/thread_dump.rb +55 -0
- data/lib/logstash/util/worker_threads_default_printer.rb +2 -2
- data/lib/logstash/version.rb +1 -1
- data/lib/logstash/webserver.rb +15 -49
- data/locales/en.yml +22 -25
- data/logstash-core.gemspec +3 -3
- data/spec/api/lib/api/node_spec.rb +2 -2
- data/spec/api/lib/api/node_stats_spec.rb +32 -57
- data/spec/api/lib/api/plugins_spec.rb +3 -3
- data/spec/api/lib/api/root_spec.rb +2 -2
- data/spec/api/lib/api/support/resource_dsl_methods.rb +47 -0
- data/spec/api/lib/commands/stats.rb +47 -0
- data/spec/api/spec_helper.rb +21 -21
- data/spec/conditionals_spec.rb +113 -113
- data/spec/logstash/agent_spec.rb +85 -68
- data/spec/logstash/config/config_ast_spec.rb +4 -2
- data/spec/logstash/config/mixin_spec.rb +33 -7
- data/spec/logstash/filters/base_spec.rb +16 -16
- data/spec/logstash/inputs/base_spec.rb +8 -8
- data/spec/logstash/instrument/periodic_poller/jvm_spec.rb +45 -0
- data/spec/logstash/output_delegator_spec.rb +2 -0
- data/spec/logstash/pipeline_reporter_spec.rb +5 -1
- data/spec/logstash/pipeline_spec.rb +75 -30
- data/spec/logstash/plugin_spec.rb +2 -2
- data/spec/logstash/runner_spec.rb +112 -25
- data/spec/logstash/setting_spec.rb +130 -0
- data/spec/logstash/settings_spec.rb +62 -0
- metadata +37 -43
- data/lib/logstash/api/init.ru +0 -31
- data/lib/logstash/api/lib/app.rb +0 -40
- data/lib/logstash/api/lib/app/command.rb +0 -29
- data/lib/logstash/api/lib/app/command_factory.rb +0 -29
- data/lib/logstash/api/lib/app/commands/stats/events_command.rb +0 -13
- data/lib/logstash/api/lib/app/commands/stats/hotthreads_command.rb +0 -120
- data/lib/logstash/api/lib/app/commands/stats/memory_command.rb +0 -25
- data/lib/logstash/api/lib/app/commands/system/basicinfo_command.rb +0 -15
- data/lib/logstash/api/lib/app/commands/system/plugins_command.rb +0 -28
- data/lib/logstash/api/lib/app/modules/node.rb +0 -25
- data/lib/logstash/api/lib/app/modules/node_stats.rb +0 -51
- data/lib/logstash/api/lib/app/modules/plugins.rb +0 -15
- data/lib/logstash/api/lib/app/modules/stats.rb +0 -21
- data/lib/logstash/api/lib/app/root.rb +0 -13
- data/lib/logstash/api/lib/app/service.rb +0 -61
- data/lib/logstash/api/lib/app/stats.rb +0 -56
- data/lib/logstash/util/defaults_printer.rb +0 -31
- data/spec/api/lib/api/stats_spec.rb +0 -19
- data/spec/api/lib/commands/events_spec.rb +0 -17
- data/spec/api/lib/commands/jvm_spec.rb +0 -45
- data/spec/logstash/util/defaults_printer_spec.rb +0 -50
- data/spec/logstash/util/worker_threads_default_printer_spec.rb +0 -45
data/spec/conditionals_spec.rb
CHANGED
@@ -64,24 +64,24 @@ describe "conditionals in filter" do
|
|
64
64
|
CONFIG
|
65
65
|
|
66
66
|
sample({"foo" => "bar"}) do
|
67
|
-
expect(subject
|
68
|
-
expect(subject
|
69
|
-
expect(subject
|
70
|
-
expect(subject
|
67
|
+
expect(subject.get("always")).to eq("awesome")
|
68
|
+
expect(subject.get("hello")).to eq("world")
|
69
|
+
expect(subject.get("fancy")).to be_nil
|
70
|
+
expect(subject.get("free")).to be_nil
|
71
71
|
end
|
72
72
|
|
73
73
|
sample({"notfoo" => "bar"}) do
|
74
|
-
expect(subject
|
75
|
-
expect(subject
|
76
|
-
expect(subject
|
77
|
-
expect(subject
|
74
|
+
expect(subject.get("always")).to eq("awesome")
|
75
|
+
expect(subject.get("hello")).to be_nil
|
76
|
+
expect(subject.get("fancy")).to be_nil
|
77
|
+
expect(subject.get("free")).to eq("hugs")
|
78
78
|
end
|
79
79
|
|
80
80
|
sample({"bar" => "baz"}) do
|
81
|
-
expect(subject
|
82
|
-
expect(subject
|
83
|
-
expect(subject
|
84
|
-
expect(subject
|
81
|
+
expect(subject.get("always")).to eq("awesome")
|
82
|
+
expect(subject.get("hello")).to be_nil
|
83
|
+
expect(subject.get("fancy")).to eq("pants")
|
84
|
+
expect(subject.get("free")).to be_nil
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -102,31 +102,31 @@ describe "conditionals in filter" do
|
|
102
102
|
CONFIG
|
103
103
|
|
104
104
|
sample("foo" => "bar", "nest" => 124) do
|
105
|
-
expect(subject
|
106
|
-
expect(subject
|
107
|
-
expect(subject
|
108
|
-
expect(subject
|
105
|
+
expect(subject.get("always")).to be_nil
|
106
|
+
expect(subject.get("hello")).to be_nil
|
107
|
+
expect(subject.get("fancy")).to be_nil
|
108
|
+
expect(subject.get("free")).to be_nil
|
109
109
|
end
|
110
110
|
|
111
111
|
sample("foo" => "bar", "nest" => 123) do
|
112
|
-
expect(subject
|
113
|
-
expect(subject
|
114
|
-
expect(subject
|
115
|
-
expect(subject
|
112
|
+
expect(subject.get("always")).to eq("awesome")
|
113
|
+
expect(subject.get("hello")).to eq("world")
|
114
|
+
expect(subject.get("fancy")).to be_nil
|
115
|
+
expect(subject.get("free")).to be_nil
|
116
116
|
end
|
117
117
|
|
118
118
|
sample("notfoo" => "bar", "nest" => 123) do
|
119
|
-
expect(subject
|
120
|
-
expect(subject
|
121
|
-
expect(subject
|
122
|
-
expect(subject
|
119
|
+
expect(subject.get("always")).to eq("awesome")
|
120
|
+
expect(subject.get("hello")).to be_nil
|
121
|
+
expect(subject.get("fancy")).to be_nil
|
122
|
+
expect(subject.get("free")).to eq("hugs")
|
123
123
|
end
|
124
124
|
|
125
125
|
sample("bar" => "baz", "nest" => 123) do
|
126
|
-
expect(subject
|
127
|
-
expect(subject
|
128
|
-
expect(subject
|
129
|
-
expect(subject
|
126
|
+
expect(subject.get("always")).to eq("awesome")
|
127
|
+
expect(subject.get("hello")).to be_nil
|
128
|
+
expect(subject.get("fancy")).to eq("pants")
|
129
|
+
expect(subject.get("free")).to be_nil
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
@@ -140,7 +140,7 @@ describe "conditionals in filter" do
|
|
140
140
|
CONFIG
|
141
141
|
|
142
142
|
sample("foo" => 123, "bar" => 123) do
|
143
|
-
expect(subject
|
143
|
+
expect(subject.get("tags") ).to include("woot")
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -169,12 +169,12 @@ describe "conditionals in filter" do
|
|
169
169
|
CONFIG
|
170
170
|
|
171
171
|
sample("foo" => "foo", "foobar" => "foobar", "greeting" => "hello world") do
|
172
|
-
expect(subject
|
173
|
-
expect(subject
|
174
|
-
expect(subject
|
175
|
-
expect(subject
|
176
|
-
expect(subject
|
177
|
-
expect(subject
|
172
|
+
expect(subject.get("tags")).to include("field in field")
|
173
|
+
expect(subject.get("tags")).to include("field in string")
|
174
|
+
expect(subject.get("tags")).to include("string in field")
|
175
|
+
expect(subject.get("tags")).to include("field in list")
|
176
|
+
expect(subject.get("tags")).not_to include("shouldnotexist")
|
177
|
+
expect(subject.get("tags")).to include("shouldexist")
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
@@ -192,107 +192,107 @@ describe "conditionals in filter" do
|
|
192
192
|
|
193
193
|
sample("foo" => "foo", "somelist" => [ "one", "two" ], "foobar" => "foobar", "greeting" => "hello world", "tags" => [ "fancypantsy" ]) do
|
194
194
|
# verify the original exists
|
195
|
-
expect(subject
|
195
|
+
expect(subject.get("tags")).to include("fancypantsy")
|
196
196
|
|
197
|
-
expect(subject
|
198
|
-
expect(subject
|
199
|
-
expect(subject
|
200
|
-
expect(subject
|
201
|
-
expect(subject
|
202
|
-
expect(subject
|
197
|
+
expect(subject.get("tags")).to include("baz")
|
198
|
+
expect(subject.get("tags")).not_to include("foo")
|
199
|
+
expect(subject.get("tags")).to include("notfoo")
|
200
|
+
expect(subject.get("tags")).to include("notsomelist")
|
201
|
+
expect(subject.get("tags")).not_to include("somelist")
|
202
|
+
expect(subject.get("tags")).to include("no string in missing field")
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
206
206
|
describe "operators" do
|
207
207
|
conditional "[message] == 'sample'" do
|
208
|
-
sample("sample") { expect(subject
|
209
|
-
sample("different") { expect(subject
|
208
|
+
sample("sample") { expect(subject.get("tags") ).to include("success") }
|
209
|
+
sample("different") { expect(subject.get("tags") ).to include("failure") }
|
210
210
|
end
|
211
211
|
|
212
212
|
conditional "[message] != 'sample'" do
|
213
|
-
sample("sample") { expect(subject
|
214
|
-
sample("different") { expect(subject
|
213
|
+
sample("sample") { expect(subject.get("tags") ).to include("failure") }
|
214
|
+
sample("different") { expect(subject.get("tags") ).to include("success") }
|
215
215
|
end
|
216
216
|
|
217
217
|
conditional "[message] < 'sample'" do
|
218
|
-
sample("apple") { expect(subject
|
219
|
-
sample("zebra") { expect(subject
|
218
|
+
sample("apple") { expect(subject.get("tags") ).to include("success") }
|
219
|
+
sample("zebra") { expect(subject.get("tags") ).to include("failure") }
|
220
220
|
end
|
221
221
|
|
222
222
|
conditional "[message] > 'sample'" do
|
223
|
-
sample("zebra") { expect(subject
|
224
|
-
sample("apple") { expect(subject
|
223
|
+
sample("zebra") { expect(subject.get("tags") ).to include("success") }
|
224
|
+
sample("apple") { expect(subject.get("tags") ).to include("failure") }
|
225
225
|
end
|
226
226
|
|
227
227
|
conditional "[message] <= 'sample'" do
|
228
|
-
sample("apple") { expect(subject
|
229
|
-
sample("zebra") { expect(subject
|
230
|
-
sample("sample") { expect(subject
|
228
|
+
sample("apple") { expect(subject.get("tags") ).to include("success") }
|
229
|
+
sample("zebra") { expect(subject.get("tags") ).to include("failure") }
|
230
|
+
sample("sample") { expect(subject.get("tags") ).to include("success") }
|
231
231
|
end
|
232
232
|
|
233
233
|
conditional "[message] >= 'sample'" do
|
234
|
-
sample("zebra") { expect(subject
|
235
|
-
sample("sample") { expect(subject
|
236
|
-
sample("apple") { expect(subject
|
234
|
+
sample("zebra") { expect(subject.get("tags") ).to include("success") }
|
235
|
+
sample("sample") { expect(subject.get("tags") ).to include("success") }
|
236
|
+
sample("apple") { expect(subject.get("tags") ).to include("failure") }
|
237
237
|
end
|
238
238
|
|
239
239
|
conditional "[message] =~ /sample/" do
|
240
|
-
sample("apple") { expect(subject
|
241
|
-
sample("sample") { expect(subject
|
242
|
-
sample("some sample") { expect(subject
|
240
|
+
sample("apple") { expect(subject.get("tags") ).to include("failure") }
|
241
|
+
sample("sample") { expect(subject.get("tags") ).to include("success") }
|
242
|
+
sample("some sample") { expect(subject.get("tags") ).to include("success") }
|
243
243
|
end
|
244
244
|
|
245
245
|
conditional "[message] !~ /sample/" do
|
246
|
-
sample("apple") { expect(subject
|
247
|
-
sample("sample") { expect(subject
|
248
|
-
sample("some sample") { expect(subject
|
246
|
+
sample("apple") { expect(subject.get("tags")).to include("success") }
|
247
|
+
sample("sample") { expect(subject.get("tags")).to include("failure") }
|
248
|
+
sample("some sample") { expect(subject.get("tags")).to include("failure") }
|
249
249
|
end
|
250
250
|
|
251
251
|
end
|
252
252
|
|
253
253
|
describe "negated expressions" do
|
254
254
|
conditional "!([message] == 'sample')" do
|
255
|
-
sample("sample") { expect(subject
|
256
|
-
sample("different") { expect(subject
|
255
|
+
sample("sample") { expect(subject.get("tags")).not_to include("success") }
|
256
|
+
sample("different") { expect(subject.get("tags")).not_to include("failure") }
|
257
257
|
end
|
258
258
|
|
259
259
|
conditional "!([message] != 'sample')" do
|
260
|
-
sample("sample") { expect(subject
|
261
|
-
sample("different") { expect(subject
|
260
|
+
sample("sample") { expect(subject.get("tags")).not_to include("failure") }
|
261
|
+
sample("different") { expect(subject.get("tags")).not_to include("success") }
|
262
262
|
end
|
263
263
|
|
264
264
|
conditional "!([message] < 'sample')" do
|
265
|
-
sample("apple") { expect(subject
|
266
|
-
sample("zebra") { expect(subject
|
265
|
+
sample("apple") { expect(subject.get("tags")).not_to include("success") }
|
266
|
+
sample("zebra") { expect(subject.get("tags")).not_to include("failure") }
|
267
267
|
end
|
268
268
|
|
269
269
|
conditional "!([message] > 'sample')" do
|
270
|
-
sample("zebra") { expect(subject
|
271
|
-
sample("apple") { expect(subject
|
270
|
+
sample("zebra") { expect(subject.get("tags")).not_to include("success") }
|
271
|
+
sample("apple") { expect(subject.get("tags")).not_to include("failure") }
|
272
272
|
end
|
273
273
|
|
274
274
|
conditional "!([message] <= 'sample')" do
|
275
|
-
sample("apple") { expect(subject
|
276
|
-
sample("zebra") { expect(subject
|
277
|
-
sample("sample") { expect(subject
|
275
|
+
sample("apple") { expect(subject.get("tags")).not_to include("success") }
|
276
|
+
sample("zebra") { expect(subject.get("tags")).not_to include("failure") }
|
277
|
+
sample("sample") { expect(subject.get("tags")).not_to include("success") }
|
278
278
|
end
|
279
279
|
|
280
280
|
conditional "!([message] >= 'sample')" do
|
281
|
-
sample("zebra") { expect(subject
|
282
|
-
sample("sample") { expect(subject
|
283
|
-
sample("apple") { expect(subject
|
281
|
+
sample("zebra") { expect(subject.get("tags")).not_to include("success") }
|
282
|
+
sample("sample") { expect(subject.get("tags")).not_to include("success") }
|
283
|
+
sample("apple") { expect(subject.get("tags")).not_to include("failure") }
|
284
284
|
end
|
285
285
|
|
286
286
|
conditional "!([message] =~ /sample/)" do
|
287
|
-
sample("apple") { expect(subject
|
288
|
-
sample("sample") { expect(subject
|
289
|
-
sample("some sample") { expect(subject
|
287
|
+
sample("apple") { expect(subject.get("tags")).not_to include("failure") }
|
288
|
+
sample("sample") { expect(subject.get("tags")).not_to include("success") }
|
289
|
+
sample("some sample") { expect(subject.get("tags")).not_to include("success") }
|
290
290
|
end
|
291
291
|
|
292
292
|
conditional "!([message] !~ /sample/)" do
|
293
|
-
sample("apple") { expect(subject
|
294
|
-
sample("sample") { expect(subject
|
295
|
-
sample("some sample") { expect(subject
|
293
|
+
sample("apple") { expect(subject.get("tags")).not_to include("success") }
|
294
|
+
sample("sample") { expect(subject.get("tags")).not_to include("failure") }
|
295
|
+
sample("some sample") { expect(subject.get("tags")).not_to include("failure") }
|
296
296
|
end
|
297
297
|
|
298
298
|
end
|
@@ -300,47 +300,47 @@ describe "conditionals in filter" do
|
|
300
300
|
describe "value as an expression" do
|
301
301
|
# testing that a field has a value should be true.
|
302
302
|
conditional "[message]" do
|
303
|
-
sample("apple") { expect(subject
|
304
|
-
sample("sample") { expect(subject
|
305
|
-
sample("some sample") { expect(subject
|
303
|
+
sample("apple") { expect(subject.get("tags")).to include("success") }
|
304
|
+
sample("sample") { expect(subject.get("tags")).to include("success") }
|
305
|
+
sample("some sample") { expect(subject.get("tags")).to include("success") }
|
306
306
|
end
|
307
307
|
|
308
308
|
# testing that a missing field has a value should be false.
|
309
309
|
conditional "[missing]" do
|
310
|
-
sample("apple") { expect(subject
|
311
|
-
sample("sample") { expect(subject
|
312
|
-
sample("some sample") { expect(subject
|
310
|
+
sample("apple") { expect(subject.get("tags")).to include("failure") }
|
311
|
+
sample("sample") { expect(subject.get("tags")).to include("failure") }
|
312
|
+
sample("some sample") { expect(subject.get("tags")).to include("failure") }
|
313
313
|
end
|
314
314
|
end
|
315
315
|
|
316
316
|
describe "logic operators" do
|
317
317
|
describe "and" do
|
318
318
|
conditional "[message] and [message]" do
|
319
|
-
sample("whatever") { expect(subject
|
319
|
+
sample("whatever") { expect(subject.get("tags")).to include("success") }
|
320
320
|
end
|
321
321
|
conditional "[message] and ![message]" do
|
322
|
-
sample("whatever") { expect(subject
|
322
|
+
sample("whatever") { expect(subject.get("tags")).to include("failure") }
|
323
323
|
end
|
324
324
|
conditional "![message] and [message]" do
|
325
|
-
sample("whatever") { expect(subject
|
325
|
+
sample("whatever") { expect(subject.get("tags")).to include("failure") }
|
326
326
|
end
|
327
327
|
conditional "![message] and ![message]" do
|
328
|
-
sample("whatever") { expect(subject
|
328
|
+
sample("whatever") { expect(subject.get("tags")).to include("failure") }
|
329
329
|
end
|
330
330
|
end
|
331
331
|
|
332
332
|
describe "or" do
|
333
333
|
conditional "[message] or [message]" do
|
334
|
-
sample("whatever") { expect(subject
|
334
|
+
sample("whatever") { expect(subject.get("tags")).to include("success") }
|
335
335
|
end
|
336
336
|
conditional "[message] or ![message]" do
|
337
|
-
sample("whatever") { expect(subject
|
337
|
+
sample("whatever") { expect(subject.get("tags")).to include("success") }
|
338
338
|
end
|
339
339
|
conditional "![message] or [message]" do
|
340
|
-
sample("whatever") { expect(subject
|
340
|
+
sample("whatever") { expect(subject.get("tags")).to include("success") }
|
341
341
|
end
|
342
342
|
conditional "![message] or ![message]" do
|
343
|
-
sample("whatever") { expect(subject
|
343
|
+
sample("whatever") { expect(subject.get("tags")).to include("failure") }
|
344
344
|
end
|
345
345
|
end
|
346
346
|
end
|
@@ -348,19 +348,19 @@ describe "conditionals in filter" do
|
|
348
348
|
describe "field references" do
|
349
349
|
conditional "[field with space]" do
|
350
350
|
sample("field with space" => "hurray") do
|
351
|
-
expect(subject
|
351
|
+
expect(subject.get("tags")).to include("success")
|
352
352
|
end
|
353
353
|
end
|
354
354
|
|
355
355
|
conditional "[field with space] == 'hurray'" do
|
356
356
|
sample("field with space" => "hurray") do
|
357
|
-
expect(subject
|
357
|
+
expect(subject.get("tags")).to include("success")
|
358
358
|
end
|
359
359
|
end
|
360
360
|
|
361
361
|
conditional "[nested field][reference with][some spaces] == 'hurray'" do
|
362
362
|
sample({"nested field" => { "reference with" => { "some spaces" => "hurray" } } }) do
|
363
|
-
expect(subject
|
363
|
+
expect(subject.get("tags")).to include("success")
|
364
364
|
end
|
365
365
|
end
|
366
366
|
end
|
@@ -385,13 +385,13 @@ describe "conditionals in filter" do
|
|
385
385
|
expect(subject).to be_an(Array)
|
386
386
|
expect(subject.length).to eq(2)
|
387
387
|
|
388
|
-
expect(subject[0]
|
389
|
-
expect(subject[0]
|
390
|
-
expect(subject[0]
|
388
|
+
expect(subject[0].get("type")).to eq("original")
|
389
|
+
expect(subject[0].get("cond1")).to eq("true")
|
390
|
+
expect(subject[0].get("cond2")).to eq(nil)
|
391
391
|
|
392
|
-
expect(subject[1]
|
393
|
-
# expect(subject[1]
|
394
|
-
# expect(subject[1]
|
392
|
+
expect(subject[1].get("type")).to eq("clone")
|
393
|
+
# expect(subject[1].get("cond1")).to eq(nil)
|
394
|
+
# expect(subject[1].get("cond2")).to eq("true")
|
395
395
|
end
|
396
396
|
end
|
397
397
|
|
@@ -413,16 +413,16 @@ describe "conditionals in filter" do
|
|
413
413
|
|
414
414
|
sample({"type" => "original"}) do
|
415
415
|
# puts subject.inspect
|
416
|
-
expect(subject[0]
|
417
|
-
expect(subject[0]
|
416
|
+
expect(subject[0].get("cond1")).to eq(nil)
|
417
|
+
expect(subject[0].get("cond2")).to eq(nil)
|
418
418
|
|
419
|
-
expect(subject[1]
|
420
|
-
expect(subject[1]
|
421
|
-
expect(subject[1]
|
419
|
+
expect(subject[1].get("type")).to eq("clone1")
|
420
|
+
expect(subject[1].get("cond1")).to eq("true")
|
421
|
+
expect(subject[1].get("cond2")).to eq(nil)
|
422
422
|
|
423
|
-
expect(subject[2]
|
424
|
-
expect(subject[2]
|
425
|
-
expect(subject[2]
|
423
|
+
expect(subject[2].get("type")).to eq("clone2")
|
424
|
+
expect(subject[2].get("cond1")).to eq(nil)
|
425
|
+
expect(subject[2].get("cond2")).to eq("true")
|
426
426
|
end
|
427
427
|
end
|
428
428
|
|
data/spec/logstash/agent_spec.rb
CHANGED
@@ -7,8 +7,14 @@ require_relative "../support/mocks_classes"
|
|
7
7
|
describe LogStash::Agent do
|
8
8
|
|
9
9
|
let(:logger) { double("logger") }
|
10
|
-
let(:
|
11
|
-
|
10
|
+
let(:agent_settings) { LogStash::SETTINGS }
|
11
|
+
let(:agent_args) { {} }
|
12
|
+
let(:pipeline_settings) { agent_settings.clone }
|
13
|
+
let(:pipeline_args) { {} }
|
14
|
+
let(:config_file) { Stud::Temporary.pathname }
|
15
|
+
let(:config_file_txt) { "input { generator { count => 100000 } } output { }" }
|
16
|
+
|
17
|
+
subject { LogStash::Agent.new(agent_settings) }
|
12
18
|
|
13
19
|
before :each do
|
14
20
|
[:info, :warn, :error, :fatal, :debug].each do |level|
|
@@ -17,46 +23,63 @@ describe LogStash::Agent do
|
|
17
23
|
[:info?, :warn?, :error?, :fatal?, :debug?].each do |level|
|
18
24
|
allow(logger).to receive(level)
|
19
25
|
end
|
26
|
+
File.open(config_file, "w") { |f| f.puts config_file_txt }
|
27
|
+
agent_args.each do |key, value|
|
28
|
+
agent_settings.set(key, value)
|
29
|
+
pipeline_settings.set(key, value)
|
30
|
+
end
|
31
|
+
pipeline_args.each do |key, value|
|
32
|
+
pipeline_settings.set(key, value)
|
33
|
+
end
|
34
|
+
#subject.logger = logger
|
35
|
+
end
|
36
|
+
|
37
|
+
after :each do
|
38
|
+
LogStash::SETTINGS.reset
|
39
|
+
File.unlink(config_file)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "fallback to hostname when no name is provided" do
|
43
|
+
expect(LogStash::Agent.new.node_name).to eq(Socket.gethostname)
|
20
44
|
end
|
21
45
|
|
22
46
|
describe "register_pipeline" do
|
23
47
|
let(:pipeline_id) { "main" }
|
24
48
|
let(:config_string) { "input { } filter { } output { }" }
|
25
|
-
let(:
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
:reload_interval => 0.01
|
34
|
-
} }
|
49
|
+
let(:agent_args) do
|
50
|
+
{
|
51
|
+
"config.string" => config_string,
|
52
|
+
"config.reload.automatic" => true,
|
53
|
+
"config.reload.interval" => 0.01,
|
54
|
+
"pipeline.workers" => 4,
|
55
|
+
}
|
56
|
+
end
|
35
57
|
|
36
58
|
it "should delegate settings to new pipeline" do
|
37
|
-
expect(LogStash::Pipeline).to receive(:new)
|
38
|
-
|
59
|
+
expect(LogStash::Pipeline).to receive(:new) do |arg1, arg2|
|
60
|
+
expect(arg1).to eq(config_string)
|
61
|
+
expect(arg2.to_hash).to include(agent_args)
|
62
|
+
end
|
63
|
+
subject.register_pipeline(pipeline_id, agent_settings)
|
39
64
|
end
|
40
65
|
end
|
41
66
|
|
42
67
|
describe "#execute" do
|
43
|
-
let(:
|
44
|
-
let(:config_file) { Stud::Temporary.pathname }
|
68
|
+
let(:config_file_txt) { "input { generator { count => 100000 } } output { }" }
|
45
69
|
|
46
70
|
before :each do
|
47
71
|
allow(subject).to receive(:start_webserver).and_return(false)
|
48
72
|
allow(subject).to receive(:stop_webserver).and_return(false)
|
49
|
-
File.open(config_file, "w") { |f| f.puts sample_config }
|
50
|
-
end
|
51
|
-
|
52
|
-
after :each do
|
53
|
-
File.unlink(config_file)
|
54
73
|
end
|
55
74
|
|
56
75
|
context "when auto_reload is false" do
|
57
|
-
let(:agent_args)
|
76
|
+
let(:agent_args) do
|
77
|
+
{
|
78
|
+
"config.reload.automatic" => false,
|
79
|
+
"path.config" => config_file
|
80
|
+
}
|
81
|
+
end
|
58
82
|
let(:pipeline_id) { "main" }
|
59
|
-
let(:pipeline_settings) { { :config_path => config_file } }
|
60
83
|
|
61
84
|
before(:each) do
|
62
85
|
subject.register_pipeline(pipeline_id, pipeline_settings)
|
@@ -75,6 +98,7 @@ describe LogStash::Agent do
|
|
75
98
|
sleep 0.1
|
76
99
|
Stud.stop!(t)
|
77
100
|
t.join
|
101
|
+
subject.shutdown
|
78
102
|
end
|
79
103
|
end
|
80
104
|
|
@@ -91,6 +115,7 @@ describe LogStash::Agent do
|
|
91
115
|
sleep 0.1
|
92
116
|
Stud.stop!(t)
|
93
117
|
t.join
|
118
|
+
subject.shutdown
|
94
119
|
end
|
95
120
|
end
|
96
121
|
|
@@ -106,15 +131,22 @@ describe LogStash::Agent do
|
|
106
131
|
sleep 0.1
|
107
132
|
Stud.stop!(t)
|
108
133
|
t.join
|
134
|
+
|
135
|
+
subject.shutdown
|
109
136
|
end
|
110
137
|
end
|
111
138
|
end
|
112
139
|
end
|
113
140
|
|
114
141
|
context "when auto_reload is true" do
|
115
|
-
let(:agent_args)
|
142
|
+
let(:agent_args) do
|
143
|
+
{
|
144
|
+
"config.reload.automatic" => true,
|
145
|
+
"config.reload.interval" => 0.01,
|
146
|
+
"path.config" => config_file,
|
147
|
+
}
|
148
|
+
end
|
116
149
|
let(:pipeline_id) { "main" }
|
117
|
-
let(:pipeline_settings) { { :config_path => config_file } }
|
118
150
|
|
119
151
|
before(:each) do
|
120
152
|
subject.register_pipeline(pipeline_id, pipeline_settings)
|
@@ -129,6 +161,7 @@ describe LogStash::Agent do
|
|
129
161
|
sleep 0.1
|
130
162
|
Stud.stop!(t)
|
131
163
|
t.join
|
164
|
+
subject.shutdown
|
132
165
|
end
|
133
166
|
end
|
134
167
|
|
@@ -144,6 +177,7 @@ describe LogStash::Agent do
|
|
144
177
|
sleep 0.1
|
145
178
|
Stud.stop!(t)
|
146
179
|
t.join
|
180
|
+
subject.shutdown
|
147
181
|
end
|
148
182
|
end
|
149
183
|
|
@@ -158,6 +192,7 @@ describe LogStash::Agent do
|
|
158
192
|
sleep 0.1
|
159
193
|
Stud.stop!(t)
|
160
194
|
t.join
|
195
|
+
subject.shutdown
|
161
196
|
end
|
162
197
|
end
|
163
198
|
end
|
@@ -168,9 +203,9 @@ describe LogStash::Agent do
|
|
168
203
|
let(:pipeline_id) { "main" }
|
169
204
|
let(:first_pipeline_config) { "input { } filter { } output { }" }
|
170
205
|
let(:second_pipeline_config) { "input { generator {} } filter { } output { }" }
|
171
|
-
let(:
|
172
|
-
|
173
|
-
|
206
|
+
let(:pipeline_args) { {
|
207
|
+
"config.string" => first_pipeline_config,
|
208
|
+
"pipeline.workers" => 4
|
174
209
|
} }
|
175
210
|
|
176
211
|
before(:each) do
|
@@ -194,30 +229,18 @@ describe LogStash::Agent do
|
|
194
229
|
end
|
195
230
|
|
196
231
|
describe "Environment Variables In Configs" do
|
232
|
+
let(:pipeline_config) { "input { generator { message => '${FOO}-bar' } } filter { } output { }" }
|
197
233
|
let(:agent_args) { {
|
198
|
-
|
199
|
-
|
200
|
-
|
234
|
+
"config.reload.automatic" => false,
|
235
|
+
"config.reload.interval" => 0.01,
|
236
|
+
"config.string" => pipeline_config
|
201
237
|
} }
|
202
238
|
let(:pipeline_id) { "main" }
|
203
|
-
let(:pipeline_config) { "input { generator { message => '${FOO}-bar' } } filter { } output { }" }
|
204
|
-
let(:pipeline_settings) { {
|
205
|
-
:config_string => pipeline_config,
|
206
|
-
} }
|
207
239
|
|
208
|
-
context "
|
209
|
-
it "does not interpolate environment variables" do
|
210
|
-
expect(subject).to receive(:fetch_config).and_return(pipeline_config)
|
211
|
-
subject.register_pipeline(pipeline_id, pipeline_settings)
|
212
|
-
expect(subject.pipelines[pipeline_id].inputs.first.message).to eq("${FOO}-bar")
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
context "when allow_env is true" do
|
240
|
+
context "environment variable templating" do
|
217
241
|
before :each do
|
218
242
|
@foo_content = ENV["FOO"]
|
219
243
|
ENV["FOO"] = "foo"
|
220
|
-
pipeline_settings.merge!(:allow_env => true)
|
221
244
|
end
|
222
245
|
|
223
246
|
after :each do
|
@@ -225,7 +248,7 @@ describe LogStash::Agent do
|
|
225
248
|
end
|
226
249
|
|
227
250
|
it "doesn't upgrade the state" do
|
228
|
-
|
251
|
+
allow(subject).to receive(:fetch_config).and_return(pipeline_config)
|
229
252
|
subject.register_pipeline(pipeline_id, pipeline_settings)
|
230
253
|
expect(subject.pipelines[pipeline_id].inputs.first.message).to eq("foo-bar")
|
231
254
|
end
|
@@ -235,9 +258,9 @@ describe LogStash::Agent do
|
|
235
258
|
describe "#upgrade_pipeline" do
|
236
259
|
let(:pipeline_id) { "main" }
|
237
260
|
let(:pipeline_config) { "input { } filter { } output { }" }
|
238
|
-
let(:
|
239
|
-
|
240
|
-
|
261
|
+
let(:pipeline_args) { {
|
262
|
+
"config.string" => pipeline_config,
|
263
|
+
"pipeline.workers" => 4
|
241
264
|
} }
|
242
265
|
let(:new_pipeline_config) { "input { generator {} } output { }" }
|
243
266
|
|
@@ -284,23 +307,12 @@ describe LogStash::Agent do
|
|
284
307
|
end
|
285
308
|
|
286
309
|
describe "#fetch_config" do
|
287
|
-
let(:file_config) { "input { generator { count => 100 } } output { }" }
|
288
310
|
let(:cli_config) { "filter { drop { } } " }
|
289
|
-
let(:
|
290
|
-
let(:agent_args) { { :logger => logger, :config_string => "filter { drop { } } ", :config_path => tmp_config_path } }
|
291
|
-
|
292
|
-
before :each do
|
293
|
-
IO.write(tmp_config_path, file_config)
|
294
|
-
end
|
295
|
-
|
296
|
-
after :each do
|
297
|
-
File.unlink(tmp_config_path)
|
298
|
-
end
|
311
|
+
let(:agent_args) { { "config.string" => cli_config, "path.config" => config_file } }
|
299
312
|
|
300
313
|
it "should join the config string and config path content" do
|
301
|
-
|
302
|
-
fetched_config
|
303
|
-
expect(fetched_config.strip).to eq(cli_config + IO.read(tmp_config_path))
|
314
|
+
fetched_config = subject.send(:fetch_config, agent_settings)
|
315
|
+
expect(fetched_config.strip).to eq(cli_config + IO.read(config_file).strip)
|
304
316
|
end
|
305
317
|
end
|
306
318
|
|
@@ -328,13 +340,17 @@ describe LogStash::Agent do
|
|
328
340
|
f.path
|
329
341
|
end
|
330
342
|
let(:interval) { 0.2 }
|
331
|
-
let(:
|
332
|
-
|
343
|
+
let(:pipeline_args) do
|
344
|
+
{
|
345
|
+
"pipeline.workers" => 4,
|
346
|
+
"path.config" => config_path
|
347
|
+
}
|
348
|
+
end
|
333
349
|
|
334
350
|
let(:agent_args) do
|
335
|
-
super.merge({
|
336
|
-
|
337
|
-
|
351
|
+
super.merge({ "config.reload.automatic" => true,
|
352
|
+
"config.reload.interval" => interval,
|
353
|
+
"metric.collect" => true })
|
338
354
|
end
|
339
355
|
|
340
356
|
before :each do
|
@@ -352,6 +368,7 @@ describe LogStash::Agent do
|
|
352
368
|
end
|
353
369
|
|
354
370
|
after :each do
|
371
|
+
subject.shutdown
|
355
372
|
Stud.stop!(@t)
|
356
373
|
@t.join
|
357
374
|
end
|