Skip to content

Commit

Permalink
Test Runner: Refactors perform action for header
Browse files Browse the repository at this point in the history
  • Loading branch information
picandocodigo committed Oct 18, 2024
1 parent a8861ce commit d15fb17
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions elasticsearch-api/api-spec-testing/test_file/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,24 +141,12 @@ def perform_action(method, args, client, test)
@response = client.send(method, arguments)
client
when 'headers'
headers = prepare_arguments(args, test)
host = client.transport.instance_variable_get('@hosts')
transport_options = client.transport.instance_variable_get('@options')&.dig(:transport_options) || {}
if ENV['QUIET'] == 'true'
# todo: create a method on Elasticsearch::Client that can clone the client with new options
Elasticsearch::Client.new(
host: host,
transport_options: transport_options.merge(headers: headers)
)
else
Elasticsearch::Client.new(
host: host,
tracer: Logger.new($stdout),
transport_options: transport_options.merge(headers: headers)
)
end
when 'catch', 'warnings', 'allowed_warnings', 'allowed_warnings_regex', 'warnings_regex'
client
Elasticsearch::Client.new(
hosts: client.transport.hosts,
tracer: client.transport.tracer || nil,
transport_options: transport_options.merge(headers: prepare_arguments(args, test))
)
when 'put_trained_model_alias'
args.merge!('reassign' => true) unless args['reassign'] === false
@response = client.send(method, prepare_arguments(args, test))
Expand Down Expand Up @@ -187,6 +175,8 @@ def perform_action(method, args, client, test)
end
@response = client.send(method, prepare_arguments(args, test))
client
when 'catch', 'warnings', 'allowed_warnings', 'allowed_warnings_regex', 'warnings_regex'
client
else
@response = client.send(method, prepare_arguments(args, test))
client
Expand Down

0 comments on commit d15fb17

Please sign in to comment.