diff --git a/.github/workflows/generate_api.yml b/.github/workflows/generate_api.yml index 5adece204..edcd6f48d 100644 --- a/.github/workflows/generate_api.yml +++ b/.github/workflows/generate_api.yml @@ -29,6 +29,7 @@ jobs: - name: Update bundler run: | sudo apt-get update + sudo apt-get install libcurl4-openssl-dev bundle install - name: Generate API diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5888ae8f4..364afafcb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,7 +48,7 @@ jobs: env: TEST_OPENSEARCH_SERVER: http://localhost:9250 PORT: 9250 - FARADAY_VERSION: '~> 1.0' + FARADAY_VERSION: '~> 1' strategy: fail-fast: false matrix: @@ -106,7 +106,6 @@ jobs: run: | sudo apt-get update sudo apt-get install libcurl4-openssl-dev - sudo apt-get install ca-certificates ruby -v bundle install - name: Test Client Security diff --git a/.github/workflows/test-unreleased.yml b/.github/workflows/test-unreleased.yml index 036bc2e49..f43c6417b 100644 --- a/.github/workflows/test-unreleased.yml +++ b/.github/workflows/test-unreleased.yml @@ -24,7 +24,7 @@ jobs: entry: - { ruby_version: '3.3', opensearch_ref: '1.x', jdk_version: '11' } - { ruby_version: '3.3', opensearch_ref: '2.x', jdk_version: '17' } - - { ruby_version: '3.3', opensearch_ref: 'main', jdk_version: '17' } + - { ruby_version: '3.3', opensearch_ref: 'main', jdk_version: '21' } steps: - uses: ruby/setup-ruby@v1 diff --git a/Gemfile b/Gemfile index 1edfa3201..7d8464312 100644 --- a/Gemfile +++ b/Gemfile @@ -28,19 +28,16 @@ source 'https://rubygems.org' gem 'opensearch-ruby', path: __dir__, require: false +# TODO: remove unnecessary dependencies gem 'ansi' gem 'bundler' gem 'cane' -gem 'faraday-httpclient' -gem 'faraday-net_http_persistent' gem 'hashie' -gem 'httpclient' gem 'jbuilder' gem 'jsonify' gem 'minitest', '~> 5' gem 'minitest-reporters', '~> 1' gem 'mocha', '~> 2' -gem 'net-http-persistent' gem 'pry' gem 'rake', '~> 13' gem 'rspec', '~> 3' @@ -50,19 +47,27 @@ gem 'rubocop-rspec' gem 'shoulda-context' gem 'simplecov', '~> 0.17', '< 0.18' gem 'test-unit', '~> 2' -gem 'typhoeus', '~> 1.4' gem 'webmock', '~> 2.0' gem 'yard' -gem 'curb' unless defined? JRUBY_VERSION -gem 'faraday-patron' unless defined? JRUBY_VERSION -gem 'patron' unless defined? JRUBY_VERSION +if defined? JRUBY_VERSION + gem 'manticore' + gem 'pry-nav' +else + gem 'curb' + gem 'require-prof' + gem 'ruby-prof' +end -gem 'require-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius) -gem 'ruby-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius) - -gem 'manticore' if defined? JRUBY_VERSION -gem 'pry-nav' if defined? JRUBY_VERSION - -gem 'faraday', ENV.fetch('FARADAY_VERSION', nil), require: false if ENV.key?('FARADAY_VERSION') -gem 'faraday-typhoeus' if !ENV.key?('FARADAY_VERSION') && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6') +if ENV.key?('FARADAY_VERSION') + gem 'faraday', ENV.fetch('FARADAY_VERSION'), require: false + gem 'httpclient' + gem 'net-http-persistent' + gem 'patron' unless defined? JRUBY_VERSION + gem 'typhoeus', '~> 1.4' +else + gem 'faraday-httpclient' + gem 'faraday-net_http_persistent' + gem 'faraday-patron' unless defined? JRUBY_VERSION + gem 'faraday-typhoeus' +end diff --git a/spec/opensearch/transport/client_spec.rb b/spec/opensearch/transport/client_spec.rb index b380b1164..6c5a8b3bc 100644 --- a/spec/opensearch/transport/client_spec.rb +++ b/spec/opensearch/transport/client_spec.rb @@ -1762,40 +1762,45 @@ end end - context 'when patron is used as an adapter', unless: jruby? do + context 'when typhoeus is used as an adapter', unless: jruby? do before do - require 'patron' + require 'typhoeus' end let(:options) do - { adapter: :patron } + { 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::Patron') + it 'uses the typhoeus connection handler' do + expect(adapter).to eq('Faraday::Adapter::Typhoeus') end it 'keeps connections open' do + puts 'Testing with _cat/health' + puts client.perform_request('GET', '_cat/health') + puts 'Performing GET _nodes/stats/http' response = client.perform_request('GET', '_nodes/stats/http') connections_before = response.body['nodes'].values.find { |n| n['name'] == node_names.first }['http']['total_opened'] + puts 'Start reloading connections' client.transport.reload_connections! + puts 'Connections reloaded' 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 + context 'when patron is used as an adapter', unless: jruby? do before do - require 'typhoeus' + require 'patron' end let(:options) do - { adapter: :typhoeus } + { adapter: :patron } end let(:adapter) do @@ -1803,7 +1808,7 @@ end it 'uses the patron connection handler' do - expect(adapter).to eq('Faraday::Adapter::Typhoeus') + expect(adapter).to eq('Faraday::Adapter::Patron') end it 'keeps connections open' do