elasticsearch-transport 5.0.5 → 6.8.3

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.
Files changed (42) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +5 -0
  3. data/README.md +88 -34
  4. data/Rakefile +14 -17
  5. data/elasticsearch-transport.gemspec +45 -63
  6. data/lib/elasticsearch/transport/client.rb +207 -67
  7. data/lib/elasticsearch/transport/redacted.rb +79 -0
  8. data/lib/elasticsearch/transport/transport/base.rb +28 -14
  9. data/lib/elasticsearch/transport/transport/connections/collection.rb +4 -0
  10. data/lib/elasticsearch/transport/transport/connections/connection.rb +5 -1
  11. data/lib/elasticsearch/transport/transport/connections/selector.rb +4 -0
  12. data/lib/elasticsearch/transport/transport/errors.rb +4 -0
  13. data/lib/elasticsearch/transport/transport/http/curb.rb +7 -2
  14. data/lib/elasticsearch/transport/transport/http/faraday.rb +11 -8
  15. data/lib/elasticsearch/transport/transport/http/manticore.rb +6 -1
  16. data/lib/elasticsearch/transport/transport/response.rb +4 -0
  17. data/lib/elasticsearch/transport/transport/serializer/multi_json.rb +4 -0
  18. data/lib/elasticsearch/transport/transport/sniffer.rb +31 -3
  19. data/lib/elasticsearch/transport/version.rb +5 -1
  20. data/lib/elasticsearch/transport.rb +5 -0
  21. data/lib/elasticsearch-transport.rb +4 -0
  22. data/spec/elasticsearch/transport/base_spec.rb +260 -0
  23. data/spec/elasticsearch/transport/client_spec.rb +1063 -0
  24. data/spec/elasticsearch/transport/meta_header_spec.rb +214 -0
  25. data/spec/elasticsearch/transport/sniffer_spec.rb +269 -0
  26. data/spec/spec_helper.rb +72 -0
  27. data/test/integration/transport_test.rb +9 -5
  28. data/test/profile/client_benchmark_test.rb +23 -25
  29. data/test/test_helper.rb +10 -0
  30. data/test/unit/connection_collection_test.rb +4 -0
  31. data/test/unit/connection_selector_test.rb +4 -0
  32. data/test/unit/connection_test.rb +4 -0
  33. data/test/unit/response_test.rb +5 -1
  34. data/test/unit/serializer_test.rb +4 -0
  35. data/test/unit/transport_base_test.rb +21 -1
  36. data/test/unit/transport_curb_test.rb +12 -0
  37. data/test/unit/transport_faraday_test.rb +16 -0
  38. data/test/unit/transport_manticore_test.rb +11 -0
  39. metadata +90 -76
  40. data/test/integration/client_test.rb +0 -237
  41. data/test/unit/client_test.rb +0 -366
  42. data/test/unit/sniffer_test.rb +0 -179
