logstash-input-http_poller 5.2.0 → 5.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile +2 -0
- data/lib/logstash/inputs/http_poller.rb +7 -5
- data/logstash-input-http_poller.gemspec +2 -3
- data/spec/inputs/http_poller_spec.rb +64 -65
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffa63b5111349fab5d81dbc52cc005ab2ab6ed296aab3135859d941b3fd32c4b
|
4
|
+
data.tar.gz: 6ab7912818139b2c9595fe7b0797f0c4e02bb9af2722a32e5af1c9ca8c887536
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2093f0da0658436437293283a8425e2e497d2bb1e17a9b3910dff3e2ea5bf8a1ce546225abf4f97f24866abd812d0078e0c479ee7c3ef401ee3c3ec611002c21
|
7
|
+
data.tar.gz: 24210d613caee8ed465816b9865d75ad0547d8e81f5160858742d77bbe4ddef46284b798b4c1581bc706f0267f4316718318995dc5dbb3647c123d407d7fdf08
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 5.2.1
|
2
|
+
- Deps: unpin rufus-scheduler dependency [#130](https://github.com/logstash-plugins/logstash-input-http_poller/pull/130)
|
3
|
+
|
1
4
|
## 5.2.0
|
2
5
|
- Feat: support ssl_verification_mode option [#131](https://github.com/logstash-plugins/logstash-input-http_poller/pull/131)
|
3
6
|
|
data/Gemfile
CHANGED
@@ -9,3 +9,5 @@ if Dir.exist?(logstash_path) && use_logstash_source
|
|
9
9
|
gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
|
10
10
|
gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
|
11
11
|
end
|
12
|
+
|
13
|
+
gem 'rufus-scheduler', ENV['RUFUS_SCHEDULER_VERSION'] if ENV['RUFUS_SCHEDULER_VERSION']
|
@@ -55,9 +55,12 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
55
55
|
setup_requests!
|
56
56
|
end
|
57
57
|
|
58
|
+
# @overload
|
58
59
|
def stop
|
59
|
-
|
60
|
-
|
60
|
+
if @scheduler
|
61
|
+
@scheduler.shutdown # on newer Rufus (3.8) this joins on the scheduler thread
|
62
|
+
end
|
63
|
+
# TODO implement client.close as we as releasing it's pooled resources!
|
61
64
|
end
|
62
65
|
|
63
66
|
private
|
@@ -163,16 +166,15 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
163
166
|
#schedule hash must contain exactly one of the allowed keys
|
164
167
|
msg_invalid_schedule = "Invalid config. schedule hash must contain " +
|
165
168
|
"exactly one of the following keys - cron, at, every or in"
|
166
|
-
raise Logstash::ConfigurationError, msg_invalid_schedule if @schedule.keys.length !=1
|
169
|
+
raise Logstash::ConfigurationError, msg_invalid_schedule if @schedule.keys.length != 1
|
167
170
|
schedule_type = @schedule.keys.first
|
168
171
|
schedule_value = @schedule[schedule_type]
|
169
172
|
raise LogStash::ConfigurationError, msg_invalid_schedule unless Schedule_types.include?(schedule_type)
|
170
173
|
|
171
174
|
@scheduler = Rufus::Scheduler.new(:max_work_threads => 1)
|
172
|
-
#as of v3.0.9, :first_in => :now doesn't work. Use the following workaround instead
|
173
175
|
opts = schedule_type == "every" ? { :first_in => 0.01 } : {}
|
174
176
|
@scheduler.send(schedule_type, schedule_value, opts) { run_once(queue) }
|
175
|
-
@scheduler.join
|
177
|
+
@scheduler.thread.join # due newer rufus (3.8) doing a blocking operation on scheduler.join
|
176
178
|
end
|
177
179
|
|
178
180
|
def run_once(queue)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-http_poller'
|
3
|
-
s.version = '5.2.
|
3
|
+
s.version = '5.2.1'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Decodes the output of an HTTP API into events"
|
6
6
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
@@ -21,8 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
|
22
22
|
s.add_runtime_dependency 'logstash-codec-plain'
|
23
23
|
s.add_runtime_dependency "logstash-mixin-http_client", ">= 7.1.0"
|
24
|
-
s.add_runtime_dependency '
|
25
|
-
s.add_runtime_dependency 'rufus-scheduler', "~>3.0.9"
|
24
|
+
s.add_runtime_dependency 'rufus-scheduler', ">= 3.0.9"
|
26
25
|
s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.3'
|
27
26
|
s.add_runtime_dependency 'logstash-mixin-event_support', '~> 1.0', '>= 1.0.1'
|
28
27
|
s.add_runtime_dependency 'logstash-mixin-validator_support', '~> 1.0'
|
@@ -25,18 +25,19 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
25
25
|
"schedule" => default_schedule,
|
26
26
|
"urls" => default_urls,
|
27
27
|
"codec" => "json",
|
28
|
-
"metadata_target" => metadata_target
|
28
|
+
"metadata_target" => metadata_target,
|
29
|
+
"pool_max" => 3, "pool_max_per_route" => 1, 'keepalive' => false
|
29
30
|
}
|
30
31
|
}
|
31
|
-
let(:
|
32
|
+
let(:opts) { default_opts }
|
32
33
|
|
34
|
+
subject(:plugin) { described_class.new(opts) }
|
33
35
|
|
34
36
|
describe "instances" do
|
35
|
-
subject {
|
37
|
+
subject { described_class.new(default_opts) }
|
36
38
|
|
37
|
-
before
|
38
|
-
|
39
|
-
end
|
39
|
+
before { subject.register }
|
40
|
+
after { subject.stop }
|
40
41
|
|
41
42
|
describe "#run" do
|
42
43
|
it "should setup a scheduler" do
|
@@ -189,22 +190,21 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
189
190
|
"metadata_target" => metadata_target
|
190
191
|
}
|
191
192
|
}
|
192
|
-
|
193
|
-
|
194
|
-
instance.register
|
193
|
+
|
194
|
+
before do
|
195
195
|
Timecop.travel(Time.new(2000,1,1,0,0,0,'+00:00'))
|
196
196
|
Timecop.scale(60)
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
end
|
201
|
-
sleep 3
|
202
|
-
instance.stop
|
203
|
-
runner.kill
|
204
|
-
runner.join
|
205
|
-
expect(queue.size).to eq(2)
|
197
|
+
end
|
198
|
+
|
199
|
+
after do
|
206
200
|
Timecop.return
|
207
201
|
end
|
202
|
+
|
203
|
+
it "should run at the schedule" do
|
204
|
+
run_plugin_and_yield_queue(plugin, sleep: 3) do |queue|
|
205
|
+
try(5) { expect(queue.size).to be >= 2 }
|
206
|
+
end
|
207
|
+
end
|
208
208
|
end
|
209
209
|
|
210
210
|
context "given 'at' expression" do
|
@@ -216,22 +216,21 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
216
216
|
"metadata_target" => metadata_target
|
217
217
|
}
|
218
218
|
}
|
219
|
-
|
220
|
-
|
221
|
-
instance.register
|
219
|
+
|
220
|
+
before do
|
222
221
|
Timecop.travel(Time.new(2000,1,1,0,0,0,'+00:00'))
|
223
|
-
Timecop.scale(60 * 5)
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
end
|
228
|
-
sleep 2
|
229
|
-
instance.stop
|
230
|
-
runner.kill
|
231
|
-
runner.join
|
232
|
-
expect(queue.size).to eq(1)
|
222
|
+
Timecop.scale (60 * 5) / 2
|
223
|
+
end
|
224
|
+
|
225
|
+
after do
|
233
226
|
Timecop.return
|
234
227
|
end
|
228
|
+
|
229
|
+
it "should run at the schedule" do
|
230
|
+
run_plugin_and_yield_queue(plugin, sleep: 2) do |queue|
|
231
|
+
try(5) { expect(queue.size).to eq(1) }
|
232
|
+
end
|
233
|
+
end
|
235
234
|
end
|
236
235
|
|
237
236
|
context "given 'every' expression" do
|
@@ -244,20 +243,12 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
244
243
|
}
|
245
244
|
}
|
246
245
|
it "should run at the schedule" do
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
246
|
+
run_plugin_and_yield_queue(plugin, sleep: 5) do |queue|
|
247
|
+
#T 0123456
|
248
|
+
#events x x x x
|
249
|
+
#expects 3 events at T=5
|
250
|
+
try(5) { expect(queue.size).to be_between(2, 3) }
|
252
251
|
end
|
253
|
-
#T 0123456
|
254
|
-
#events x x x x
|
255
|
-
#expects 3 events at T=5
|
256
|
-
sleep 5
|
257
|
-
instance.stop
|
258
|
-
runner.kill
|
259
|
-
runner.join
|
260
|
-
expect(queue.size).to be_between(2, 3)
|
261
252
|
end
|
262
253
|
end
|
263
254
|
|
@@ -271,21 +262,28 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
271
262
|
}
|
272
263
|
}
|
273
264
|
it "should run at the schedule" do
|
274
|
-
|
275
|
-
|
276
|
-
queue = Queue.new
|
277
|
-
runner = Thread.new do
|
278
|
-
instance.run(queue)
|
265
|
+
run_plugin_and_yield_queue(plugin, sleep: 2.5) do |queue|
|
266
|
+
try(5) { expect(queue.size).to eq(1) }
|
279
267
|
end
|
280
|
-
sleep 3
|
281
|
-
instance.stop
|
282
|
-
runner.kill
|
283
|
-
runner.join
|
284
|
-
expect(queue.size).to eq(1)
|
285
268
|
end
|
286
269
|
end
|
287
270
|
end
|
288
271
|
|
272
|
+
def run_plugin_and_yield_queue(plugin, sleep: nil)
|
273
|
+
plugin.register
|
274
|
+
queue = Queue.new
|
275
|
+
begin
|
276
|
+
runner = Thread.new do
|
277
|
+
plugin.run(queue)
|
278
|
+
end
|
279
|
+
sleep(sleep) if sleep
|
280
|
+
yield(queue)
|
281
|
+
ensure
|
282
|
+
plugin.stop
|
283
|
+
runner.join if runner
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
289
287
|
describe "events", :ecs_compatibility_support, :aggregate_failures do
|
290
288
|
ecs_compatibility_matrix(:disabled, :v1, :v8 => :v1) do |ecs_select|
|
291
289
|
before do
|
@@ -339,6 +337,8 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
339
337
|
event # materialize the subject
|
340
338
|
end
|
341
339
|
|
340
|
+
after { poller.stop }
|
341
|
+
|
342
342
|
it "should enqueue a message" do
|
343
343
|
expect(event).to be_a(LogStash::Event)
|
344
344
|
end
|
@@ -399,9 +399,6 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
399
399
|
let(:payload) { {"a" => 2, "hello" => ["a", "b", "c"]} }
|
400
400
|
let(:response_body) { LogStash::Json.dump(payload) }
|
401
401
|
let(:opts) { default_opts }
|
402
|
-
let(:instance) {
|
403
|
-
klass.new(opts)
|
404
|
-
}
|
405
402
|
let(:name) { default_name }
|
406
403
|
let(:url) { default_url }
|
407
404
|
let(:code) { 202 }
|
@@ -411,14 +408,14 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
411
408
|
}
|
412
409
|
|
413
410
|
before do
|
414
|
-
|
411
|
+
plugin.register
|
415
412
|
u = url.is_a?(Hash) ? url["url"] : url # handle both complex specs and simple string URLs
|
416
|
-
|
413
|
+
plugin.client.stub(u,
|
417
414
|
:body => response_body,
|
418
415
|
:code => code
|
419
416
|
)
|
420
|
-
allow(
|
421
|
-
|
417
|
+
allow(plugin).to receive(:decorate)
|
418
|
+
plugin.send(:run_once, queue)
|
422
419
|
end
|
423
420
|
|
424
421
|
it "should have a matching message" do
|
@@ -426,7 +423,7 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
426
423
|
end
|
427
424
|
|
428
425
|
it "should decorate the event" do
|
429
|
-
expect(
|
426
|
+
expect(plugin).to have_received(:decorate).once
|
430
427
|
end
|
431
428
|
|
432
429
|
include_examples("matching metadata")
|
@@ -434,7 +431,7 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
434
431
|
context "with an empty body" do
|
435
432
|
let(:response_body) { "" }
|
436
433
|
it "should return an empty event" do
|
437
|
-
|
434
|
+
plugin.send(:run_once, queue)
|
438
435
|
headers_field = ecs_select[disabled: "[#{metadata_target}][response_headers]",
|
439
436
|
v1: "[#{metadata_target}][input][http_poller][response][headers]"]
|
440
437
|
expect(event.get("#{headers_field}[content-length]")).to eql("0")
|
@@ -449,7 +446,7 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
449
446
|
}
|
450
447
|
|
451
448
|
it "should not have any metadata on the event" do
|
452
|
-
|
449
|
+
plugin.send(:run_once, queue)
|
453
450
|
expect(event.get(metadata_target)).to be_nil
|
454
451
|
end
|
455
452
|
end
|
@@ -555,6 +552,8 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
555
552
|
|
556
553
|
describe "stopping" do
|
557
554
|
let(:config) { default_opts }
|
558
|
-
it_behaves_like "an interruptible input plugin"
|
555
|
+
it_behaves_like "an interruptible input plugin" do
|
556
|
+
let(:allowed_lag) { 10 } # CI: wait till scheduler shuts down
|
557
|
+
end
|
559
558
|
end
|
560
559
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-http_poller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.
|
4
|
+
version: 5.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-02-
|
12
|
+
date: 2022-02-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,21 +62,7 @@ dependencies:
|
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: 0.0.22
|
68
|
-
name: stud
|
69
|
-
prerelease: false
|
70
|
-
type: :runtime
|
71
|
-
version_requirements: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 0.0.22
|
76
|
-
- !ruby/object:Gem::Dependency
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
65
|
+
- - ">="
|
80
66
|
- !ruby/object:Gem::Version
|
81
67
|
version: 3.0.9
|
82
68
|
name: rufus-scheduler
|
@@ -84,7 +70,7 @@ dependencies:
|
|
84
70
|
type: :runtime
|
85
71
|
version_requirements: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- - "
|
73
|
+
- - ">="
|
88
74
|
- !ruby/object:Gem::Version
|
89
75
|
version: 3.0.9
|
90
76
|
- !ruby/object:Gem::Dependency
|