Skip to content

Commit 5e83b6b

Browse files
committed
[API] Refactors custom wipe cluster cleanup
1 parent 4eafd9b commit 5e83b6b

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
module Elasticsearch
19+
module RestAPIYAMLTests
20+
# Custom functions for wipe cluster
21+
module CustomCleanup
22+
class << self
23+
def wipe_calendars(client)
24+
calendars = client.ml.get_calendars(calendar_id: '_all').body['calendars']
25+
calendars.each do |calendar|
26+
client.ml.delete_calendar(calendar_id: calendar['calendar_id'])
27+
end
28+
end
29+
end
30+
end
31+
end
32+
end

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# under the License.
1717

1818
require_relative 'logging'
19+
require_relative 'custom_cleanup'
1920
include Elasticsearch::RestAPIYAMLTests::Logging
2021

2122
module Elasticsearch
@@ -79,20 +80,15 @@ def wipe_cluster(client)
7980
# clear_ml_filters(client)
8081
# clear_tasks(client)
8182
# clear_transforms(client)
82-
wipe_calendars(client)
83+
84+
# Custom implementations
85+
CustomCleanup::wipe_calendars(client)
8386
end
8487

8588
def ensure_no_initializing_shards(client)
8689
client.cluster.health(wait_for_no_initializing_shards: true, timeout: '70s', level: 'shards')
8790
end
8891

89-
def wipe_calendars(client)
90-
calendars = client.ml.get_calendars(calendar_id: '_all').body['calendars']
91-
calendars.each do |calendar|
92-
client.ml.delete_calendar(calendar_id: calendar['calendar_id'])
93-
end
94-
end
95-
9692
def check_for_unexpectedly_recreated_objects(client)
9793
unexpected_ilm_policies = client.index_lifecycle_management.get_lifecycle
9894
unexpected_ilm_policies.reject! { |k, _| PRESERVE_ILM_POLICY_IDS.include? k }

0 commit comments

Comments
 (0)