elasticsearch-transport 7.13.3 → 7.17.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,126 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ unless defined?(JRUBY_VERSION)
19
+ require_relative '../../../spec_helper'
20
+
21
+ describe Elasticsearch::Transport::Transport::HTTP::Curb do
22
+ let(:client) do
23
+ Elasticsearch::Transport::Client.new(transport_class: described_class)
24
+ end
25
+
26
+ describe '#perform_request' do
27
+ subject(:perform_request) { client.perform_request(*args) }
28
+ let(:args) do
29
+ ['POST', '/', {}, body, headers]
30
+ end
31
+ let(:body) { '{"foo":"bar"}' }
32
+ let(:headers) { { 'Content-Type' => 'application/x-ndjson' } }
33
+
34
+ before do
35
+ allow_any_instance_of(Curl::Easy).to receive(:http).and_return(true)
36
+ end
37
+
38
+ it 'convert body to json' do
39
+ expect(client.transport).to receive(:__convert_to_json).with(body)
40
+ perform_request
41
+ end
42
+
43
+ it 'call compress_request' do
44
+ expect(client.transport).to receive(:compress_request).with(body, headers)
45
+ perform_request
46
+ end
47
+
48
+ it 'return response' do
49
+ expect(perform_request).to be_kind_of(Elasticsearch::Transport::Transport::Response)
50
+ end
51
+
52
+ it 'put body' do
53
+ expect(client.transport.connections.first.connection).to receive('put_data=').with(body)
54
+ perform_request
55
+ end
56
+
57
+ context 'when body nil' do
58
+ let(:body) { nil }
59
+
60
+ it 'convert body to json' do
61
+ expect(client.transport).not_to receive(:__convert_to_json)
62
+ perform_request
63
+ end
64
+
65
+ it 'call compress_request' do
66
+ expect(client.transport).to receive(:compress_request).with(body, headers)
67
+ perform_request
68
+ end
69
+
70
+ it 'put body' do
71
+ expect(client.transport.connections.first.connection).not_to receive('put_data=')
72
+ perform_request
73
+ end
74
+ end
75
+
76
+ context 'when body is hash' do
77
+ let(:body) { { foo: 'bar' } }
78
+ let(:body_string) { '{"foo":"bar"}' }
79
+
80
+ it 'convert body to json' do
81
+ expect(client.transport).to receive(:__convert_to_json).with(body)
82
+ perform_request
83
+ end
84
+
85
+ it 'call compress_request' do
86
+ expect(client.transport).to receive(:compress_request).with(body_string, headers)
87
+ perform_request
88
+ end
89
+
90
+ it 'put body' do
91
+ expect(client.transport.connections.first.connection).to receive('put_data=').with(body_string)
92
+ perform_request
93
+ end
94
+ end
95
+
96
+ context 'when compression enabled' do
97
+ let(:client) do
98
+ Elasticsearch::Transport::Client.new(transport_class: described_class, compression: true)
99
+ end
100
+ let(:body_string) { '{"foo":"bar"}' }
101
+ let(:compressed_body) do
102
+ gzip = Zlib::GzipWriter.new(StringIO.new)
103
+ gzip << body_string
104
+ gzip.close.string
105
+ end
106
+
107
+ before { allow(client.transport).to receive(:decompress_response).and_return('') }
108
+
109
+ it 'put compressed body' do
110
+ expect(client.transport.connections.first.connection).to receive('put_data=').with(compressed_body)
111
+ perform_request
112
+ end
113
+
114
+ it 'set Content-Encoding header' do
115
+ perform_request
116
+ expect(client.transport.connections.first.connection.headers).to include('Content-Encoding')
117
+ end
118
+
119
+ it 'set Content-Encoding to gzip' do
120
+ perform_request
121
+ expect(client.transport.connections.first.connection.headers['Content-Encoding']).to eql('gzip')
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,141 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ require_relative '../../../spec_helper'
19
+
20
+ describe Elasticsearch::Transport::Transport::HTTP::Faraday do
21
+ let(:client) do
22
+ Elasticsearch::Transport::Client.new(transport_class: described_class)
23
+ end
24
+
25
+ describe '#perform_request' do
26
+ subject(:perform_request) { client.perform_request(*args) }
27
+ let(:args) do
28
+ ['POST', '/', {}, body, headers]
29
+ end
30
+ let(:body) { '{"foo":"bar"}' }
31
+ let(:headers) { { 'Content-Type' => 'application/x-ndjson' } }
32
+ let(:response) { instance_double('Faraday::Response', status: 200, body: '', headers: headers) }
33
+ let(:expected_headers) do
34
+ client.transport.connections.first.connection.headers.merge(headers)
35
+ end
36
+
37
+ before do
38
+ allow_any_instance_of(Faraday::Connection).to receive(:run_request).and_return(response)
39
+ end
40
+
41
+ it 'convert body to json' do
42
+ expect(client.transport).to receive(:__convert_to_json).with(body)
43
+ perform_request
44
+ end
45
+
46
+ it 'call compress_request' do
47
+ expect(client.transport).to receive(:compress_request).with(body, expected_headers)
48
+ perform_request
49
+ end
50
+
51
+ it 'return response' do
52
+ expect(perform_request).to be_kind_of(Elasticsearch::Transport::Transport::Response)
53
+ end
54
+
55
+ it 'run body with preper params' do
56
+ expect(
57
+ client.transport.connections.first.connection
58
+ ).to receive(:run_request).with(:post, 'http://localhost:9200/', body, expected_headers).and_return(response)
59
+ perform_request
60
+ end
61
+
62
+ context 'when body nil' do
63
+ let(:body) { nil }
64
+ let(:request_params) { [:post, 'http://localhost:9200/', body, expected_headers] }
65
+
66
+ it 'convert body to json' do
67
+ expect(client.transport).not_to receive(:__convert_to_json)
68
+ perform_request
69
+ end
70
+
71
+ it 'call compress_request' do
72
+ expect(client.transport).to receive(:compress_request).with(body, expected_headers)
73
+ perform_request
74
+ end
75
+
76
+ it 'run body with preper params' do
77
+ expect(
78
+ client.transport.connections.first.connection
79
+ ).to receive(:run_request).with(*request_params).and_return(response)
80
+ perform_request
81
+ end
82
+ end
83
+
84
+ context 'when body is hash' do
85
+ let(:body) { { foo: 'bar' } }
86
+ let(:body_string) { '{"foo":"bar"}' }
87
+ let(:request_params) { [:post, 'http://localhost:9200/', body_string, expected_headers] }
88
+
89
+ it 'convert body to json' do
90
+ expect(client.transport).to receive(:__convert_to_json).with(body)
91
+ perform_request
92
+ end
93
+
94
+ it 'call compress_request' do
95
+ expect(client.transport).to receive(:compress_request).with(body_string, expected_headers)
96
+ perform_request
97
+ end
98
+
99
+ it 'run body with preper params' do
100
+ expect(
101
+ client.transport.connections.first.connection
102
+ ).to receive(:run_request).with(*request_params).and_return(response)
103
+ perform_request
104
+ end
105
+ end
106
+
107
+ context 'when compression enabled' do
108
+ let(:client) do
109
+ Elasticsearch::Transport::Client.new(transport_class: described_class, compression: true)
110
+ end
111
+ let(:body_string) { '{"foo":"bar"}' }
112
+ let(:expected_headers) { super().merge({ "Content-Encoding" => "gzip", "Accept-Encoding" => "gzip"}) }
113
+ let(:request_params) { [:post, 'http://localhost:9200/', compressed_body, expected_headers] }
114
+ let(:compressed_body) do
115
+ gzip = Zlib::GzipWriter.new(StringIO.new)
116
+ gzip << body_string
117
+ gzip.close.string
118
+ end
119
+
120
+ it 'run body with preper params' do
121
+ expect(
122
+ client.transport.connections.first.connection
123
+ ).to receive(:run_request).with(*request_params).and_return(response)
124
+ perform_request
125
+ end
126
+
127
+ context 'when client makes second request with nil boby' do
128
+ before { perform_request }
129
+
130
+ it 'remove Content-Encoding header' do
131
+ expected_headers.delete("Content-Encoding")
132
+ expect(
133
+ client.transport.connections.first.connection
134
+ ).to receive(:run_request).with(:post, 'http://localhost:9200/', nil, expected_headers)
135
+ .and_return(response)
136
+ client.perform_request('POST', '/', {}, nil, headers)
137
+ end
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,143 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ if defined?(JRUBY_VERSION)
19
+ require_relative '../../../spec_helper'
20
+
21
+ describe Elasticsearch::Transport::Transport::HTTP::Manticore do
22
+ let(:client) do
23
+ Elasticsearch::Transport::Client.new(transport_class: described_class)
24
+ end
25
+
26
+ describe '#perform_request' do
27
+ subject(:perform_request) { client.perform_request(*args) }
28
+ let(:args) do
29
+ ['POST', '/', {}, body, headers]
30
+ end
31
+ let(:body) { '{"foo":"bar"}' }
32
+ let(:headers) { { 'Content-Type' => 'application/json' } }
33
+ let(:response) { instance_double('Manticore::Response', code: 200, read_body: '', headers: headers) }
34
+ let(:expected_headers) do
35
+ client.transport.instance_variable_get('@request_options')[:headers].merge(headers)
36
+ end
37
+
38
+ before do
39
+ allow_any_instance_of(Manticore::Client).to receive(:post).and_return(response)
40
+ end
41
+
42
+ it 'convert body to json' do
43
+ expect(client.transport).to receive(:__convert_to_json).with(body)
44
+ perform_request
45
+ end
46
+
47
+ it 'call compress_request' do
48
+ expect(client.transport).to receive(:compress_request).with(body, expected_headers)
49
+ perform_request
50
+ end
51
+
52
+ it 'return response' do
53
+ expect(perform_request).to be_kind_of(Elasticsearch::Transport::Transport::Response)
54
+ end
55
+
56
+ it 'run body with preper params' do
57
+ expect(
58
+ client.transport.connections.first.connection
59
+ ).to receive(:post).with('http://localhost:9200/', { body: body, headers: expected_headers }).and_return(response)
60
+ perform_request
61
+ end
62
+
63
+ context 'when body nil' do
64
+ let(:body) { nil }
65
+ let(:request_params) { ['http://localhost:9200/', { body: body, headers: expected_headers }] }
66
+
67
+ it 'convert body to json' do
68
+ expect(client.transport).not_to receive(:__convert_to_json)
69
+ perform_request
70
+ end
71
+
72
+ it 'call compress_request' do
73
+ expect(client.transport).to receive(:compress_request).with(body, expected_headers)
74
+ perform_request
75
+ end
76
+
77
+ it 'run body with preper params' do
78
+ expect(
79
+ client.transport.connections.first.connection
80
+ ).to receive(:post).with('http://localhost:9200/', { headers: expected_headers }).and_return(response)
81
+ perform_request
82
+ end
83
+ end
84
+
85
+ context 'when body is hash' do
86
+ let(:body) { { foo: 'bar' } }
87
+ let(:body_string) { '{"foo":"bar"}' }
88
+ let(:request_params) { ['http://localhost:9200/', { body: body_string, headers: expected_headers }] }
89
+
90
+ it 'convert body to json' do
91
+ expect(client.transport).to receive(:__convert_to_json).with(body)
92
+ perform_request
93
+ end
94
+
95
+ it 'call compress_request' do
96
+ expect(client.transport).to receive(:compress_request).with(body_string, expected_headers)
97
+ perform_request
98
+ end
99
+
100
+ it 'run body with preper params' do
101
+ expect(
102
+ client.transport.connections.first.connection
103
+ ).to receive(:post).with(*request_params).and_return(response)
104
+ perform_request
105
+ end
106
+ end
107
+
108
+ context 'when compression enabled' do
109
+ let(:client) do
110
+ Elasticsearch::Transport::Client.new(transport_class: described_class, compression: true)
111
+ end
112
+ let(:body_string) { '{"foo":"bar"}' }
113
+ let(:expected_headers) { super().merge({ "Content-Encoding" => "gzip", "Accept-Encoding" => "gzip"}) }
114
+ let(:request_params) { ['http://localhost:9200/', { body: compressed_body, headers: expected_headers }] }
115
+ let(:compressed_body) do
116
+ gzip = Zlib::GzipWriter.new(StringIO.new)
117
+ gzip << body_string
118
+ gzip.close.string
119
+ end
120
+
121
+ it 'run body with preper params' do
122
+ expect(
123
+ client.transport.connections.first.connection
124
+ ).to receive(:post).with(*request_params).and_return(response)
125
+ perform_request
126
+ end
127
+
128
+ context 'when client makes second request with nil boby' do
129
+ before { perform_request }
130
+
131
+ it 'remove Content-Encoding header' do
132
+ expected_headers.delete("Content-Encoding")
133
+ expect(
134
+ client.transport.connections.first.connection
135
+ ).to receive(:post).with('http://localhost:9200/', { headers: expected_headers })
136
+ .and_return(response)
137
+ client.perform_request('POST', '/', {}, nil, headers)
138
+ end
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
@@ -16,6 +16,7 @@
16
16
  # under the License.
