logstash-input-elasticsearch 4.11.0 → 4.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e0b94cdf348e1d25d3007f0d98637e11fea82606ac8116962f999d8743cd0f3
4
- data.tar.gz: 82f489d3d852073644e488e0ced799d676f33e2c496d2353cbad911e87311b21
3
+ metadata.gz: 2c8dcf80b30079fa7b38d9c8cb0a11127bc896af3c5efe9e10b92023a74d0034
4
+ data.tar.gz: b6f40095bd604f4770529c621397c86a569494a973aa32dc13d978f68d49ac44
5
5
  SHA512:
6
- metadata.gz: 9be021ff84622606a6e3959055e4180cad9976dece9a690d732c289186243de051c5493d2c513e665c4dbdc5cdfbd68a42dcea80b4bb2f182d44b9b807fd5a7d
7
- data.tar.gz: 5344d73f5b88542f03d045f45a630eb36d031f09fa2a79cfd50db4b2703350f91191c500e4c86adc26cb04d5c4ec4594c13eb2e7581edbe41d8e94866e077026
6
+ metadata.gz: 9ff54e3056fedf78f80fa77d11ccb16f267675ff091d0c8f09262368272ec9d063064459acfc5645764f08a066692215d2713e0b0e100c502ad5488873ba549a
7
+ data.tar.gz: 7d315f02bdce91ce2f74fa27c85f9962bcdf3548a97a1018d577c480777e370f503301d4482aa28a2a8b68d932f8c2fdde9a6e7f576b6210ded7e43cad692dce
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 4.12.0
2
+ - Feat: Update Elasticsearch client to 7.14.0 [#157](https://github.com/logstash-plugins/logstash-filter-elasticsearch/pull/157)
3
+
1
4
  ## 4.11.0
2
5
  - Feat: add user-agent header passed to the Elasticsearch HTTP connection [#158](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/158)
3
6
 
@@ -240,6 +240,8 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
240
240
  :transport_class => ::Elasticsearch::Transport::Transport::HTTP::Manticore,
241
241
  :ssl => ssl_options
242
242
  )
243
+ test_connection!
244
+ @client
243
245
  end
244
246
 
245
247
 
@@ -473,6 +475,12 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
473
475
  # @private used by unit specs
474
476
  attr_reader :client
475
477
 
478
+ def test_connection!
479
+ @client.ping
480
+ rescue Elasticsearch::UnsupportedProductError
481
+ raise LogStash::ConfigurationError, "Could not connect to a compatible version of Elasticsearch"
482
+ end
483
+
476
484
  module URIOrEmptyValidator
477
485
  ##
478
486
  # @override to provide :uri_or_empty validator
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-elasticsearch'
4
- s.version = '4.11.0'
4
+ s.version = '4.12.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Reads query results from an Elasticsearch cluster"
7
7
  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"
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_runtime_dependency 'logstash-mixin-event_support', '~> 1.0'
26
26
  s.add_runtime_dependency "logstash-mixin-validator_support", '~> 1.0'
27
27
 
28
- s.add_runtime_dependency 'elasticsearch', '>= 5.0.5' # LS >= 6.7 and < 7.14 all used version 5.0.5
28
+ s.add_runtime_dependency 'elasticsearch', '>= 7.14.0' # LS >= 6.7 and < 7.14 all used version 5.0.5
29
29
 
30
30
  s.add_runtime_dependency 'tzinfo'
31
31
  s.add_runtime_dependency 'tzinfo-data'
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.add_runtime_dependency 'manticore', ">= 0.7.1"
34
34
 
35
35
  s.add_development_dependency 'logstash-codec-plain'
36
- s.add_development_dependency 'faraday', "~> 0.15.4"
36
+ s.add_development_dependency 'faraday', "~> 1"
37
37
  s.add_development_dependency 'logstash-devutils'
38
38
  s.add_development_dependency 'timecop'
39
39
  s.add_development_dependency 'cabin', ['~> 0.6']
@@ -18,6 +18,34 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
18
18
  let(:plugin) { described_class.new(config) }
19
19
  let(:queue) { Queue.new }
20
20
 
21
+ before(:each) do
22
+ Elasticsearch::Client.send(:define_method, :ping) { } # define no-action ping method
23
+ end
24
+
25
+ context "register" do
26
+ let(:config) do
27
+ {
28
+ "schedule" => "* * * * * UTC"
29
+ }
30
+ end
31
+
32
+ context "against authentic Elasticsearch" do
33
+ it "should not raise an exception" do
34
+ expect { plugin.register }.to_not raise_error
35
+ end
36
+ end
37
+
38
+ context "against not authentic Elasticsearch" do
39
+ before(:each) do
40
+ Elasticsearch::Client.send(:define_method, :ping) { raise Elasticsearch::UnsupportedProductError.new("Fake error") } # define error ping method
41
+ end
42
+
43
+ it "should raise ConfigurationError" do
44
+ expect { plugin.register }.to raise_error(LogStash::ConfigurationError)
45
+ end
46
+ end
47
+ end
48
+
21
49
  it_behaves_like "an interruptible input plugin" do
22
50
  let(:esclient) { double("elasticsearch-client") }
23
51
  let(:config) do
@@ -38,6 +66,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
38
66
  allow(esclient).to receive(:search) { { "hits" => { "hits" => [hit] } } }
39
67
  allow(esclient).to receive(:scroll) { { "hits" => { "hits" => [hit] } } }
40
68
  allow(esclient).to receive(:clear_scroll).and_return(nil)
69
+ allow(esclient).to receive(:ping)
41
70
  end
42
71
  end
43
72
 
@@ -96,6 +125,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
96
125
  expect(client).to receive(:search).with(any_args).and_return(mock_response)
97
126
  expect(client).to receive(:scroll).with({ :body => { :scroll_id => "cXVlcnlUaGVuRmV0Y2g" }, :scroll=> "1m" }).and_return(mock_scroll_response)
98
127
  expect(client).to receive(:clear_scroll).and_return(nil)
128
+ expect(client).to receive(:ping)
99
129
  end
100
130
 
101
131
  it 'creates the events from the hits' do
@@ -311,6 +341,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
311
341
  expect(client).to receive(:search).with(hash_including(:body => slice0_query)).and_return(slice0_response0)
312
342
  expect(client).to receive(:scroll).with(hash_including(:body => { :scroll_id => slice0_scroll1 })).and_return(slice0_response1)
313
343
  expect(client).to receive(:scroll).with(hash_including(:body => { :scroll_id => slice0_scroll2 })).and_return(slice0_response2)
344
+ allow(client).to receive(:ping)
314
345
 
315
346
  # SLICE1 is a two-page scroll in which the last page has no next scroll id
316
347
  slice1_query = LogStash::Json.dump(query.merge('slice' => { 'id' => 1, 'max' => 2}))
@@ -410,6 +441,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
410
441
  expect(client).to receive(:search).with(any_args).and_return(response)
411
442
  allow(client).to receive(:scroll).with({ :body => {:scroll_id => "cXVlcnlUaGVuRmV0Y2g"}, :scroll => "1m" }).and_return(scroll_reponse)
412
443
  allow(client).to receive(:clear_scroll).and_return(nil)
444
+ allow(client).to receive(:ping).and_return(nil)
413
445
  end
414
446
 
415
447
  ecs_compatibility_matrix(:disabled, :v1, :v8) do |ecs_select|
@@ -586,13 +618,14 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
586
618
  it "should set host(s)" do
587
619
  plugin.register
588
620
  client = plugin.send(:client)
589
- expect( extract_transport(client).hosts ).to eql [{
590
- :scheme => "https",
591
- :host => "ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io",
592
- :port => 9243,
593
- :path => "",
594
- :protocol => "https"
595
- }]
621
+
622
+ expect( client.transport.instance_variable_get(:@seeds) ).to eql [{
623
+ :scheme => "https",
624
+ :host => "ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io",
625
+ :port => 9243,
626
+ :path => "",
627
+ :protocol => "https"
628
+ }]
596
629
  end
597
630
 
598
631
  context 'invalid' do
@@ -843,7 +876,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
843
876
  end
844
877
  end
845
878
 
846
- shared_examples'configurable timeout' do |config_name, manticore_transport_option|
879
+ shared_examples 'configurable timeout' do |config_name, manticore_transport_option|
847
880
  let(:config_value) { fail NotImplementedError }
848
881
  let(:config) { super().merge(config_name => config_value) }
849
882
  {
@@ -874,6 +907,9 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
874
907
  transport_options = new_elasticsearch_client_params[:transport_options]
875
908
  expect(transport_options).to include(manticore_transport_option)
876
909
  expect(transport_options[manticore_transport_option]).to eq(config_value.to_i)
910
+ mock_client = double("fake_client")
911
+ allow(mock_client).to receive(:ping)
912
+ mock_client
877
913
  end
878
914
 
879
915
  plugin.register
@@ -24,7 +24,6 @@ describe LogStash::Inputs::Elasticsearch do
24
24
  ESHelper.index_doc(@es, :index => 'logs', :body => { :response => 404, :message=> 'Not Found'})
25
25
  end
26
26
  @es.indices.refresh
27
- plugin.register
28
27
  end
29
28
 
30
29
  after(:each) do
@@ -33,6 +32,10 @@ describe LogStash::Inputs::Elasticsearch do
33
32
  end
34
33
 
35
34
  shared_examples 'an elasticsearch index plugin' do
35
+ before(:each) do
36
+ plugin.register
37
+ end
38
+
36
39
  it 'should retrieve json event from elasticsearch' do
37
40
  queue = []
38
41
  plugin.run(queue)
@@ -43,6 +46,10 @@ describe LogStash::Inputs::Elasticsearch do
43
46
  end
44
47
 
45
48
  describe 'against an unsecured elasticsearch', :integration => true do
49
+ before(:each) do
50
+ plugin.register
51
+ end
52
+
46
53
  it_behaves_like 'an elasticsearch index plugin'
47
54
  end
48
55
 
@@ -66,8 +73,7 @@ describe LogStash::Inputs::Elasticsearch do
66
73
  let(:queue) { [] }
67
74
 
68
75
  it "fails to run the plugin" do
69
- plugin.register
70
- expect { plugin.run queue }.to raise_error Elasticsearch::Transport::Transport::Errors::Unauthorized
76
+ expect { plugin.register }.to raise_error Elasticsearch::Transport::Transport::Errors::Unauthorized
71
77
  end
72
78
  end
73
79
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.11.0
4
+ version: 4.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-29 00:00:00.000000000 Z
11
+ date: 2021-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -77,7 +77,7 @@ dependencies:
77
77
  requirements:
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
- version: 5.0.5
80
+ version: 7.14.0
81
81
  name: elasticsearch
82
82
  prerelease: false
83
83
  type: :runtime
@@ -85,7 +85,7 @@ dependencies:
85
85
  requirements:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
- version: 5.0.5
88
+ version: 7.14.0
89
89
  - !ruby/object:Gem::Dependency
90
90
  requirement: !ruby/object:Gem::Requirement
91
91
  requirements:
@@ -161,7 +161,7 @@ dependencies:
161
161
  requirements:
162
162
  - - "~>"
163
163
  - !ruby/object:Gem::Version
164
- version: 0.15.4
164
+ version: '1'
165
165
  name: faraday
166
166
  prerelease: false
167
167
  type: :development
@@ -169,7 +169,7 @@ dependencies:
169
169
  requirements:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: 0.15.4
172
+ version: '1'
173
173
  - !ruby/object:Gem::Dependency
174
174
  requirement: !ruby/object:Gem::Requirement
175
175
  requirements: