diff --git a/elasticsearch-api/spec/yaml-test-runner/run.rb b/elasticsearch-api/spec/yaml-test-runner/run.rb index c0167c5ec..701d26b80 100644 --- a/elasticsearch-api/spec/yaml-test-runner/run.rb +++ b/elasticsearch-api/spec/yaml-test-runner/run.rb @@ -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, @@ -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__)