@@ -0,0 +1,214 @@
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 'spec_helper'
19
+
20
+ describe Elasticsearch::Transport::Client do
21
+ context 'meta-header' do
22
+ let(:subject) { client.transport.connections.first.connection.headers }
23
+ let(:client) { described_class.new }
24
+ let(:regexp) { /^[a-z]{1,}=[a-z0-9.\-]{1,}(?:,[a-z]{1,}=[a-z0-9._\-]+)*$/ }
25
+ let(:adapter) { :net_http }
26
+ let(:adapter_code) { "nh=#{defined?(Net::HTTP::VERSION) ? Net::HTTP::VERSION : Net::HTTP::HTTPVersion}" }
27
+ let(:meta_header) do
28
+ if jruby?
29
+ "es=#{meta_version},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},jv=#{ENV_JAVA['java.version']},jr=#{JRUBY_VERSION},fd=#{Faraday::VERSION},#{adapter_code}"
30
+ else
31
+ "es=#{meta_version},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},fd=#{Faraday::VERSION},#{adapter_code}"
32
+ end
33
+ end
34
+
35
+ context 'client_meta_version_' do
36
+ let(:version) { ['7.1.0-alpha', '7.11.0.pre.1', '8.0.0-beta', '8.0.0.beta.2']}
37
+
38
+ it 'converts the version to X.X.Xp' do
39
+ expect(client.send(:client_meta_version, '7.0.0-alpha')).to eq('7.0.0p')
40
+ expect(client.send(:client_meta_version, '7.11.0.pre.1')).to eq('7.11.0p')
41
+ expect(client.send(:client_meta_version, '8.1.0-beta')).to eq('8.1.0p')
42
+ expect(client.send(:client_meta_version, '8.0.0.beta.2')).to eq('8.0.0p')
43
+ expect(client.send(:client_meta_version, '12.16.4.pre')).to eq('12.16.4p')
44
+ end
45
+ end
46
+
47
+ # We are testing this method in the previous block, so now using it inside the test to make the
48
+ # Elasticsearch version in the meta header string dynamic
49
+ def meta_version
50
+ client.send(:client_meta_version, Elasticsearch::VERSION)
51
+ end
52
+
53
+ context 'single use of meta header' do
54
+ let(:client) do
55
+ described_class.new(adapter: adapter).tap do |klient|
56
+ allow(klient).to receive(:__build_connections)
57
+ end
58
+ end
59
+
60
+ it 'x-elastic-client-header value matches regexp' do
61
+ expect(subject['x-elastic-client-meta']).to match(regexp)
62
+ expect(subject).to include('x-elastic-client-meta' => meta_header)
63
+ end
64
+ end
65
+
66
+ context 'when using user-agent headers' do
67
+ let(:client) do
68
+ transport_options = { headers: { user_agent: 'My Ruby App' } }
69
+ described_class.new(transport_options: transport_options, adapter: adapter).tap do |klient|
70
+ allow(klient).to receive(:__build_connections)
71
+ end
72
+ end
73
+
74
+ it 'is friendly to previously set headers' do
75
+ expect(subject).to include(user_agent: 'My Ruby App')
76
+ expect(subject['x-elastic-client-meta']).to match(regexp)
77
+ expect(subject).to include('x-elastic-client-meta' => meta_header)
78
+ end
79
+ end
80
+
81
+ context 'when using API Key' do
82
+ let(:client) do
83
+ described_class.new(api_key: 'an_api_key', adapter: adapter)
84
+ end
85
+
86
+ let(:authorization_header) do
87
+ client.transport.connections.first.connection.headers['Authorization']
88
+ end
89
+
90
+ it 'adds the ApiKey header to the connection' do
91
+ expect(authorization_header).to eq('ApiKey an_api_key')
92
+ expect(subject['x-elastic-client-meta']).to match(regexp)
93
+ expect(subject).to include('x-elastic-client-meta' => meta_header)
94
+ end
95
+ end
96
+
97
+ context 'adapters' do
98
+ let(:meta_header) do
99
+ if jruby?
100
+ "es=#{meta_version},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},jv=#{ENV_JAVA['java.version']},jr=#{JRUBY_VERSION},fd=#{Faraday::VERSION}"
101
+ else
102
+ "es=#{meta_version},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},fd=#{Faraday::VERSION}"
103
+ end
104
+ end
105
+ let(:client) { described_class.new(adapter: adapter) }
106
+ let(:headers) { client.transport.connections.first.connection.headers }
107
+
108
+ context 'using net/http/persistent' do
109
+ let(:adapter) { :net_http_persistent }
110
+
111
+ it 'sets adapter in the meta header' do
112
+ require 'net/http/persistent'
113
+ expect(headers['x-elastic-client-meta']).to match(regexp)
114
+ meta = "#{meta_header},np=#{Net::HTTP::Persistent::VERSION}"
115
+ expect(headers).to include('x-elastic-client-meta' => meta)
116
+ end
117
+ end
118
+
119
+ context 'using httpclient' do
120
+ let(:adapter) { :httpclient }
121
+
122
+ it 'sets adapter in the meta header' do
123
+ require 'httpclient'
124
+ expect(headers['x-elastic-client-meta']).to match(regexp)
125
+ meta = "#{meta_header},hc=#{HTTPClient::VERSION}"
126
+ expect(headers).to include('x-elastic-client-meta' => meta)
127
+ end
128
+ end
129
+
130
+ context 'using typhoeus' do
131
+ let(:adapter) { :typhoeus }
132
+
133
+ it 'sets adapter in the meta header' do
134
+ require 'typhoeus'
135
+ expect(headers['x-elastic-client-meta']).to match(regexp)
136
+ meta = "#{meta_header},ty=#{Typhoeus::VERSION}"
137
+ expect(headers).to include('x-elastic-client-meta' => meta)
138
+ end
139
+ end
140
+
141
+ unless defined?(JRUBY_VERSION)
142
+ let(:adapter) { :patron }
143
+
144
+ context 'using patron' do
145
+ it 'sets adapter in the meta header' do
146
+ require 'patron'
147
+ expect(headers['x-elastic-client-meta']).to match(regexp)
148
+ meta = "#{meta_header},pt=#{Patron::VERSION}"
149
+ expect(headers).to include('x-elastic-client-meta' => meta)
150
+ end
151
+ end
152
+ end
153
+ end
154
+
155
+ if defined?(JRUBY_VERSION)
156
+ context 'when using manticore' do
157
+ let(:client) do
158
+ Elasticsearch::Client.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Manticore)
159
+ end
160
+ let(:subject) { client.transport.connections.first.connection.instance_variable_get("@options")[:headers]}
161
+
162
+ it 'sets manticore in the metaheader' do
163
+ expect(subject['x-elastic-client-meta']).to match(regexp)
164
+ expect(subject['x-elastic-client-meta']).to match(/mc=[0-9.]+/)
165
+ end
166
+ end
167
+ else
168
+ context 'when using curb' do
169
+ let(:client) do
170
+ Elasticsearch::Client.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Curb)
171
+ end
172
+
173
+ it 'sets curb in the metaheader' do
174
+ expect(subject['x-elastic-client-meta']).to match(regexp)
175
+ expect(subject['x-elastic-client-meta']).to match(/cl=[0-9.]+/)
176
+ end
177
+ end
178
+ end
179
+
180
+ context 'when using custom transport implementation' do
181
+ class MyTransport
182
+ include Elasticsearch::Transport::Transport::Base
183
+ def initialize(args); end
184
+ end
185
+ let(:client) { Elasticsearch::Client.new(transport_class: MyTransport) }
186
+ let(:subject){ client.instance_variable_get("@arguments")[:transport_options][:headers] }
187
+ let(:meta_header) do
188
+ if jruby?
189
+ "es=#{meta_version},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION},jv=#{ENV_JAVA['java.version']},jr=#{JRUBY_VERSION}"
190
+ else
191
+ "es=#{meta_version},rb=#{RUBY_VERSION},t=#{Elasticsearch::Transport::VERSION}"
192
+ end
193
+ end
194
+
195
+ it 'doesnae set any info about the implementation in the metaheader' do
196
+ expect(subject['x-elastic-client-meta']).to match(regexp)
197
+ expect(subject).to include('x-elastic-client-meta' => meta_header)
198
+ end
199
+ end
200
+
201
+ context 'when using a different service version' do
202
+ before do
203
+ stub_const("Elastic::META_HEADER_SERVICE_VERSION", [:ent, '8.0.0'])
204
+ end
205
+
206
+ let(:client) { Elasticsearch::Client.new }
207
+
208
+ it 'sets the service version in the metaheader' do
209
+ expect(subject['x-elastic-client-meta']).to match(regexp)
210
+ expect(subject['x-elastic-client-meta']).to start_with('ent=8.0.0')
211
+ end
212
+ end
213
+ end
214
+ end
@@ -0,0 +1,269 @@
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 'spec_helper'
19
+
20
+ describe Elasticsearch::Transport::Transport::Sniffer do
21
+
22
+ let(:transport) do
23
+ double('transport').tap do |t|
24
+ allow(t).to receive(:perform_request).and_return(response)
25
+ allow(t).to receive(:options).and_return(sniffer_timeout: 2)
26
+ end
27
+ end
28
+
29
+ let(:sniffer) do
30
+ described_class.new(transport)
31
+ end
32
+
33
+ let(:response) do
34
+ double('response').tap do |r|
35
+ allow(r).to receive(:body).and_return(raw_response)
36
+ end
37
+ end
38
+
39
+ let(:raw_response) do
40
+ { 'nodes' => { 'n1' => { 'http' => { 'publish_address' => publish_address } } } }
41
+ end
42
+
43
+ let(:publish_address) do
44
+ '127.0.0.1:9250'
45
+ end
46
+
47
+ describe '#initialize' do
48
+
49
+ it 'has a transport instance' do
50
+ expect(sniffer.transport).to be(transport)
51
+ end
52
+
53
+ it 'inherits the sniffer timeout from the transport object' do
54
+ expect(sniffer.timeout).to eq(2)
55
+ end
56
+ end
57
+
58
+ describe '#timeout' do
59
+
60
+ let(:sniffer) do
61
+ described_class.new(double('transport', options: {}))
62
+ end
63
+
64
+ before do
65
+ sniffer.timeout = 3
66
+ end
67
+
68
+ it 'allows the timeout to be configured' do
69
+ expect(sniffer.timeout).to eq(3)
70
+ end
71
+ end
72
+
73
+ describe '#hosts' do
74
+
75
+ let(:hosts) do
76
+ sniffer.hosts
77
+ end
78
+
79
+ context 'when the entire response is parsed' do
80
+
81
+ let(:raw_response) do
82
+ {
83
+ "cluster_name" => "elasticsearch_test",
84
+ "nodes" => {
85
+ "N1" => {
86
+ "name" => "Node 1",
87
+ "transport_address" => "127.0.0.1:9300",
88
+ "host" => "testhost1",
89
+ "ip" => "127.0.0.1",
90
+ "version" => "7.0.0",
91
+ "roles" => [
92
+ "master",
93
+ "data",
94
+ "ingest"
95
+ ],
96
+ "attributes" => {
97
+ "testattr" => "test"
98
+ },
99
+ "http" => {
100
+ "bound_address" => [
101
+ "[fe80::1]:9250",
102
+ "[::1]:9250",
103
+ "127.0.0.1:9250"
104
+ ],
105
+ "publish_address" => "127.0.0.1:9250",
106
+ "max_content_length_in_bytes" => 104857600
107
+ }
108
+ }
109
+ }
110
+ }
111
+ end
112
+
113
+ it 'parses the id' do
114
+ expect(sniffer.hosts[0][:id]).to eq('N1')
115
+ end
116
+
117
+ it 'parses the name' do
118
+ expect(sniffer.hosts[0][:name]).to eq('Node 1')
119
+ end
120
+
121
+ it 'parses the version' do
122
+ expect(sniffer.hosts[0][:version]).to eq('7.0.0')
123
+ end
124
+
125
+ it 'parses the host' do
126
+ expect(sniffer.hosts[0][:host]).to eq('127.0.0.1')
127
+ end
128
+
129
+ it 'parses the port' do
130
+ expect(sniffer.hosts[0][:port]).to eq('9250')
131
+ end
132
+
133
+ it 'parses the roles' do
134
+ expect(sniffer.hosts[0][:roles]).to eq(['master',
135
+ 'data',
136
+ 'ingest'])
137
+ end
138
+
139
+ it 'parses the attributes' do
140
+ expect(sniffer.hosts[0][:attributes]).to eq('testattr' => 'test')
141
+ end
142
+ end
143
+
144
+ context 'when the transport protocol does not match' do
145
+
146
+ let(:raw_response) do
147
+ { 'nodes' => { 'n1' => { 'foo' => { 'publish_address' => '127.0.0.1:9250' } } } }
148
+ end
149
+
150
+ it 'does not parse the addresses' do
151
+ expect(hosts).to eq([])
152
+ end
153
+ end
154
+
155
+ context 'when a list of nodes is returned' do
156
+
157
+ let(:raw_response) do
158
+ { 'nodes' => { 'n1' => { 'http' => { 'publish_address' => '127.0.0.1:9250' } },
159
+ 'n2' => { 'http' => { 'publish_address' => '127.0.0.1:9251' } } } }
160
+ end
161
+
162
+ it 'parses the response' do
163
+ expect(hosts.size).to eq(2)
164
+ end
165
+
166
+ it 'correctly parses the hosts' do
167
+ expect(hosts[0][:host]).to eq('127.0.0.1')
168
+ expect(hosts[1][:host]).to eq('127.0.0.1')
169
+ end
170
+
171
+ it 'correctly parses the ports' do
172
+ expect(hosts[0][:port]).to eq('9250')
173
+ expect(hosts[1][:port]).to eq('9251')
174
+ end
175
+ end
176
+
177
+ context 'when the host and port are an ip address and port' do
178
+
179
+ it 'parses the response' do
180
+ expect(hosts.size).to eq(1)
181
+ end
182
+
183
+ it 'correctly parses the host' do
184
+ expect(hosts[0][:host]).to eq('127.0.0.1')
185
+ end
186
+
187
+ it 'correctly parses the port' do
188
+ expect(hosts[0][:port]).to eq('9250')
189
+ end
190
+ end
191
+
192
+ context 'when the host and port are a hostname and port' do
193
+
194
+ let(:publish_address) do
195
+ 'testhost1.com:9250'
196
+ end
197
+
198
+ let(:hosts) do
199
+ sniffer.hosts
200
+ end
201
+
202
+ it 'parses the response' do
203
+ expect(hosts.size).to eq(1)
204
+ end
205
+
206
+ it 'correctly parses the host' do
207
+ expect(hosts[0][:host]).to eq('testhost1.com')
208
+ end
209
+
210
+ it 'correctly parses the port' do
211
+ expect(hosts[0][:port]).to eq('9250')
212
+ end
213
+ end
214
+
215
+ context 'when the host and port are in the format: hostname/ip:port' do
216
+
217
+ let(:publish_address) do
218
+ 'example.com/127.0.0.1:9250'
219
+ end
220
+
221
+ it 'parses the response' do
222
+ expect(hosts.size).to eq(1)
223
+ end
224
+
225
+ it 'uses the hostname' do
226
+ expect(hosts[0][:host]).to eq('example.com')
227
+ end
228
+
229
+ it 'correctly parses the port' do
230
+ expect(hosts[0][:port]).to eq('9250')
231
+ end
232
+ end
233
+
234
+ context 'when the address is IPv6' do
235
+
236
+ let(:publish_address) do
237
+ '[::1]:9250'
238
+ end
239
+
240
+ it 'parses the response' do
241
+ expect(hosts.size).to eq(1)
242
+ end
243
+
244
+ it 'correctly parses the host' do
245
+ expect(hosts[0][:host]).to eq('::1')
246
+ end
247
+
248
+ it 'correctly parses the port' do
249
+ expect(hosts[0][:port]).to eq('9250')
250
+ end
251
+ end
252
+
253
+ context 'when the transport has :randomize_hosts option' do
254
+
255
+ let(:raw_response) do
256
+ { 'nodes' => { 'n1' => { 'http' => { 'publish_address' => '127.0.0.1:9250' } },
257
+ 'n2' => { 'http' => { 'publish_address' => '127.0.0.1:9251' } } } }
258
+ end
259
+
260
+ before do
261
+ allow(transport).to receive(:options).and_return(randomize_hosts: true)
262
+ end
263
+
264
+ it 'shuffles the list' do
265
+ expect(hosts.size).to eq(2)
266
+ end
267
+ end
268
+ end
269
+ end
@@ -0,0 +1,72 @@
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
4
+
5
+ require 'elasticsearch'
6
+ require 'elasticsearch-transport'
7
+ require 'logger'
8
+ require 'ansi/code'
9
+ require 'hashie/mash'
10
+ require 'pry-nav'
11
+ if defined?(JRUBY_VERSION)
12
+ require 'elasticsearch/transport/transport/http/manticore'
13
+ require 'pry-nav'
14
+ else
15
+ require 'elasticsearch/transport/transport/http/curb'
16
+ require 'curb'
17
+ end
18
+
19
+ # The hosts to use for creating a elasticsearch client.
20
+ #
21
+ # @since 7.0.0
22
+ ELASTICSEARCH_HOSTS = if hosts = ENV['TEST_ES_SERVER'] || ENV['ELASTICSEARCH_HOSTS']
23
+ hosts.split(',').map do |host|
24
+ /(http\:\/\/)?(\S+)/.match(host)[2]
25
+ end
26
+ end.freeze
27
+
28
+ # Are we testing on JRuby?
29
+ #
30
+ # @return [ true, false ] Whether JRuby is being used.
31
+ #
32
+ # @since 7.0.0
33
+ def jruby?
34
+ RUBY_PLATFORM =~ /\bjava\b/
35
+ end
36
+
37
+ # The names of the connected nodes.
38
+ #
39
+ # @return [ Array<String> ] The node names.
40
+ #
41
+ # @since 7.0.0
42
+ def node_names
43
+ $node_names ||= default_client.nodes.stats['nodes'].collect do |name, stats|
44
+ stats['name']
45
+ end
46
+ end
47
+
48
+ # The default client.
49
+ #
50
+ # @return [ Elasticsearch::Client ] The default client.
51
+ #
52
+ # @since 7.0.0
53
+ def default_client
54
+ $client ||= Elasticsearch::Client.new(hosts: ELASTICSEARCH_HOSTS)
55
+ end
56
+
57
+ module Config
58
+
59
+ def self.included(context)
60
+
61
+ # Get the hosts to use to connect an elasticsearch client.
62
+ #
63
+ # @since 7.0.0
64
+ context.let(:hosts) { ELASTICSEARCH_HOSTS }
65
+ end
66
+ end
67
+
68
+ RSpec.configure do |config|
69
+ config.include(Config)
70
+ config.formatter = 'documentation'
71
+ config.color = true
72
+ end
@@ -1,3 +1,7 @@
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
4
+
1
5
  require 'test_helper'
