Skip to content

Commit

Permalink
Ruby 2.6 works with faraday-typhoeus now (#88) (#90)
Browse files Browse the repository at this point in the history
- Gemfile restrictions and README adjusted accordingly. No app changes.
- Patron tests don't work with Faraday 2 and JRuby, because Patron is
  now required for the Patron tests, and it doesn't support JRuby.
- Add a response assertion to the Typhoeus intergration tests.

Signed-off-by: Brian Hawley <[email protected]>
(cherry picked from commit 06758a9)

Co-authored-by: Brian Hawley <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and BrianHawley authored Jul 11, 2022
1 parent 6daa5cf commit 4df0e3b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion opensearch-transport/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ if File.exist? File.expand_path('../opensearch/opensearch.gemspec', __dir__)
gem 'opensearch-ruby', path: File.expand_path('../opensearch', __dir__), require: false
end

ENV['FARADAY_VERSION'] = '~> 1.0' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7')
gem 'faraday', ENV['FARADAY_VERSION'], require: false if ENV.key?('FARADAY_VERSION')

group :development, :test do
Expand Down
4 changes: 2 additions & 2 deletions opensearch-transport/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ If you don't use Bundler, you may need to require the library explicitly (like `

Currently these libraries will be automatically detected and used:
- [Patron](https://github.com/toland/patron) through [faraday-patron](https://github.com/lostisland/faraday-patron)
- [Typhoeus](https://github.com/typhoeus/typhoeus) through [faraday-typhoeus](https://github.com/dleavitt/faraday-typhoeus) for Faraday 2 or higher, or its built-in adapter for Faraday 1.
- [Typhoeus](https://github.com/typhoeus/typhoeus) through [faraday-typhoeus](https://github.com/dleavitt/faraday-typhoeus) for Faraday 2 or higher, or Faraday's built-in adapter for Faraday 1.
- [HTTPClient](https://rubygems.org/gems/httpclient) through [faraday-httpclient](https://github.com/lostisland/faraday-httpclient)
- [Net::HTTP::Persistent](https://rubygems.org/gems/net-http-persistent) through [faraday-net_http_persistent](https://github.com/lostisland/faraday-net_http_persistent)

**Note on [Typhoeus](https://github.com/typhoeus/typhoeus)**: You need to use v1.4.0 or up since older versions are not compatible with Faraday 1.0 or higher. You can't use Typhoeus with Faraday 2.0 or higher with Ruby versions less than 2.7 because [faraday-typhoeus](https://github.com/dleavitt/faraday-typhoeus) doesn't support it, so use Faraday 1.x and its built-in Typhoeus adapter.
**Note on [Typhoeus](https://github.com/typhoeus/typhoeus)**: You need to use v1.4.0 or up since older versions are not compatible with Faraday 1.0 or higher.

**Note on [Faraday](https://rubygems.org/gems/faraday)**: If you use Faraday 2.0 or higher, if the adapter is in a separate gem, you will likely need to declare that gem as well. Only the Net::HTTP adapter gem is included by default. Faraday 1.x includes most common adapter gems already.

Expand Down
2 changes: 1 addition & 1 deletion opensearch-transport/opensearch-transport.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'simplecov'
s.add_development_dependency 'test-unit', '~> 2'
s.add_development_dependency 'typhoeus', '~> 1.4'
s.add_development_dependency 'faraday-typhoeus' if !ENV.key?('FARADAY_VERSION') && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
s.add_development_dependency 'faraday-typhoeus' if !ENV.key?('FARADAY_VERSION') && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6')
s.add_development_dependency 'yard'

s.description = <<-DESC.gsub(/^ /, '')
Expand Down
6 changes: 3 additions & 3 deletions opensearch-transport/spec/opensearch/transport/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
end unless jruby?
end

context 'when the adapter is patron' do
context 'when the adapter is patron', unless: jruby? do
let(:adapter) do
client.transport.connections.all.first.connection.builder.adapter
end
Expand Down Expand Up @@ -275,7 +275,7 @@
end
end unless jruby?

context 'when the adapter is specified as a string key' do
context 'when the adapter is specified as a string key', unless: jruby? do
let(:adapter) do
client.transport.connections.all.first.connection.builder.adapter
end
Expand Down Expand Up @@ -305,7 +305,7 @@
end
end

context 'when the Faraday adapter is configured' do
context 'when the Faraday adapter is configured', unless: jruby? do

let(:client) do
described_class.new do |faraday|
Expand Down
6 changes: 5 additions & 1 deletion opensearch-transport/test/integration/transport_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ class OpenSearch::Transport::ClientIntegrationTest < Minitest::Test
end

client = OpenSearch::Transport::Client.new transport: transport
client.perform_request 'GET', ''
response = client.perform_request 'GET', ''

assert_respond_to(response.body, :to_hash)
assert_not_nil response.body['name']
assert_equal 'application/json; charset=UTF-8', response.headers['content-type']
end unless jruby?

should "allow to customize the Faraday adapter to NetHttpPersistent" do
Expand Down

0 comments on commit 4df0e3b

Please sign in to comment.