elasticsearch-transport 7.5.0 → 7.8.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +27 -10
- data/README.md +142 -53
- data/Rakefile +16 -3
- data/elasticsearch-transport.gemspec +57 -63
- data/lib/elasticsearch-transport.rb +16 -3
- data/lib/elasticsearch/transport.rb +16 -3
- data/lib/elasticsearch/transport/client.rb +61 -13
- data/lib/elasticsearch/transport/redacted.rb +16 -3
- data/lib/elasticsearch/transport/transport/base.rb +23 -4
- data/lib/elasticsearch/transport/transport/connections/collection.rb +16 -3
- data/lib/elasticsearch/transport/transport/connections/connection.rb +16 -3
- data/lib/elasticsearch/transport/transport/connections/selector.rb +16 -3
- data/lib/elasticsearch/transport/transport/errors.rb +16 -3
- data/lib/elasticsearch/transport/transport/http/curb.rb +16 -3
- data/lib/elasticsearch/transport/transport/http/faraday.rb +17 -4
- data/lib/elasticsearch/transport/transport/http/manticore.rb +16 -3
- data/lib/elasticsearch/transport/transport/loggable.rb +16 -3
- data/lib/elasticsearch/transport/transport/response.rb +16 -4
- data/lib/elasticsearch/transport/transport/serializer/multi_json.rb +16 -3
- data/lib/elasticsearch/transport/transport/sniffer.rb +16 -3
- data/lib/elasticsearch/transport/version.rb +17 -4
- data/spec/elasticsearch/connections/collection_spec.rb +16 -3
- data/spec/elasticsearch/connections/selector_spec.rb +16 -3
- data/spec/elasticsearch/transport/base_spec.rb +16 -10
- data/spec/elasticsearch/transport/client_spec.rb +154 -28
- data/spec/elasticsearch/transport/sniffer_spec.rb +16 -3
- data/spec/spec_helper.rb +19 -1
- data/test/integration/transport_test.rb +16 -3
- data/test/profile/client_benchmark_test.rb +16 -3
- data/test/test_helper.rb +16 -3
- data/test/unit/connection_test.rb +16 -3
- data/test/unit/response_test.rb +17 -4
- data/test/unit/serializer_test.rb +16 -3
- data/test/unit/transport_base_test.rb +16 -3
- data/test/unit/transport_curb_test.rb +16 -3
- data/test/unit/transport_faraday_test.rb +16 -3
- data/test/unit/transport_manticore_test.rb +16 -3
- metadata +68 -70
@@ -1,6 +1,19 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V under one or more
|
2
|
-
#
|
3
|
-
#
|
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.
|
4
17
|
|
5
18
|
module Elasticsearch
|
6
19
|
module Transport
|
@@ -1,6 +1,19 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V under one or more
|
2
|
-
#
|
3
|
-
#
|
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.
|
4
17
|
|
5
18
|
module Elasticsearch
|
6
19
|
module Transport
|
@@ -1,9 +1,22 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V under one or more
|
2
|
-
#
|
3
|
-
#
|
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.
|
4
17
|
|
5
18
|
module Elasticsearch
|
6
19
|
module Transport
|
7
|
-
VERSION = "7.
|
20
|
+
VERSION = "7.8.0.pre"
|
8
21
|
end
|
9
22
|
end
|
@@ -1,6 +1,19 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V under one or more
|
2
|
-
#
|
3
|
-
#
|
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.
|
4
17
|
|
5
18
|
require 'spec_helper'
|
6
19
|
|
@@ -1,6 +1,19 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V under one or more
|
2
|
-
#
|
3
|
-
#
|
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.
|
4
17
|
|
5
18
|
require 'spec_helper'
|
6
19
|
|
@@ -1,6 +1,19 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V under one or more
|
2
|
-
#
|
3
|
-
#
|
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.
|
4
17
|
|
5
18
|
require 'spec_helper'
|
6
19
|
|
@@ -96,7 +109,6 @@ describe Elasticsearch::Transport::Transport::Base do
|
|
96
109
|
end
|
97
110
|
|
98
111
|
context 'when `perform_request` is called without a `retry_on_failure` option value' do
|
99
|
-
|
100
112
|
before do
|
101
113
|
expect(client.transport).to receive(:get_connection).exactly(3).times.and_call_original
|
102
114
|
end
|
@@ -109,7 +121,6 @@ describe Elasticsearch::Transport::Transport::Base do
|
|
109
121
|
end
|
110
122
|
|
111
123
|
context 'when `perform_request` is called with a `retry_on_failure` option value' do
|
112
|
-
|
113
124
|
before do
|
114
125
|
expect(client.transport).to receive(:get_connection).exactly(6).times.and_call_original
|
115
126
|
end
|
@@ -123,7 +134,6 @@ describe Elasticsearch::Transport::Transport::Base do
|
|
123
134
|
end
|
124
135
|
|
125
136
|
context 'when the client has `retry_on_failure` set to true' do
|
126
|
-
|
127
137
|
let(:client) do
|
128
138
|
Elasticsearch::Transport::Client.new(arguments)
|
129
139
|
end
|
@@ -136,7 +146,6 @@ describe Elasticsearch::Transport::Transport::Base do
|
|
136
146
|
end
|
137
147
|
|
138
148
|
context 'when `perform_request` is called without a `retry_on_failure` option value' do
|
139
|
-
|
140
149
|
before do
|
141
150
|
expect(client.transport).to receive(:get_connection).exactly(4).times.and_call_original
|
142
151
|
end
|
@@ -149,7 +158,6 @@ describe Elasticsearch::Transport::Transport::Base do
|
|
149
158
|
end
|
150
159
|
|
151
160
|
context 'when `perform_request` is called with a `retry_on_failure` option value' do
|
152
|
-
|
153
161
|
before do
|
154
162
|
expect(client.transport).to receive(:get_connection).exactly(6).times.and_call_original
|
155
163
|
end
|
@@ -163,7 +171,6 @@ describe Elasticsearch::Transport::Transport::Base do
|
|
163
171
|
end
|
164
172
|
|
165
173
|
context 'when the client has `retry_on_failure` set to false' do
|
166
|
-
|
167
174
|
let(:client) do
|
168
175
|
Elasticsearch::Transport::Client.new(arguments)
|
169
176
|
end
|
@@ -176,7 +183,6 @@ describe Elasticsearch::Transport::Transport::Base do
|
|
176
183
|
end
|
177
184
|
|
178
185
|
context 'when `perform_request` is called without a `retry_on_failure` option value' do
|
179
|
-
|
180
186
|
before do
|
181
187
|
expect(client.transport).to receive(:get_connection).once.and_call_original
|
182
188
|
end
|
@@ -1,11 +1,23 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V under one or more
|
2
|
-
#
|
3
|
-
#
|
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.
|
4
17
|
|
5
18
|
require 'spec_helper'
|
6
19
|
|
7
20
|
describe Elasticsearch::Transport::Client do
|
8
|
-
|
9
21
|
let(:client) do
|
10
22
|
described_class.new.tap do |_client|
|
11
23
|
allow(_client).to receive(:__build_connections)
|
@@ -49,7 +61,6 @@ describe Elasticsearch::Transport::Client do
|
|
49
61
|
end
|
50
62
|
|
51
63
|
context 'when a User-Agent header is specified as client option' do
|
52
|
-
|
53
64
|
let(:client) do
|
54
65
|
described_class.new(transport_options: { headers: { 'User-Agent' => 'testing' } })
|
55
66
|
end
|
@@ -59,6 +70,49 @@ describe Elasticsearch::Transport::Client do
|
|
59
70
|
end
|
60
71
|
end
|
61
72
|
|
73
|
+
context 'when an encoded api_key is provided' do
|
74
|
+
let(:client) do
|
75
|
+
described_class.new(api_key: 'an_api_key')
|
76
|
+
end
|
77
|
+
let(:authorization_header) do
|
78
|
+
client.transport.connections.first.connection.headers['Authorization']
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'Adds the ApiKey header to the connection' do
|
82
|
+
expect(authorization_header).to eq('ApiKey an_api_key')
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'when an un-encoded api_key is provided' do
|
87
|
+
let(:client) do
|
88
|
+
described_class.new(api_key: { id: 'my_id', api_key: 'my_api_key' })
|
89
|
+
end
|
90
|
+
let(:authorization_header) do
|
91
|
+
client.transport.connections.first.connection.headers['Authorization']
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'Adds the ApiKey header to the connection' do
|
95
|
+
expect(authorization_header).to eq("ApiKey #{Base64.strict_encode64('my_id:my_api_key')}")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'when basic auth and api_key are provided' do
|
100
|
+
let(:client) do
|
101
|
+
described_class.new(
|
102
|
+
api_key: { id: 'my_id', api_key: 'my_api_key' },
|
103
|
+
host: 'http://elastic:password@localhost:9200'
|
104
|
+
)
|
105
|
+
end
|
106
|
+
let(:authorization_header) do
|
107
|
+
client.transport.connections.first.connection.headers['Authorization']
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'removes basic auth credentials' do
|
111
|
+
expect(authorization_header).not_to match(/^Basic/)
|
112
|
+
expect(authorization_header).to match(/^ApiKey/)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
62
116
|
context 'when a user-agent header is specified as client option in lower-case' do
|
63
117
|
|
64
118
|
let(:client) do
|
@@ -176,45 +230,43 @@ describe Elasticsearch::Transport::Client do
|
|
176
230
|
end
|
177
231
|
|
178
232
|
describe 'adapter' do
|
179
|
-
|
180
233
|
context 'when no adapter is specified' do
|
181
|
-
|
182
234
|
let(:adapter) do
|
183
|
-
client.transport.connections.all.first.connection.builder.
|
235
|
+
client.transport.connections.all.first.connection.builder.adapter
|
184
236
|
end
|
185
237
|
|
186
238
|
it 'uses Faraday NetHttp' do
|
187
|
-
expect(adapter).to
|
239
|
+
expect(adapter).to eq Faraday::Adapter::NetHttp
|
188
240
|
end
|
189
241
|
end
|
190
242
|
|
191
243
|
context 'when the adapter is specified' do
|
192
244
|
|
193
245
|
let(:adapter) do
|
194
|
-
client.transport.connections.all.first.connection.builder.
|
246
|
+
client.transport.connections.all.first.connection.builder.adapter
|
195
247
|
end
|
196
248
|
|
197
249
|
let(:client) do
|
198
|
-
described_class.new(adapter: :
|
250
|
+
described_class.new(adapter: :patron)
|
199
251
|
end
|
200
252
|
|
201
253
|
it 'uses Faraday with the adapter' do
|
202
|
-
expect(adapter).to
|
254
|
+
expect(adapter).to eq Faraday::Adapter::Patron
|
203
255
|
end
|
204
256
|
end
|
205
257
|
|
206
258
|
context 'when the adapter is specified as a string key' do
|
207
259
|
|
208
260
|
let(:adapter) do
|
209
|
-
client.transport.connections.all.first.connection.builder.
|
261
|
+
client.transport.connections.all.first.connection.builder.adapter
|
210
262
|
end
|
211
263
|
|
212
264
|
let(:client) do
|
213
|
-
described_class.new('adapter' => :
|
265
|
+
described_class.new('adapter' => :patron)
|
214
266
|
end
|
215
267
|
|
216
268
|
it 'uses Faraday with the adapter' do
|
217
|
-
expect(adapter).to
|
269
|
+
expect(adapter).to eq Faraday::Adapter::Patron
|
218
270
|
end
|
219
271
|
end
|
220
272
|
|
@@ -226,11 +278,11 @@ describe Elasticsearch::Transport::Client do
|
|
226
278
|
end
|
227
279
|
|
228
280
|
let(:adapter) do
|
229
|
-
client.transport.connections.all.first.connection.builder.
|
281
|
+
client.transport.connections.all.first.connection.builder.adapter
|
230
282
|
end
|
231
283
|
|
232
284
|
it 'uses the detected adapter' do
|
233
|
-
expect(adapter).to
|
285
|
+
expect(adapter).to eq Faraday::Adapter::Patron
|
234
286
|
end
|
235
287
|
end
|
236
288
|
|
@@ -238,17 +290,21 @@ describe Elasticsearch::Transport::Client do
|
|
238
290
|
|
239
291
|
let(:client) do
|
240
292
|
described_class.new do |faraday|
|
241
|
-
faraday.adapter :
|
293
|
+
faraday.adapter :patron
|
242
294
|
faraday.response :logger
|
243
295
|
end
|
244
296
|
end
|
245
297
|
|
298
|
+
let(:adapter) do
|
299
|
+
client.transport.connections.all.first.connection.builder.adapter
|
300
|
+
end
|
301
|
+
|
246
302
|
let(:handlers) do
|
247
303
|
client.transport.connections.all.first.connection.builder.handlers
|
248
304
|
end
|
249
305
|
|
250
306
|
it 'sets the adapter' do
|
251
|
-
expect(
|
307
|
+
expect(adapter).to eq Faraday::Adapter::Patron
|
252
308
|
end
|
253
309
|
|
254
310
|
it 'sets the logger' do
|
@@ -1055,10 +1111,81 @@ describe Elasticsearch::Transport::Client do
|
|
1055
1111
|
expect(request).to be(true)
|
1056
1112
|
end
|
1057
1113
|
end
|
1114
|
+
|
1115
|
+
context 'when x-opaque-id is set' do
|
1116
|
+
let(:client) { described_class.new(host: hosts) }
|
1117
|
+
|
1118
|
+
it 'uses x-opaque-id on a request' do
|
1119
|
+
expect(client.perform_request('GET', '/', { opaque_id: '12345' }).headers['x-opaque-id']).to eq('12345')
|
1120
|
+
end
|
1121
|
+
end
|
1122
|
+
|
1123
|
+
context 'when an x-opaque-id prefix is set on initialization' do
|
1124
|
+
let(:prefix) { 'elastic_cloud' }
|
1125
|
+
let(:client) do
|
1126
|
+
described_class.new(host: hosts, opaque_id_prefix: prefix)
|
1127
|
+
end
|
1128
|
+
|
1129
|
+
it 'uses x-opaque-id on a request' do
|
1130
|
+
expect(client.perform_request('GET', '/', { opaque_id: '12345' }).headers['x-opaque-id']).to eq("#{prefix}12345")
|
1131
|
+
end
|
1132
|
+
|
1133
|
+
context 'when using an API call' do
|
1134
|
+
let(:client) { described_class.new(host: hosts) }
|
1135
|
+
|
1136
|
+
it 'doesnae raise an ArgumentError' do
|
1137
|
+
expect { client.search(opaque_id: 'no_error') }.not_to raise_error
|
1138
|
+
end
|
1139
|
+
|
1140
|
+
it 'uses X-Opaque-Id in the header' do
|
1141
|
+
allow(client).to receive(:perform_request) { OpenStruct.new(body: '') }
|
1142
|
+
expect { client.search(opaque_id: 'opaque_id') }.not_to raise_error
|
1143
|
+
expect(client).to have_received(:perform_request)
|
1144
|
+
.with('GET', '_search', { opaque_id: 'opaque_id' }, nil, {})
|
1145
|
+
end
|
1146
|
+
end
|
1147
|
+
end
|
1148
|
+
|
1149
|
+
context 'when Elasticsearch response includes a warning header' do
|
1150
|
+
let(:client) do
|
1151
|
+
Elasticsearch::Transport::Client.new(hosts: hosts)
|
1152
|
+
end
|
1153
|
+
|
1154
|
+
let(:warning) { 'Elasticsearch warning: "deprecation warning"' }
|
1155
|
+
|
1156
|
+
it 'prints a warning' do
|
1157
|
+
allow_any_instance_of(Elasticsearch::Transport::Transport::Response).to receive(:headers) do
|
1158
|
+
{ 'warning' => warning }
|
1159
|
+
end
|
1160
|
+
|
1161
|
+
begin
|
1162
|
+
stderr = $stderr
|
1163
|
+
fake_stderr = StringIO.new
|
1164
|
+
$stderr = fake_stderr
|
1165
|
+
|
1166
|
+
client.perform_request('GET', '/')
|
1167
|
+
fake_stderr.rewind
|
1168
|
+
expect(fake_stderr.string).to eq("warning: #{warning}\n")
|
1169
|
+
ensure
|
1170
|
+
$stderr = stderr
|
1171
|
+
end
|
1172
|
+
end
|
1173
|
+
end
|
1174
|
+
|
1175
|
+
context 'when a header is set on an endpoint request' do
|
1176
|
+
let(:client) { described_class.new(host: hosts) }
|
1177
|
+
let(:headers) { { 'user-agent' => 'my ruby app' } }
|
1178
|
+
|
1179
|
+
it 'performs the request with the header' do
|
1180
|
+
allow(client).to receive(:perform_request) { OpenStruct.new(body: '') }
|
1181
|
+
expect { client.search(headers: headers) }.not_to raise_error
|
1182
|
+
expect(client).to have_received(:perform_request)
|
1183
|
+
.with('GET', '_search', {}, nil, headers)
|
1184
|
+
end
|
1185
|
+
end
|
1058
1186
|
end
|
1059
1187
|
|
1060
1188
|
context 'when the client connects to Elasticsearch' do
|
1061
|
-
|
1062
1189
|
let(:logger) do
|
1063
1190
|
Logger.new(STDERR).tap do |logger|
|
1064
1191
|
logger.formatter = proc do |severity, datetime, progname, msg|
|
@@ -1136,15 +1263,14 @@ describe Elasticsearch::Transport::Client do
|
|
1136
1263
|
end
|
1137
1264
|
|
1138
1265
|
context 'when the Faraday adapter is set in the block' do
|
1139
|
-
|
1140
1266
|
let(:client) do
|
1141
1267
|
Elasticsearch::Client.new(host: ELASTICSEARCH_HOSTS.first, logger: logger) do |client|
|
1142
1268
|
client.adapter(:net_http_persistent)
|
1143
1269
|
end
|
1144
1270
|
end
|
1145
1271
|
|
1146
|
-
let(:
|
1147
|
-
client.transport.connections.first.connection.builder.
|
1272
|
+
let(:handler_name) do
|
1273
|
+
client.transport.connections.first.connection.builder.adapter.name
|
1148
1274
|
end
|
1149
1275
|
|
1150
1276
|
let(:response) do
|
@@ -1152,7 +1278,7 @@ describe Elasticsearch::Transport::Client do
|
|
1152
1278
|
end
|
1153
1279
|
|
1154
1280
|
it 'sets the adapter' do
|
1155
|
-
expect(
|
1281
|
+
expect(handler_name).to eq('Faraday::Adapter::NetHttpPersistent')
|
1156
1282
|
end
|
1157
1283
|
|
1158
1284
|
it 'uses the adapter to connect' do
|
@@ -1202,7 +1328,7 @@ describe Elasticsearch::Transport::Client do
|
|
1202
1328
|
expect(client.perform_request('GET', '_nodes/_local'))
|
1203
1329
|
expect {
|
1204
1330
|
client.perform_request('GET', '_nodes/_local')
|
1205
|
-
}.to raise_exception(Faraday::
|
1331
|
+
}.to raise_exception(Faraday::ConnectionFailed)
|
1206
1332
|
end
|
1207
1333
|
end
|
1208
1334
|
|
@@ -1486,12 +1612,12 @@ describe Elasticsearch::Transport::Client do
|
|
1486
1612
|
{ adapter: :patron }
|
1487
1613
|
end
|
1488
1614
|
|
1489
|
-
let(:
|
1490
|
-
client.transport.connections.first.connection.builder.
|
1615
|
+
let(:adapter) do
|
1616
|
+
client.transport.connections.first.connection.builder.adapter
|
1491
1617
|
end
|
1492
1618
|
|
1493
1619
|
it 'uses the patron connection handler' do
|
1494
|
-
expect(
|
1620
|
+
expect(adapter).to eq('Faraday::Adapter::Patron')
|
1495
1621
|
end
|
1496
1622
|
|
1497
1623
|
it 'keeps connections open' do
|