elasticsearch-transport 7.1.0 → 7.5.0
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 +3 -16
- data/{LICENSE.txt → LICENSE} +0 -0
- data/README.md +18 -19
- data/Rakefile +3 -16
- data/elasticsearch-transport.gemspec +7 -19
- data/lib/elasticsearch/transport/client.rb +27 -24
- data/lib/elasticsearch/transport/redacted.rb +3 -16
- data/lib/elasticsearch/transport/transport/base.rb +81 -26
- data/lib/elasticsearch/transport/transport/connections/collection.rb +3 -16
- data/lib/elasticsearch/transport/transport/connections/connection.rb +3 -16
- data/lib/elasticsearch/transport/transport/connections/selector.rb +20 -21
- data/lib/elasticsearch/transport/transport/errors.rb +3 -16
- data/lib/elasticsearch/transport/transport/http/curb.rb +28 -24
- data/lib/elasticsearch/transport/transport/http/faraday.rb +19 -18
- data/lib/elasticsearch/transport/transport/http/manticore.rb +27 -25
- data/lib/elasticsearch/transport/transport/loggable.rb +3 -16
- data/lib/elasticsearch/transport/transport/response.rb +3 -16
- data/lib/elasticsearch/transport/transport/serializer/multi_json.rb +3 -16
- data/lib/elasticsearch/transport/transport/sniffer.rb +5 -17
- data/lib/elasticsearch/transport/version.rb +4 -17
- data/lib/elasticsearch/transport.rb +3 -16
- data/lib/elasticsearch-transport.rb +3 -16
- data/spec/elasticsearch/connections/collection_spec.rb +241 -0
- data/spec/elasticsearch/connections/selector_spec.rb +161 -0
- data/spec/elasticsearch/transport/base_spec.rb +186 -24
- data/spec/elasticsearch/transport/client_spec.rb +350 -19
- data/spec/elasticsearch/transport/sniffer_spec.rb +3 -16
- data/spec/spec_helper.rb +6 -0
- data/test/integration/transport_test.rb +3 -16
- data/test/profile/client_benchmark_test.rb +3 -16
- data/test/test_helper.rb +3 -16
- data/test/unit/connection_test.rb +3 -16
- data/test/unit/response_test.rb +3 -16
- data/test/unit/serializer_test.rb +3 -16
- data/test/unit/transport_base_test.rb +3 -16
- data/test/unit/transport_curb_test.rb +4 -17
- data/test/unit/transport_faraday_test.rb +3 -16
- data/test/unit/transport_manticore_test.rb +30 -27
- metadata +42 -16
- data/test/unit/connection_collection_test.rb +0 -147
- data/test/unit/connection_selector_test.rb +0 -81
@@ -1,19 +1,6 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V
|
2
|
-
#
|
3
|
-
#
|
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.
|
1
|
+
# Licensed to Elasticsearch B.V under one or more agreements.
|
2
|
+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
3
|
+
# See the LICENSE file in the project root for more information
|
17
4
|
|
18
5
|
require 'spec_helper'
|
19
6
|
|
@@ -33,18 +20,161 @@ describe Elasticsearch::Transport::Client do
|
|
33
20
|
expect(client.transport).to be_a(Elasticsearch::Transport::Client::DEFAULT_TRANSPORT_CLASS)
|
34
21
|
end
|
35
22
|
|
36
|
-
it '
|
23
|
+
it 'preserves the Faraday default user agent header' do
|
37
24
|
expect(client.transport.connections.first.connection.headers['User-Agent']).to match(/Faraday/)
|
38
25
|
end
|
39
26
|
|
27
|
+
it 'identifies the Ruby client in the User-Agent header' do
|
28
|
+
expect(client.transport.connections.first.connection.headers['User-Agent']).to match(/elasticsearch-ruby\/#{Elasticsearch::Transport::VERSION}/)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'identifies the Ruby version in the User-Agent header' do
|
32
|
+
expect(client.transport.connections.first.connection.headers['User-Agent']).to match(/#{RUBY_VERSION}/)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'identifies the host_os in the User-Agent header' do
|
36
|
+
expect(client.transport.connections.first.connection.headers['User-Agent']).to match(/#{RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase}/)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'identifies the target_cpu in the User-Agent header' do
|
40
|
+
expect(client.transport.connections.first.connection.headers['User-Agent']).to match(/#{RbConfig::CONFIG['target_cpu']}/)
|
41
|
+
end
|
42
|
+
|
40
43
|
it 'sets the \'Content-Type\' header to \'application/json\' by default' do
|
41
|
-
expect(client.transport.
|
44
|
+
expect(client.transport.connections.first.connection.headers['Content-Type']).to eq('application/json')
|
42
45
|
end
|
43
46
|
|
44
47
|
it 'uses localhost by default' do
|
45
48
|
expect(client.transport.hosts[0][:host]).to eq('localhost')
|
46
49
|
end
|
47
50
|
|
51
|
+
context 'when a User-Agent header is specified as client option' do
|
52
|
+
|
53
|
+
let(:client) do
|
54
|
+
described_class.new(transport_options: { headers: { 'User-Agent' => 'testing' } })
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'sets the specified User-Agent header' do
|
58
|
+
expect(client.transport.connections.first.connection.headers['User-Agent']).to eq('testing')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when a user-agent header is specified as client option in lower-case' do
|
63
|
+
|
64
|
+
let(:client) do
|
65
|
+
described_class.new(transport_options: { headers: { 'user-agent' => 'testing' } })
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'sets the specified User-Agent header' do
|
69
|
+
expect(client.transport.connections.first.connection.headers['User-Agent']).to eq('testing')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when a Content-Type header is specified as client option' do
|
74
|
+
|
75
|
+
let(:client) do
|
76
|
+
described_class.new(transport_options: { headers: { 'Content-Type' => 'testing' } })
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'sets the specified Content-Type header' do
|
80
|
+
expect(client.transport.connections.first.connection.headers['Content-Type']).to eq('testing')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when a content-type header is specified as client option in lower-case' do
|
85
|
+
|
86
|
+
let(:client) do
|
87
|
+
described_class.new(transport_options: { headers: { 'content-type' => 'testing' } })
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'sets the specified Content-Type header' do
|
91
|
+
expect(client.transport.connections.first.connection.headers['Content-Type']).to eq('testing')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'when the Curb transport class is used', unless: jruby? do
|
96
|
+
|
97
|
+
let(:client) do
|
98
|
+
described_class.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Curb)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'preserves the Curb default user agent header' do
|
102
|
+
expect(client.transport.connections.first.connection.headers['User-Agent']).to match(/Curb/)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'identifies the Ruby client in the User-Agent header' do
|
106
|
+
expect(client.transport.connections.first.connection.headers['User-Agent']).to match(/elasticsearch-ruby\/#{Elasticsearch::Transport::VERSION}/)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'identifies the Ruby version in the User-Agent header' do
|
110
|
+
expect(client.transport.connections.first.connection.headers['User-Agent']).to match(/#{RUBY_VERSION}/)
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'identifies the host_os in the User-Agent header' do
|
114
|
+
expect(client.transport.connections.first.connection.headers['User-Agent']).to match(/#{RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase}/)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'identifies the target_cpu in the User-Agent header' do
|
118
|
+
expect(client.transport.connections.first.connection.headers['User-Agent']).to match(/#{RbConfig::CONFIG['target_cpu']}/)
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'sets the \'Content-Type\' header to \'application/json\' by default' do
|
122
|
+
expect(client.transport.connections.first.connection.headers['Content-Type']).to eq('application/json')
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'uses localhost by default' do
|
126
|
+
expect(client.transport.hosts[0][:host]).to eq('localhost')
|
127
|
+
end
|
128
|
+
|
129
|
+
context 'when a User-Agent header is specified as a client option' do
|
130
|
+
|
131
|
+
let(:client) do
|
132
|
+
described_class.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Curb,
|
133
|
+
transport_options: { headers: { 'User-Agent' => 'testing' } })
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'sets the specified User-Agent header' do
|
137
|
+
expect(client.transport.connections.first.connection.headers['User-Agent']).to eq('testing')
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context 'when a user-agent header is specified as a client option as lower-case' do
|
142
|
+
|
143
|
+
let(:client) do
|
144
|
+
described_class.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Curb,
|
145
|
+
transport_options: { headers: { 'user-agent' => 'testing' } })
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'sets the specified User-Agent header' do
|
149
|
+
expect(client.transport.connections.first.connection.headers['User-Agent']).to eq('testing')
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
context 'when a Content-Type header is specified as client option' do
|
154
|
+
|
155
|
+
let(:client) do
|
156
|
+
described_class.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Curb,
|
157
|
+
transport_options: { headers: { 'Content-Type' => 'testing' } })
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'sets the specified Content-Type header' do
|
161
|
+
expect(client.transport.connections.first.connection.headers['Content-Type']).to eq('testing')
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
context 'when a content-type header is specified as client option in lower-case' do
|
166
|
+
|
167
|
+
let(:client) do
|
168
|
+
described_class.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Curb,
|
169
|
+
transport_options: { headers: { 'content-type' => 'testing' } })
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'sets the specified Content-Type header' do
|
173
|
+
expect(client.transport.connections.first.connection.headers['Content-Type']).to eq('testing')
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
48
178
|
describe 'adapter' do
|
49
179
|
|
50
180
|
context 'when no adapter is specified' do
|
@@ -127,6 +257,72 @@ describe Elasticsearch::Transport::Client do
|
|
127
257
|
end
|
128
258
|
end
|
129
259
|
|
260
|
+
context 'when cloud credentials are provided' do
|
261
|
+
|
262
|
+
let(:client) do
|
263
|
+
described_class.new(cloud_id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==', user: 'elastic', password: 'changeme')
|
264
|
+
end
|
265
|
+
|
266
|
+
let(:hosts) do
|
267
|
+
client.transport.hosts
|
268
|
+
end
|
269
|
+
|
270
|
+
it 'extracts the cloud credentials' do
|
271
|
+
expect(hosts[0][:host]).to eq('abcd.localhost')
|
272
|
+
expect(hosts[0][:protocol]).to eq('https')
|
273
|
+
expect(hosts[0][:user]).to eq('elastic')
|
274
|
+
expect(hosts[0][:password]).to eq('changeme')
|
275
|
+
expect(hosts[0][:port]).to eq(9243)
|
276
|
+
end
|
277
|
+
|
278
|
+
it 'creates the correct full url' do
|
279
|
+
expect(client.transport.__full_url(client.transport.hosts[0])).to eq('https://elastic:changeme@abcd.localhost:9243')
|
280
|
+
end
|
281
|
+
|
282
|
+
context 'when a port is specified' do
|
283
|
+
|
284
|
+
let(:client) do
|
285
|
+
described_class.new(cloud_id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==', user: 'elastic', password: 'changeme', port: 9200 )
|
286
|
+
end
|
287
|
+
|
288
|
+
it 'sets the specified port along with the cloud credentials' do
|
289
|
+
expect(hosts[0][:host]).to eq('abcd.localhost')
|
290
|
+
expect(hosts[0][:protocol]).to eq('https')
|
291
|
+
expect(hosts[0][:user]).to eq('elastic')
|
292
|
+
expect(hosts[0][:password]).to eq('changeme')
|
293
|
+
expect(hosts[0][:port]).to eq(9200)
|
294
|
+
end
|
295
|
+
|
296
|
+
it 'creates the correct full url' do
|
297
|
+
expect(client.transport.__full_url(client.transport.hosts[0])).to eq('https://elastic:changeme@abcd.localhost:9200')
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
context 'when the cluster has alternate names' do
|
302
|
+
|
303
|
+
let(:client) do
|
304
|
+
described_class.new(cloud_id: 'myCluster:bG9jYWxob3N0JGFiY2QkZWZnaA==', user: 'elasticfantastic', password: 'tobechanged')
|
305
|
+
end
|
306
|
+
|
307
|
+
let(:hosts) do
|
308
|
+
client.transport.hosts
|
309
|
+
end
|
310
|
+
|
311
|
+
it 'extracts the cloud credentials' do
|
312
|
+
expect(hosts[0][:host]).to eq('abcd.localhost')
|
313
|
+
expect(hosts[0][:protocol]).to eq('https')
|
314
|
+
expect(hosts[0][:user]).to eq('elasticfantastic')
|
315
|
+
expect(hosts[0][:password]).to eq('tobechanged')
|
316
|
+
expect(hosts[0][:port]).to eq(9243)
|
317
|
+
end
|
318
|
+
|
319
|
+
it 'creates the correct full url' do
|
320
|
+
expect(client.transport.__full_url(client.transport.hosts[0])).to eq('https://elasticfantastic:tobechanged@abcd.localhost:9243')
|
321
|
+
end
|
322
|
+
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
130
326
|
shared_examples_for 'a client that extracts hosts' do
|
131
327
|
|
132
328
|
context 'when the hosts are a String' do
|
@@ -1053,6 +1249,141 @@ describe Elasticsearch::Transport::Client do
|
|
1053
1249
|
}.to raise_exception(Elasticsearch::Transport::Transport::Errors::BadRequest)
|
1054
1250
|
end
|
1055
1251
|
end
|
1252
|
+
|
1253
|
+
context 'when the \'compression\' option is set to true' do
|
1254
|
+
|
1255
|
+
context 'when using Faraday as the transport' do
|
1256
|
+
|
1257
|
+
context 'when using the Net::HTTP adapter' do
|
1258
|
+
|
1259
|
+
let(:client) do
|
1260
|
+
described_class.new(hosts: ELASTICSEARCH_HOSTS, compression: true, adapter: :net_http)
|
1261
|
+
end
|
1262
|
+
|
1263
|
+
it 'compresses the request and decompresses the response' do
|
1264
|
+
expect(client.perform_request('GET', '/').body).to be_a(Hash)
|
1265
|
+
end
|
1266
|
+
|
1267
|
+
it 'sets the Accept-Encoding header' do
|
1268
|
+
expect(client.transport.connections[0].connection.headers['Accept-Encoding'])
|
1269
|
+
end
|
1270
|
+
|
1271
|
+
it 'preserves the other headers' do
|
1272
|
+
expect(client.transport.connections[0].connection.headers['User-Agent'])
|
1273
|
+
end
|
1274
|
+
end
|
1275
|
+
|
1276
|
+
context 'when using the HTTPClient adapter' do
|
1277
|
+
|
1278
|
+
let(:client) do
|
1279
|
+
described_class.new(hosts: ELASTICSEARCH_HOSTS, compression: true, adapter: :httpclient)
|
1280
|
+
end
|
1281
|
+
|
1282
|
+
it 'compresses the request and decompresses the response' do
|
1283
|
+
expect(client.perform_request('GET', '/').body).to be_a(Hash)
|
1284
|
+
end
|
1285
|
+
|
1286
|
+
it 'sets the Accept-Encoding header' do
|
1287
|
+
expect(client.transport.connections[0].connection.headers['Accept-Encoding'])
|
1288
|
+
end
|
1289
|
+
|
1290
|
+
it 'preserves the other headers' do
|
1291
|
+
expect(client.transport.connections[0].connection.headers['User-Agent'])
|
1292
|
+
end
|
1293
|
+
end
|
1294
|
+
|
1295
|
+
context 'when using the Patron adapter', unless: jruby? do
|
1296
|
+
|
1297
|
+
let(:client) do
|
1298
|
+
described_class.new(hosts: ELASTICSEARCH_HOSTS, compression: true, adapter: :patron)
|
1299
|
+
end
|
1300
|
+
|
1301
|
+
it 'compresses the request and decompresses the response' do
|
1302
|
+
expect(client.perform_request('GET', '/').body).to be_a(Hash)
|
1303
|
+
end
|
1304
|
+
|
1305
|
+
it 'sets the Accept-Encoding header' do
|
1306
|
+
expect(client.transport.connections[0].connection.headers['Accept-Encoding'])
|
1307
|
+
end
|
1308
|
+
|
1309
|
+
it 'preserves the other headers' do
|
1310
|
+
expect(client.transport.connections[0].connection.headers['User-Agent'])
|
1311
|
+
end
|
1312
|
+
end
|
1313
|
+
|
1314
|
+
context 'when using the Net::HTTP::Persistent adapter' do
|
1315
|
+
|
1316
|
+
let(:client) do
|
1317
|
+
described_class.new(hosts: ELASTICSEARCH_HOSTS, compression: true, adapter: :net_http_persistent)
|
1318
|
+
end
|
1319
|
+
|
1320
|
+
it 'compresses the request and decompresses the response' do
|
1321
|
+
expect(client.perform_request('GET', '/').body).to be_a(Hash)
|
1322
|
+
end
|
1323
|
+
|
1324
|
+
it 'sets the Accept-Encoding header' do
|
1325
|
+
expect(client.transport.connections[0].connection.headers['Accept-Encoding'])
|
1326
|
+
end
|
1327
|
+
|
1328
|
+
it 'preserves the other headers' do
|
1329
|
+
expect(client.transport.connections[0].connection.headers['User-Agent'])
|
1330
|
+
end
|
1331
|
+
end
|
1332
|
+
|
1333
|
+
context 'when using the Typhoeus adapter' do
|
1334
|
+
|
1335
|
+
let(:client) do
|
1336
|
+
described_class.new(hosts: ELASTICSEARCH_HOSTS, compression: true, adapter: :typhoeus)
|
1337
|
+
end
|
1338
|
+
|
1339
|
+
it 'compresses the request and decompresses the response' do
|
1340
|
+
expect(client.perform_request('GET', '/').body).to be_a(Hash)
|
1341
|
+
end
|
1342
|
+
|
1343
|
+
it 'sets the Accept-Encoding header' do
|
1344
|
+
expect(client.transport.connections[0].connection.headers['Accept-Encoding'])
|
1345
|
+
end
|
1346
|
+
|
1347
|
+
it 'preserves the other headers' do
|
1348
|
+
expect(client.transport.connections[0].connection.headers['User-Agent'])
|
1349
|
+
end
|
1350
|
+
end
|
1351
|
+
end
|
1352
|
+
end
|
1353
|
+
|
1354
|
+
context 'when using Curb as the transport', unless: jruby? do
|
1355
|
+
|
1356
|
+
let(:client) do
|
1357
|
+
described_class.new(hosts: ELASTICSEARCH_HOSTS,
|
1358
|
+
compression: true,
|
1359
|
+
transport_class: Elasticsearch::Transport::Transport::HTTP::Curb)
|
1360
|
+
end
|
1361
|
+
|
1362
|
+
it 'compresses the request and decompresses the response' do
|
1363
|
+
expect(client.perform_request('GET', '/').body).to be_a(Hash)
|
1364
|
+
end
|
1365
|
+
|
1366
|
+
it 'sets the Accept-Encoding header' do
|
1367
|
+
expect(client.transport.connections[0].connection.headers['Accept-Encoding'])
|
1368
|
+
end
|
1369
|
+
|
1370
|
+
it 'preserves the other headers' do
|
1371
|
+
expect(client.transport.connections[0].connection.headers['User-Agent'])
|
1372
|
+
end
|
1373
|
+
end
|
1374
|
+
|
1375
|
+
context 'when using Manticore as the transport', if: jruby? do
|
1376
|
+
|
1377
|
+
let(:client) do
|
1378
|
+
described_class.new(hosts: ELASTICSEARCH_HOSTS,
|
1379
|
+
compression: true,
|
1380
|
+
transport_class: Elasticsearch::Transport::Transport::HTTP::Manticore)
|
1381
|
+
end
|
1382
|
+
|
1383
|
+
it 'compresses the request and decompresses the response' do
|
1384
|
+
expect(client.perform_request('GET', '/').body).to be_a(Hash)
|
1385
|
+
end
|
1386
|
+
end
|
1056
1387
|
end
|
1057
1388
|
|
1058
1389
|
describe '#perform_request' do
|
@@ -1064,7 +1395,7 @@ describe Elasticsearch::Transport::Client do
|
|
1064
1395
|
client.perform_request('DELETE', 'myindex') rescue
|
1065
1396
|
client.perform_request('PUT', 'myindex', {}, { settings: { number_of_shards: 2, number_of_replicas: 0 } })
|
1066
1397
|
client.perform_request('PUT', 'myindex/mydoc/1', { routing: 'XYZ', timeout: '1s' }, { foo: 'bar' })
|
1067
|
-
client.perform_request('GET', '_cluster/health?wait_for_status=green', {})
|
1398
|
+
client.perform_request('GET', '_cluster/health?wait_for_status=green&timeout=2s', {})
|
1068
1399
|
end
|
1069
1400
|
|
1070
1401
|
let(:response) do
|
@@ -1,19 +1,6 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V
|
2
|
-
#
|
3
|
-
#
|
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.
|
1
|
+
# Licensed to Elasticsearch B.V under one or more agreements.
|
2
|
+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
3
|
+
# See the LICENSE file in the project root for more information
|
17
4
|
|
18
5
|
require 'spec_helper'
|
19
6
|
|
data/spec/spec_helper.rb
CHANGED
@@ -4,6 +4,12 @@ require 'logger'
|
|
4
4
|
require 'ansi/code'
|
5
5
|
require 'hashie/mash'
|
6
6
|
require 'pry-nav'
|
7
|
+
if defined?(JRUBY_VERSION)
|
8
|
+
require 'elasticsearch/transport/transport/http/manticore'
|
9
|
+
else
|
10
|
+
require 'elasticsearch/transport/transport/http/curb'
|
11
|
+
require 'curb'
|
12
|
+
end
|
7
13
|
|
8
14
|
# The hosts to use for creating a elasticsearch client.
|
9
15
|
#
|
@@ -1,19 +1,6 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V
|
2
|
-
#
|
3
|
-
#
|
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.
|
1
|
+
# Licensed to Elasticsearch B.V under one or more agreements.
|
2
|
+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
3
|
+
# See the LICENSE file in the project root for more information
|
17
4
|
|
18
5
|
require 'test_helper'
|
19
6
|
|
@@ -1,19 +1,6 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V
|
2
|
-
#
|
3
|
-
#
|
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.
|
1
|
+
# Licensed to Elasticsearch B.V under one or more agreements.
|
2
|
+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
3
|
+
# See the LICENSE file in the project root for more information
|
17
4
|
|
18
5
|
require 'test_helper'
|
19
6
|
|
data/test/test_helper.rb
CHANGED
@@ -1,19 +1,6 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V
|
2
|
-
#
|
3
|
-
#
|
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.
|
1
|
+
# Licensed to Elasticsearch B.V under one or more agreements.
|
2
|
+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
3
|
+
# See the LICENSE file in the project root for more information
|
17
4
|
|
18
5
|
|
19
6
|
ELASTICSEARCH_HOSTS = if hosts = ENV['TEST_ES_SERVER'] || ENV['ELASTICSEARCH_HOSTS']
|
@@ -1,19 +1,6 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V
|
2
|
-
#
|
3
|
-
#
|
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.
|
1
|
+
# Licensed to Elasticsearch B.V under one or more agreements.
|
2
|
+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
3
|
+
# See the LICENSE file in the project root for more information
|
17
4
|
|
18
5
|
require 'test_helper'
|
19
6
|
|
data/test/unit/response_test.rb
CHANGED
@@ -1,19 +1,6 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V
|
2
|
-
#
|
3
|
-
#
|
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.
|
1
|
+
# Licensed to Elasticsearch B.V under one or more agreements.
|
2
|
+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
3
|
+
# See the LICENSE file in the project root for more information
|
17
4
|
|
18
5
|
require 'test_helper'
|
19
6
|
|
@@ -1,19 +1,6 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V
|
2
|
-
#
|
3
|
-
#
|
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.
|
1
|
+
# Licensed to Elasticsearch B.V under one or more agreements.
|
2
|
+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
3
|
+
# See the LICENSE file in the project root for more information
|
17
4
|
|
18
5
|
require 'test_helper'
|
19
6
|
|
@@ -1,19 +1,6 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V
|
2
|
-
#
|
3
|
-
#
|
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.
|
1
|
+
# Licensed to Elasticsearch B.V under one or more agreements.
|
2
|
+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
3
|
+
# See the LICENSE file in the project root for more information
|
17
4
|
|
18
5
|
require 'test_helper'
|
19
6
|
|
@@ -1,19 +1,6 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V
|
2
|
-
#
|
3
|
-
#
|
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.
|
1
|
+
# Licensed to Elasticsearch B.V under one or more agreements.
|
2
|
+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
3
|
+
# See the LICENSE file in the project root for more information
|
17
4
|
|
18
5
|
require 'test_helper'
|
19
6
|
|
@@ -57,7 +44,7 @@ else
|
|
57
44
|
should "perform request with headers" do
|
58
45
|
@transport.connections.first.connection.expects(:put_data=).with('{"foo":"bar"}')
|
59
46
|
@transport.connections.first.connection.expects(:http).with(:POST).returns(stub_everything)
|
60
|
-
@transport.connections.first.connection.expects(:
|
47
|
+
@transport.connections.first.connection.headers.expects(:merge!).with("Content-Type" => "application/x-ndjson")
|
61
48
|
|
62
49
|
@transport.perform_request 'POST', '/', {}, {:foo => 'bar'}, {"Content-Type" => "application/x-ndjson"}
|
63
50
|
end
|
@@ -1,19 +1,6 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V
|
2
|
-
#
|
3
|
-
#
|
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.
|
1
|
+
# Licensed to Elasticsearch B.V under one or more agreements.
|
2
|
+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
3
|
+
# See the LICENSE file in the project root for more information
|
17
4
|
|
18
5
|
require 'test_helper'
|
19
6
|
|