Skip to content

Commit

Permalink
[CI] Adds client options for running Serverless YAML tests
Browse files Browse the repository at this point in the history
  • Loading branch information
picandocodigo committed Jan 17, 2025
1 parent 61b8ff6 commit d7bc81b
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions elasticsearch-api/spec/yaml-test-runner/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@
password = ENV['ELASTIC_PASSWORD'] || 'changeme'
uri = URI.parse(host)

def serverless?
ENV['TEST_SUITE'] == 'serverless'
end

if uri.is_a?(URI::HTTPS)
raw_certificate = File.read("#{CERTS_PATH}/testnode.crt")
certificate = OpenSSL::X509::Certificate.new(raw_certificate)
raw_key = File.read("#{CERTS_PATH}/testnode.key")
key = OpenSSL::PKey::RSA.new(raw_key)
ca_file = File.expand_path("#{CERTS_PATH}/ca.crt")
host = "https://elastic:#{password}@#{uri.host}:#{uri.port}".freeze unless ENV['TEST_SUITE'] == 'serverless'
host = "https://elastic:#{password}@#{uri.host}:#{uri.port}".freeze unless serverless?
transport_options = {
ssl: {
client_cert: certificate,
Expand All @@ -49,8 +53,22 @@
transport_options = {}
end

options = { host: host, transport_options: transport_options, compression: true }
options = {
host: host,
transport_options: transport_options,
}
options.merge!({ api_key: ENV['ES_API_KEY'] }) if ENV['ES_API_KEY']

if serverless?
options.merge!(
{
retry_on_status: [409],
retry_on_failure: 10,
delay_on_retry: 60_000,
request_timeout: 120
}
)
end
CLIENT = Elasticsearch::Client.new(options)

tests_path = File.expand_path('./tmp', __dir__)
Expand Down

0 comments on commit d7bc81b

Please sign in to comment.