Skip to content

Commit a8861ce

Browse files
committed
Updates logger in wipe_cluster
1 parent 38025e2 commit a8861ce

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

elasticsearch-api/api-spec-testing/wipe_cluster.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
require_relative 'logging'
1918
require_relative 'custom_cleanup'
20-
include Elasticsearch::RestAPIYAMLTests::Logging
2119

2220
module Elasticsearch
2321
module RestAPIYAMLTests
@@ -151,7 +149,7 @@ def check_for_unexpectedly_recreated_objects(client)
151149
unexpected_ilm_policies = client.index_lifecycle_management.get_lifecycle
152150
unexpected_ilm_policies.reject! { |k, _| preserve_policy?(k) }
153151
unless unexpected_ilm_policies.empty?
154-
logger.info(
152+
client.logger.info(
155153
"Expected no ILM policies after deletions, but found #{unexpected_ilm_policies.keys.join(',')}"
156154
)
157155
end
@@ -166,7 +164,7 @@ def check_for_unexpectedly_recreated_objects(client)
166164
unexpected_templates << legacy_templates.keys.reject { |t| platinum_template?(t) }
167165

168166
unless unexpected_templates.reject(&:empty?).empty?
169-
logger.info(
167+
client.logger.info(
170168
"Expected no templates after deletions, but found #{unexpected_templates.join(',')}"
171169
)
172170
end
@@ -211,7 +209,7 @@ def wait_for_pending_rollup_tasks(client)
211209
end
212210
break unless count.positive? && Time.now.to_i < (start_time + 1)
213211
end
214-
logger.debug("Waited for #{count} pending rollup tasks for #{Time.now.to_i - start_time}s.") if count.positive?
212+
client.logger.debug("Waited for #{count} pending rollup tasks for #{Time.now.to_i - start_time}s.") if count.positive?
215213
end
216214

217215
def delete_all_slm_policies(client)
@@ -247,7 +245,7 @@ def wipe_snapshots(client)
247245
response = client.snapshot.get(repository: repository, snapshot: '_all', ignore_unavailable: true)
248246
response['snapshots'].each do |snapshot|
249247
if snapshot['state'] != 'SUCCESS'
250-
logger.debug("Found snapshot that did not succeed #{snapshot}")
248+
client.logger.debug("Found snapshot that did not succeed #{snapshot}")
251249
end
252250
client.snapshot.delete(repository: repository, snapshot: snapshot['snapshot'], ignore: 404)
253251
end
@@ -261,7 +259,7 @@ def wipe_datastreams(client)
261259
begin
262260
client.indices.delete_data_stream(name: '*', expand_wildcards: 'all')
263261
rescue StandardError => e
264-
logger.error "Caught exception attempting to delete data streams: #{e}"
262+
client.logger.error "Caught exception attempting to delete data streams: #{e}"
265263
client.indices.delete_data_stream(name: '*')
266264
end
267265
end
@@ -290,14 +288,13 @@ def wipe_all_templates(client)
290288
end
291289

292290
# Always check for legacy templates
293-
templates = client.indices.get_template
294-
templates.each do |name, _|
291+
client.indices.get_template.each_key do |name|
295292
next if platinum_template?(name)
296293

297294
begin
298295
client.indices.delete_template(name: name)
299296
rescue StandardError => e
300-
logger.info("Unable to remove index template #{name}")
297+
client.logger.info("Unable to remove index template #{name} - #{e}")
301298
end
302299
end
303300
end
@@ -331,7 +328,6 @@ def wait_for_cluster_tasks(client)
331328
end
332329
break unless count.positive? && Time.now.to_i < (start_time + 5)
333330
end
334-
logger.debug("Waited for #{count} pending cluster tasks for #{Time.now.to_i - start_time}s.") if count.positive?
335331
end
336332

337333
def skippable_task?(task)

elasticsearch-api/spec/rest_api/rest_api_yaml_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def skip_test?(test)
8686
run_rspec_matchers_on_task_group(task_group, test)
8787
end
8888
rescue StandardError => e
89-
LOGGER.error e
89+
LOGGER.error "#{context_name} - #{e}"
9090
raise e
9191
end
9292
end

0 commit comments

Comments
 (0)