spec/elasticsearch/transport/client_spec.rb in elasticsearch-transport-6.8.2 vs spec/elasticsearch/transport/client_spec.rb in elasticsearch-transport-6.8.3

- old
+ new

@@ -101,33 +101,45 @@ it 'uses Faraday NetHttp' do expect(adapter).to eq Faraday::Adapter::NetHttp end end - context 'when the adapter is specified' do - + context 'when the adapter is patron' do let(:adapter) do client.transport.connections.all.first.connection.builder.adapter end let(:client) do - described_class.new(adapter: :patron) + described_class.new(adapter: :patron, enable_meta_header: false) end it 'uses Faraday with the adapter' do expect(adapter).to eq Faraday::Adapter::Patron end end - context 'when the adapter is specified as a string key' do + context 'when the adapter is typhoeus' do + let(:adapter) do + client.transport.connections.all.first.connection.builder.adapter + end + let(:client) do + described_class.new(adapter: :typhoeus, enable_meta_header: false) + end + + it 'uses Faraday with the adapter' do + expect(adapter).to eq Faraday::Adapter::Typhoeus + end + end + + context 'when the adapter is specified as a string key' do let(:adapter) do client.transport.connections.all.first.connection.builder.adapter end let(:client) do - described_class.new('adapter' => :patron) + described_class.new('adapter' => :patron, enable_meta_header: false) end it 'uses Faraday with the adapter' do expect(adapter).to eq Faraday::Adapter::Patron end @@ -216,11 +228,10 @@ expect(hosts[0][:port]).to be(8080) end end context 'when credentials are specified' do - let(:host) do 'http://USERNAME:PASSWORD@myhost:8080' end it 'extracts the host' do @@ -1007,9 +1018,36 @@ client.transport.connections.first.connection.builder.adapter end it 'uses the patron connection handler' do expect(adapter).to eq('Faraday::Adapter::Patron') + end + + it 'keeps connections open' do + response = client.perform_request('GET', '_nodes/stats/http') + connections_before = response.body['nodes'].values.find { |n| n['name'] == node_names.first }['http']['total_opened'] + client.transport.reload_connections! + response = client.perform_request('GET', '_nodes/stats/http') + connections_after = response.body['nodes'].values.find { |n| n['name'] == node_names.first }['http']['total_opened'] + expect(connections_after).to be >= (connections_before) + end + end + + context 'when typhoeus is used as an adapter', unless: jruby? do + before do + require 'typhoeus' + end + + let(:options) do + { adapter: :typhoeus } + end + + let(:adapter) do + client.transport.connections.first.connection.builder.adapter + end + + it 'uses the patron connection handler' do + expect(adapter).to eq('Faraday::Adapter::Typhoeus') end it 'keeps connections open' do response = client.perform_request('GET', '_nodes/stats/http') connections_before = response.body['nodes'].values.find { |n| n['name'] == node_names.first }['http']['total_opened']