17
17
 
18
18
  require 'spec_helper'
19
+ require 'elasticsearch'
19
20
 
20
21
  describe Elasticsearch::Transport::Client do
21
22
  context 'meta-header' do
@@ -109,11 +110,17 @@ describe Elasticsearch::Transport::Client do
109
110
  let(:adapter) { :net_http_persistent }
110
111
 
111
112
  it 'sets adapter in the meta header version to 0 when not loaded' do
112
- fork {
113
- expect(headers['x-elastic-client-meta']).to match(regexp)
114
- meta = "#{meta_header},np=0"
115
- expect(headers).to include('x-elastic-client-meta' => meta)
116
- }
113
+ was_required = defined?(Net::HTTP::Persistent)
114
+ if was_required
115
+ @klass = Net::HTTP::Persistent.clone
116
+ Net::HTTP.send(:remove_const, :Persistent)
117
+ end
118
+
119
+ expect(headers['x-elastic-client-meta']).to match(regexp)
120
+ meta = "#{meta_header},np=0"
121
+ expect(headers).to include('x-elastic-client-meta' => meta)
122
+
123
+ Net::HTTP::Persistent = @klass if was_required
117
124
  end unless jruby?
118
125
 
119
126
  it 'sets adapter in the meta header' do
@@ -128,15 +135,22 @@ describe Elasticsearch::Transport::Client do
128
135
  let(:adapter) { :httpclient }
