Skip to content

Commit 38025e2

Browse files
committed
Updates logger for Elasticsearch rest specs
1 parent 22a96d5 commit 38025e2

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

elasticsearch-api/spec/rest_api/rest_api_tests_helper.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,21 @@
4848
transport_options = {}
4949
end
5050

51-
ADMIN_CLIENT = Elasticsearch::Client.new(host: host, transport_options: transport_options)
51+
# DEBUG: For easier debugging, set LOG_STDOUT env variable to true
52+
output = if ENV['LOG_STDOUT'] == 'true'
53+
$stdout
54+
else
55+
File.expand_path("../../tmp/tracer_log-#{ENV['TEST_SUITE']}-#{ENV['RUBY_VERSION']}.log", __dir__)
56+
end
57+
logger = Logger.new(output)
5258

59+
ADMIN_CLIENT = Elasticsearch::Client.new(host: host, transport_options: transport_options, tracer: logger)
5360
DEFAULT_CLIENT = if ENV['QUIET'] == 'true'
5461
Elasticsearch::Client.new(host: host, transport_options: transport_options)
5562
else
5663
Elasticsearch::Client.new(
5764
host: host,
58-
tracer: Logger.new($stdout),
65+
tracer: logger,
5966
transport_options: transport_options
6067
)
6168
end

elasticsearch-api/spec/rest_api/rest_api_yaml_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
require_relative 'rest_api_tests_helper'
2020
require_relative './run_rspec_matchers'
2121

22+
# LOGGER logs to stdout since we want to see if there are any errors in the running of the tests.
23+
# The client has a tracer/logger defined in ./rest_api_tests_helper.rb, ENV['LOG_STDOUT'] set to
24+
# true will log to stdout instead of a log file:
2225
LOGGER = Logger.new($stdout)
2326
CLUSTER_FEATURES = ADMIN_CLIENT.features.get_features['features'].map { |f| f['name'] }
2427

0 commit comments

Comments
 (0)