Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed generate_api workflow #266

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/generate_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-unreleased.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 21 additions & 16 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
23 changes: 14 additions & 9 deletions spec/opensearch/transport/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1762,48 +1762,53 @@
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
client.transport.connections.first.connection.builder.adapter
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
Expand Down
Loading