2
6
 
3
7
  class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::IntegrationTestCase
@@ -11,7 +15,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
11
15
 
12
16
  context "Transport" do
13
17
  setup do
14
- @port = (ENV['TEST_CLUSTER_PORT'] || 9250).to_i
18
+ @host, @port = ELASTICSEARCH_HOSTS.first.split(':')
15
19
  begin; Object.send(:remove_const, :Patron); rescue NameError; end
16
20
  end
17
21
 
@@ -20,7 +24,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
20
24
  require 'typhoeus/adapters/faraday'
21
25
 
22
26
  transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new \
23
- :hosts => [ { :host => 'localhost', :port => @port } ] do |f|
27
+ :hosts => [ { host: @host, port: @port } ] do |f|
24
28
  f.response :logger
25
29
  f.adapter :typhoeus
26
30
  end
@@ -31,7 +35,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
31
35
 
32
36
  should "allow to define connection parameters and pass them" do
33
37
  transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new \
34
- :hosts => [ { :host => 'localhost', :port => @port } ],
38
+ :hosts => [ { host: @host, port: @port } ],
35
39
  :options => { :transport_options => {
36
40
  :params => { :format => 'yaml' }
37
41
  }
@@ -48,7 +52,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
48
52
  require 'elasticsearch/transport/transport/http/curb'
49
53
 
50
54
  transport = Elasticsearch::Transport::Transport::HTTP::Curb.new \
51
- :hosts => [ { :host => 'localhost', :port => @port } ] do |curl|
55
+ :hosts => [ { host: @host, port: @port } ] do |curl|
52
56
  curl.verbose = true
53
57
  end
54
58
 
@@ -61,7 +65,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
61
65
  require 'elasticsearch/transport/transport/http/curb'
62
66
 
63
67
  transport = Elasticsearch::Transport::Transport::HTTP::Curb.new \
64
- :hosts => [ { :host => 'localhost', :port => @port } ] do |curl|
68
+ :hosts => [ { host: @host, port: @port } ] do |curl|
65
69
  curl.verbose = true
66
70
  end
67
71