Skip to content

Satisfy all tests on 8.x branch #1075

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

Open
wants to merge 7 commits into
base: 8.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Handle security config for ES8
  • Loading branch information
sinisterchipmunk committed Apr 12, 2024
commit c1ccb4dc3d152b01a16d28ef2ee1ff0b8273428d
18 changes: 10 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ def admin_client

if test_suite == 'security'
transport_options.merge!(:ssl => { verify: false,
ca_path: CERT_DIR })
ca_path: defined?(CERT_DIR) ? CERT_DIR : nil
}.compact)

password = ENV['ELASTIC_PASSWORD']
user = ENV['ELASTIC_USER'] || 'elastic'
url = "https://#{user}:#{password}@#{host}:#{port}"
url = "https://#{user}:#{password}@#{host || 'localhost'}:#{port || 9200}"
else
url = "http://#{host || 'localhost'}:#{port || 9200}"
end
ENV['ELASTICSEARCH_URL'] ||= url
Elasticsearch::Client.new(host: url, transport_options: transport_options)
end
end
Expand Down Expand Up @@ -140,7 +142,7 @@ namespace :test do
end

desc "Run all tests in all subprojects"
task all: :wait_for_green do
task all: :wait_for_green_or_yellow do
subprojects.each do |project|
puts '-'*80
sh "cd #{project} && " +
Expand All @@ -151,20 +153,20 @@ namespace :test do
end
end

desc "Wait for elasticsearch cluster to be in green state"
task :wait_for_green do
desc "Wait for elasticsearch cluster to be in green or yellow state"
task :wait_for_green_or_yellow do
require 'elasticsearch'

ready = nil
5.times do |i|
begin
puts "Attempting to wait for green status: #{i + 1}"
if admin_client.cluster.health(wait_for_status: 'green', timeout: '50s')
puts "Attempting to wait for green or yellow status: #{i + 1}"
if admin_client.cluster.health(wait_for_status: 'yellow', timeout: '50s')
ready = true
break
end
rescue Elastic::Transport::Transport::Errors::RequestTimeout => ex
puts "Couldn't confirm green status.\n#{ex.inspect}."
puts "Couldn't confirm green or yellow status.\n#{ex.inspect}."
rescue Faraday::ConnectionFailed => ex
puts "Couldn't connect to Elasticsearch.\n#{ex.inspect}."
sleep(30)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ class ::DummyIndexingModelForRecreate

context 'when the index is not found' do
let(:logger) { nil }
let(:client) { Elasticsearch::Client.new(logger: logger) }
let(:client) { Elasticsearch::Client.new(logger: logger, transport_options: { ssl: { verify: false } }) }

before do
expect(DummyIndexingModelForRecreate).to receive(:client).at_most(3).times.and_return(client)
Expand Down
3 changes: 2 additions & 1 deletion elasticsearch-model/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
tracer.formatter = lambda { |s, d, p, m| "#{m.gsub(/^.*$/) { |n| ' ' + n }.ansi(:faint)}\n" }
Elasticsearch::Model.client = Elasticsearch::Client.new(
host: ELASTICSEARCH_URL,
tracer: (ENV['QUIET'] ? nil : tracer)
tracer: (ENV['QUIET'] ? nil : tracer),
transport_options: { :ssl => { verify: false } }
)
puts "Elasticsearch Version: #{Elasticsearch::Model.client.info['version']}"

Expand Down
3 changes: 2 additions & 1 deletion elasticsearch-persistence/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
#
# @since 6.0.0
DEFAULT_CLIENT = Elasticsearch::Client.new(host: ELASTICSEARCH_URL,
tracer: (ENV['QUIET'] ? nil : ::Logger.new(STDERR)))
tracer: (ENV['QUIET'] ? nil : ::Logger.new(STDERR)),
transport_options: { :ssl => { verify: false } })

class MyTestRepository
include Elasticsearch::Persistence::Repository
Expand Down
3 changes: 2 additions & 1 deletion elasticsearch-rails/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
tracer = ::Logger.new(STDERR)
tracer.formatter = lambda { |s, d, p, m| "#{m.gsub(/^.*$/) { |n| ' ' + n }.ansi(:faint)}\n" }
Elasticsearch::Model.client = Elasticsearch::Client.new host: ELASTICSEARCH_URL,
tracer: (ENV['QUIET'] ? nil : tracer)
tracer: (ENV['QUIET'] ? nil : tracer),
transport_options: { :ssl => { verify: false } }
puts "Elasticsearch Version: #{Elasticsearch::Model.client.info['version']}"

unless ActiveRecord::Base.connected?
Expand Down