elasticsearch-transport 7.14.0 → 7.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/elasticsearch-transport.gemspec +4 -4
- data/lib/elasticsearch/transport/client.rb +31 -0
- data/lib/elasticsearch/transport/transport/base.rb +40 -20
- data/lib/elasticsearch/transport/transport/connections/connection.rb +2 -1
- data/lib/elasticsearch/transport/transport/http/curb.rb +6 -4
- data/lib/elasticsearch/transport/transport/http/faraday.rb +8 -7
- data/lib/elasticsearch/transport/transport/http/manticore.rb +7 -4
- data/lib/elasticsearch/transport/version.rb +1 -1
- data/lib/elasticsearch/transport.rb +1 -0
- data/spec/elasticsearch/transport/client_spec.rb +107 -24
- data/spec/elasticsearch/transport/http/curb_spec.rb +126 -0
- data/spec/elasticsearch/transport/http/faraday_spec.rb +141 -0
- data/spec/elasticsearch/transport/http/manticore_spec.rb +143 -0
- data/test/integration/jruby_test.rb +43 -0
- data/test/integration/transport_test.rb +18 -27
- data/test/unit/transport_manticore_test.rb +224 -155
- metadata +15 -7
@@ -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
|
@@ -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
|
@@ -29,6 +29,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
|
|
29
29
|
context "Transport" do
|
30
30
|
setup do
|
31
31
|
@host, @port = ELASTICSEARCH_HOSTS.first.split(':')
|
32
|
+
@hosts = { hosts: [ { host: @host, port: @port } ] }
|
32
33
|
begin; Object.send(:remove_const, :Patron); rescue NameError; end
|
33
34
|
end
|
34
35
|
|
@@ -36,11 +37,10 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
|
|
36
37
|
require 'typhoeus'
|
37
38
|
require 'typhoeus/adapters/faraday'
|
38
39
|
|
39
|
-
transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
40
|
+
transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new(@hosts) do |f|
|
41
|
+
f.response :logger
|
42
|
+
f.adapter :typhoeus
|
43
|
+
end
|
44
44
|
|
45
45
|
client = Elasticsearch::Transport::Client.new transport: transport
|
46
46
|
client.perform_request 'GET', ''
|
@@ -49,8 +49,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
|
|
49
49
|
should "allow to customize the Faraday adapter to NetHttpPersistent" do
|
50
50
|
require 'net/http/persistent'
|
51
51
|
|
52
|
-
transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new
|
53
|
-
:hosts => [ { host: @host, port: @port } ] do |f|
|
52
|
+
transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new(@hosts) do |f|
|
54
53
|
f.response :logger
|
55
54
|
f.adapter :net_http_persistent
|
56
55
|
end
|
@@ -60,13 +59,10 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
|
|
60
59
|
end
|
61
60
|
|
62
61
|
should "allow to define connection parameters and pass them" do
|
63
|
-
transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
62
|
+
transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new(
|
63
|
+
hosts: [ { host: @host, port: @port } ],
|
64
|
+
options: { transport_options: { params: { :format => 'yaml' } } }
|
65
|
+
)
|
70
66
|
client = Elasticsearch::Transport::Client.new transport: transport
|
71
67
|
response = client.perform_request 'GET', ''
|
72
68
|
|
@@ -76,24 +72,20 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
|
|
76
72
|
should "use the Curb client" do
|
77
73
|
require 'curb'
|
78
74
|
require 'elasticsearch/transport/transport/http/curb'
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
curl.verbose = true
|
83
|
-
end
|
75
|
+
transport = Elasticsearch::Transport::Transport::HTTP::Curb.new(@hosts) do |curl|
|
76
|
+
curl.verbose = true
|
77
|
+
end
|
84
78
|
|
85
79
|
client = Elasticsearch::Transport::Client.new transport: transport
|
86
80
|
client.perform_request 'GET', ''
|
87
|
-
end unless
|
81
|
+
end unless jruby?
|
88
82
|
|
89
83
|
should "deserialize JSON responses in the Curb client" do
|
90
84
|
require 'curb'
|
91
85
|
require 'elasticsearch/transport/transport/http/curb'
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
curl.verbose = true
|
96
|
-
end
|
86
|
+
transport = Elasticsearch::Transport::Transport::HTTP::Curb.new(@hosts) do |curl|
|
87
|
+
curl.verbose = true
|
88
|
+
end
|
97
89
|
|
98
90
|
client = Elasticsearch::Transport::Client.new transport: transport
|
99
91
|
response = client.perform_request 'GET', ''
|
@@ -101,7 +93,6 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
|
|
101
93
|
assert_respond_to(response.body, :to_hash)
|
102
94
|
assert_not_nil response.body['name']
|
103
95
|
assert_equal 'application/json', response.headers['content-type']
|
104
|
-
end unless
|
96
|
+
end unless jruby?
|
105
97
|
end
|
106
|
-
|
107
98
|
end
|