Skip to content

Commit

Permalink
[CI] Handles mutex_m issue with Ruby 3.4 in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
picandocodigo committed Dec 27, 2024
1 parent 93cbc5c commit fd282f7
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ gemspec

group :development, :test do
gem 'faraday-httpclient'
gem 'mutex_m' if RUBY_VERSION >= '3.4'
gem 'faraday-net_http_persistent'
gem 'faraday-typhoeus'
gem 'faraday-excon'
Expand Down
29 changes: 29 additions & 0 deletions spec/elastic/adapters/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

source 'https://rubygems.org'

# $ BUNDLE_GEMFILE=./Gemfile-excon.gemfile bundle install
# $ BUNDLE_GEMFILE=./Gemfile-excon.gemfile bundle exec rake test:adapters
gemspec

gem 'rspec'
gem 'elasticsearch'

group :excon do
gem 'faraday-excon'
end
31 changes: 31 additions & 0 deletions spec/elastic/adapters/adapters_tests.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

namespace :test do
namespace :adapters do
desc 'Run excon test'
task :excon do
# sh "BUNDLE_GEMFILE=#{FARADAY1_GEMFILE} bundle exec rspec"
# test.test_files = FileList['']
# test.verbose = false
# test.warning = false
# sh "BUNDLE_GEMFILE=#{FARADAY1_GEMFILE} ruby -Ilib:test #{test}"
test = File.expand_path('./excon_spec.rb', __dir__)
sh "bundle exec rspec #{test}"
end
end
end
24 changes: 24 additions & 0 deletions spec/elastic/adapters/excon.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

source 'https://rubygems.org'

# $ BUNDLE_GEMFILE=./Gemfile-excon.gemfile bundle install
# $ BUNDLE_GEMFILE=./Gemfile-excon.gemfile bundle exec rake test:adapters
gemspec

gem 'faraday-excon'
62 changes: 62 additions & 0 deletions spec/elastic/adapters/excon_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

require 'bundler/inline'
gemfile do
source 'https://rubygems.org'

gem 'faraday-excon'
gem 'elasticsearch'
gem 'rspec'
gem 'debug'
gemspec
end

require 'elasticsearch'
require 'faraday/excon'
require 'spec_helper'

describe 'Excon Adapter' do
let(:client) do
Elasticsearch::Client.new(
hosts: ELASTICSEARCH_HOSTS,
adapter: :excon,
transport_options: { ssl: { verify: false } }
)
end

context 'Integrates with elasticsearch API' do
it 'should perform the API methods' do
expect do
# Index a document
client.index(index: 'test-index', id: '1', body: { title: 'Test' })

# Refresh the index
client.indices.refresh(index: 'test-index')

# Search
response = client.search(index: 'test-index', body: { query: { match: { title: 'test' } } })

expect(response['hits']['total']['value']).to eq 1
expect(response['hits']['hits'][0]['_source']['title']).to eq 'Test'

# Delete the index
client.indices.delete(index: 'test-index')
end.not_to raise_error
end
end
end
1 change: 1 addition & 0 deletions spec/elastic/transport/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,7 @@

context 'when using the HTTPClient adapter' do
require 'faraday/httpclient'
require 'mutex_m'

let(:client) do
described_class.new(hosts: ELASTICSEARCH_HOSTS, compression: true, adapter: :httpclient, enable_meta_header: false)
Expand Down

0 comments on commit fd282f7

Please sign in to comment.