Skip to content

Commit f3af8a3

Browse files
committed
[API] Refactors logging in wipe cluster
1 parent 895c77c commit f3af8a3

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

api-spec-testing/logging.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
require 'logger'
19+
20+
module Elasticsearch
21+
module RestAPIYAMLTests
22+
module Logging
23+
def logger
24+
@logger ||= Logger.new($stdout)
25+
end
26+
end
27+
end
28+
end

api-spec-testing/wipe_cluster.rb

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

18+
require_relative 'logging'
19+
include Elasticsearch::RestAPIYAMLTests::Logging
20+
1821
module Elasticsearch
1922
module RestAPIYAMLTests
2023
module WipeCluster
@@ -81,7 +84,7 @@ def wait_for_pending_tasks(client)
8184
results.each do |task|
8285
next if task.empty?
8386

84-
LOGGER.debug "Pending task: #{task}"
87+
logger.debug "Pending task: #{task}"
8588
count += 1 if task.include?(filter)
8689
end
8790
break unless count.positive? && Time.now.to_i < (time + 30)
@@ -97,7 +100,7 @@ def wait_for_cluster_tasks(client)
97100
results['tasks'].each do |task|
98101
next if task.empty?
99102

100-
LOGGER.debug "Pending cluster task: #{task}"
103+
logger.debug "Pending cluster task: #{task}"
101104
count += 1
102105
end
103106
break unless count.positive? && Time.now.to_i < (time + 30)
@@ -286,7 +289,7 @@ def clear_datastreams(client)
286289
begin
287290
client.xpack.indices.delete_data_stream(name: '*', expand_wildcards: 'all')
288291
rescue StandardError => e
289-
LOGGER.error "Caught exception attempting to delete data streams: #{e}"
292+
logger.error "Caught exception attempting to delete data streams: #{e}"
290293
client.xpack.indices.delete_data_stream(name: '*')
291294
end
292295
end

elasticsearch-xpack/spec/xpack/rest_api_yaml_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
after(:all) do
7171
test_file.teardown
72-
Elasticsearch::RestAPIYAMLTests::TestFile.wipe_cluster(ADMIN_CLIENT)
72+
Elasticsearch::RestAPIYAMLTests::WipeCluster.run(ADMIN_CLIENT)
7373
end
7474

7575
test.task_groups.each do |task_group|

0 commit comments

Comments
 (0)