129
136
 
130
137
  it 'sets adapter in the meta header version to 0 when not loaded' do
131
- fork {
132
- expect(headers['x-elastic-client-meta']).to match(regexp)
133
- meta = "#{meta_header},hc=0"
134
- expect(headers).to include('x-elastic-client-meta' => meta)
135
- }
138
+ was_required = defined?(HTTPClient)
139
+ if was_required
140
+ @klass = HTTPClient.clone
141
+ Object.send(:remove_const, :HTTPClient)
142
+ end
143
+
144
+ expect(headers['x-elastic-client-meta']).to match(regexp)
145
+ meta = "#{meta_header},hc=0"
146
+ expect(headers).to include('x-elastic-client-meta' => meta)
147
+
148
+ HTTPClient = @klass if was_required
136
149
  end unless jruby?
137
150
 
138
151
  it 'sets adapter in the meta header' do
139
152
  require 'httpclient'
153
+
140
154
  expect(headers['x-elastic-client-meta']).to match(regexp)
141
155
  meta = "#{meta_header},hc=#{HTTPClient::VERSION}"
142
156
  expect(headers).to include('x-elastic-client-meta' => meta)
@@ -147,11 +161,17 @@ describe Elasticsearch::Transport::Client do
147
161
  let(:adapter) { :typhoeus }
