Skip to content

Commit e7f85a7

Browse files
committed
[API] Test Runner: Updates wiping snapshots
1 parent e12497c commit e7f85a7

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def self.run(client)
4747
clear_sml_policies(client)
4848
wipe_searchable_snapshot_indices(client)
4949
end
50-
clear_snapshots_and_repositories(client)
50+
wipe_snapshots(client)
5151
wipe_datastreams(client)
5252
wipe_all_indices(client)
5353
if platinum?
@@ -257,22 +257,18 @@ def clear_index_templates(client)
257257
end
258258
end
259259

260-
def clear_snapshots_and_repositories(client)
260+
def wipe_snapshots(client)
261261
return unless (repositories = client.snapshot.get_repository(repository: '_all'))
262262

263263
repositories.each_key do |repository|
264-
client.snapshot.delete(repository: repository, snapshot: '*', ignore: 404) if repositories[repository]['type'] == 'fs'
265-
begin
266-
response = client.perform_request('DELETE', "_snapshot/#{repository}", ignore: [500, 404])
267-
client.snapshot.delete_repository(repository: repository, ignore: 404)
268-
rescue Elastic::Transport::Transport::Errors::InternalServerError => e
269-
regexp = /indices that use the repository: \[docs\/([a-zA-Z0-9]+)/
270-
raise e unless response.body['error']['root_cause'].first['reason'].match(regexp)
271-
272-
# Try again after clearing indices if we get a 500 error from delete repository
273-
wipe_all_indices(client)
274-
client.snapshot.delete_repository(repository: repository, ignore: 404)
264+
if repositories[repository]['type'] == 'fs'
265+
response = client.snapshot.get(repository: repository, snapshot: '_all', ignore_unavailable: true)
266+
# response ={"snapshots"=>[], "total"=>0, "remaining"=>0}
267+
response['snapshots'].each do |snapshot|
268+
client.snapshot.delete(repository: repository, snapshot: snapshot['snapshot'], ignore: 404)
269+
end
275270
end
271+
client.snapshot.delete_repository(repository: repository, ignore: 404)
276272
end
277273
end
278274

@@ -304,6 +300,7 @@ def clear_ml_filters(client)
304300

305301
def wipe_all_indices(client)
306302
client.indices.delete(index: '*,-.ds-ilm-history-*', expand_wildcards: 'open,closed,hidden', ignore: 404)
303+
client.indices.refresh(expand_wildcards: 'open,hidden')
307304
end
308305

309306
def wipe_searchable_snapshot_indices(client)

0 commit comments

Comments
 (0)