@@ -52,7 +52,11 @@ def self.run(client)
52
52
wipe_datastreams ( client )
53
53
wipe_all_indices ( client )
54
54
if platinum?
55
- clear_templates_platinum ( client )
55
+ wipe_templates_for_xpack ( client )
56
+ else
57
+ wipe_all_templates ( client )
58
+ end
59
+ if platinum?
56
60
clear_datafeeds ( client )
57
61
clear_ml_jobs ( client )
58
62
else
@@ -157,7 +161,7 @@ def clear_cluster_settings(client)
157
161
client . cluster . put_settings ( body : new_settings ) unless new_settings . empty?
158
162
end
159
163
160
- def clear_templates_platinum ( client )
164
+ def wipe_templates_for_xpack ( client )
161
165
templates = client . indices . get_index_template
162
166
163
167
templates [ 'index_templates' ] . each do |template |
@@ -178,16 +182,27 @@ def clear_templates_platinum(client)
178
182
179
183
# Always check for legacy templates
180
184
templates = client . indices . get_template
181
-
182
185
templates . each do |name , _ |
183
186
next if platinum_template? name
184
187
185
188
begin
186
189
client . indices . delete_template ( name : name )
190
+ rescue StandardError => e
191
+ Elasticsearch ::RestAPIYAMLTests ::Logging . logger . info ( "Unable to remove index template #{ name } " )
187
192
end
188
193
end
189
194
end
190
195
196
+ def wipe_all_templates ( client )
197
+ client . indices . delete_template ( name : '*' )
198
+ begin
199
+ client . indices . delete_index_template ( name : '*' )
200
+ client . cluster . delete_component_template ( name : '*' )
201
+ rescue StandardError => e
202
+ Elasticsearch ::RestAPIYAMLTests ::Logging . logger . info ( 'Using a version of ES that doesn\'t support index templates v2 yet, so it\'s safe to ignore' )
203
+ end
204
+ end
205
+
191
206
def platinum_template? ( template )
192
207
platinum_prefixes = [ '.monitoring' , '.watch' , '.triggered-watches' , '.data-frame' , '.ml-' , '.transform' , 'data-streams-mappings' ] . freeze
193
208
platinum_prefixes . map { |a | return true if a . include? template }
0 commit comments