148
162
 
149
163
  it 'sets adapter in the meta header version to 0 when not loaded' do
150
- fork {
151
- expect(headers['x-elastic-client-meta']).to match(regexp)
152
- meta = "#{meta_header},ty=0"
153
- expect(headers).to include('x-elastic-client-meta' => meta)
154
- }
164
+ was_required = defined?(Typhoeus)
165
+ if was_required
166
+ @klass = Typhoeus.clone
167
+ Object.send(:remove_const, :Typhoeus)
168
+ end
169
+
170
+ expect(headers['x-elastic-client-meta']).to match(regexp)
171
+ meta = "#{meta_header},ty=0"
172
+ expect(headers).to include('x-elastic-client-meta' => meta)
173
+
174
+ Typhoeus = @klass if was_required
155
175
  end unless jruby?
156
176
 
157
177
  it 'sets adapter in the meta header' do
@@ -167,11 +187,17 @@ describe Elasticsearch::Transport::Client do
167
187
 
168
188
  context 'using patron without requiring it' do
169
189
  it 'sets adapter in the meta header version to 0 when not loaded' do
170
- fork {
171
- expect(headers['x-elastic-client-meta']).to match(regexp)
172
- meta = "#{meta_header},pt=0"
173
- expect(headers).to include('x-elastic-client-meta' => meta)
174
- }
190
+ was_required = defined?(Patron)
191
+ if was_required
192
+ @klass = Patron.clone
193
+ Object.send(:remove_const, :Patron)
194
+ end
195
+
196
+ expect(headers['x-elastic-client-meta']).to match(regexp)
197
+ meta = "#{meta_header},pt=0"
198
+ expect(headers).to include('x-elastic-client-meta' => meta)
199
+
200
+ Patron = @klass if was_required
175
201
  end
176
202
  end
177
203
 
@@ -206,7 +232,9 @@ describe Elasticsearch::Transport::Client do
206
232
  if defined?(JRUBY_VERSION)
207
233
  context 'when using manticore' do
208
234
  let(:client) do
209
- Elasticsearch::Client.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Manticore)
235
+ described_class.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Manticore).tap do |client|
236
+ client.instance_variable_set('@verified', true)
237
+ end
210
238
  end
211
239
  let(:subject) { client.transport.connections.first.connection.instance_variable_get("@options")[:headers]}
212
240
 
@@ -218,7 +246,9 @@ describe Elasticsearch::Transport::Client do
218
246
  else
219
247
  context 'when using curb' do
220
248
  let(:client) do
221
- Elasticsearch::Client.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Curb)
249
+ described_class.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Curb).tap do |client|
250
+ client.instance_variable_set('@verified', true)
251
+ end
222
252
  end
223
253
 
224
254
  it 'sets curb in the metaheader' do
@@ -229,12 +259,14 @@ describe Elasticsearch::Transport::Client do
229
259
  end
230
260
 
231
261
  context 'when using custom transport implementation' do
232
- class MyTransport
233
- include Elasticsearch::Transport::Transport::Base
234
- def initialize(args); end
262
+ let(:transport_class) do
263
+ Class.new do
264
+ def initialize(args)
265
+ end
266
+ end
235
267
  end
236
- let(:client) { Elasticsearch::Client.new(transport_class: MyTransport) }
237
- let(:subject){ client.instance_variable_get("@arguments")[:transport_options][:headers] }
268
+ let(:client) { Elasticsearch::Transport::Client.new(transport_class: transport_class) }
269
+ let(:subject) { client.instance_variable_get('@arguments')[:transport_options][:headers] }
238
270
  let(:meta_header) do
239
271
  if jruby?
240
272
  "es=#{meta_version},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},jv=#{ENV_JAVA['java.version']},jr=#{JRUBY_VERSION}"
@@ -254,7 +286,11 @@ describe Elasticsearch::Transport::Client do
254
286
  stub_const('Elastic::ELASTICSEARCH_SERVICE_VERSION', [:ent, '8.0.0'])
255
287
  end
256
288
 
257
- let(:client) { Elasticsearch::Client.new }
289
+ let(:client) do
290
+ described_class.new.tap do |client|
291
+ client.instance_variable_set('@verified', true)
292
+ end
293
+ end
258
294
 
259
295
  it 'sets the service version in the metaheader' do
260
296
  expect(subject['x-elastic-client-meta']).to match(regexp)
data/spec/spec_helper.rb CHANGED
@@ -14,8 +14,11 @@
14
14
  # KIND, either express or implied. See the License for the
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
+ if ENV['COVERAGE'] && ENV['CI'].nil?
18
+ require 'simplecov'
19
+ SimpleCov.start { add_filter %r{^/test|spec/} }
20
+ end
17
21
 
18
- require 'elasticsearch'
19
22
  require 'elasticsearch-transport'
20
23
  require 'logger'
21
24
  require 'ansi/code'
@@ -32,10 +35,12 @@ end
32
35
  # The hosts to use for creating a elasticsearch client.
33
36
  #
34
37
  # @since 7.0.0
35
- ELASTICSEARCH_HOSTS = if hosts = ENV['TEST_ES_SERVER'] || ENV['ELASTICSEARCH_HOSTS']
38
+ ELASTICSEARCH_HOSTS = if (hosts = ENV['TEST_ES_SERVER'] || ENV['ELASTICSEARCH_HOSTS'])
36
39
  hosts.split(',').map do |host|
37
40
  /(http\:\/\/)?(\S+)/.match(host)[2]
38
41
  end
42
+ else
43
+ ['localhost:9200']
39
44
  end.freeze
40
45
 
41
46
  TEST_HOST, TEST_PORT = ELASTICSEARCH_HOSTS.first.split(':') if ELASTICSEARCH_HOSTS
@@ -55,7 +60,8 @@ end
55
60
  #
56
61
  # @since 7.0.0
57
62
  def node_names
58
- $node_names ||= default_client.nodes.stats['nodes'].collect do |name, stats|
63
+ node_stats = default_client.perform_request('GET', '_nodes/stats').body
64
+ $node_names ||= node_stats['nodes'].collect do |name, stats|
59
65
  stats['name']
60
66
  end
61
67
  end
@@ -70,9 +76,7 @@ def default_client
70
76
  end
71
77
 
72
78
  module Config
73
-
74
79
  def self.included(context)
75
-
76
80
  # Get the hosts to use to connect an elasticsearch client.
77
81
  #
78
82
  # @since 7.0.0
@@ -0,0 +1,43 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ require 'test_helper'
18
+
19
+ if JRUBY
20
+ require 'elasticsearch/transport/transport/http/manticore'
21
+
22
+ class Elasticsearch::Transport::ClientManticoreIntegrationTest < Elasticsearch::Test::IntegrationTestCase
23
+ context "Transport" do
24
+ setup do
25
+ @host, @port = ELASTICSEARCH_HOSTS.first.split(':')
26
+ end
27
+
28
+ shutdown do
29
+ begin; Object.send(:remove_const, :Manticore); rescue NameError; end
30
+ end
31
+
32
+ should 'allow to customize the Faraday adapter to Manticore' do
33
+ client = Elasticsearch::Transport::Client.new(
34
+ transport_class: Elasticsearch::Transport::Transport::HTTP::Manticore,
35
+ trace: true,
36
+ hosts: [ { host: @host, port: @port } ]
37
+ )
38
+ response = client.perform_request 'GET', ''
39
+ assert_respond_to(response.body, :to_hash)
40
+ end
41
+ end
42
+ end
43
+ end