Skip to content

Commit 77200f2

Browse files
committed
[XPACK] Fixes issue with deleting repository
1 parent 3f71dec commit 77200f2

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

api-spec-testing/test_file.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,18 @@ def clear_snapshots_and_repositories(client)
387387
return unless (repositories = client.snapshot.get_repository)
388388

389389
repositories.each_key do |repository|
390-
391-
client.snapshot.delete(repository: repository, snapshot: '*', ignore: 404) if(repositories[repository]['type'] == 'fs')
392-
393-
client.snapshot.delete_repository(repository: repository, ignore: 404)
390+
client.snapshot.delete(repository: repository, snapshot: '*', ignore: 404) if repositories[repository]['type'] == 'fs'
391+
begin
392+
response = client.perform_request('DELETE', "_snapshot/#{repository}", ignore: [500, 404])
393+
client.snapshot.delete_repository(repository: repository, ignore: 404)
394+
rescue Elasticsearch::Transport::Transport::Errors::InternalServerError => e
395+
regexp = /indices that use the repository: \[docs\/([a-zA-Z0-9]+)/
396+
raise e unless response.body['error']['root_cause'].first['reason'].match(regexp)
397+
398+
# Try again after clearing indices if we get a 500 error from delete repository
399+
clear_indices(client)
400+
client.snapshot.delete_repository(repository: repository, ignore: 404)
401+
end
394402
end
395403
end
396404

elasticsearch-api/spec/spec_helper.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646

4747
module HelperModule
4848
def self.included(context)
49-
5049
context.let(:client_double) do
5150
Class.new { include Elasticsearch::API }.new.tap do |client|
5251
expect(client).to receive(:perform_request).with(*expected_args).and_return(response_double)

elasticsearch-xpack/Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ end
3333
namespace :test do
3434
desc 'Run REST API YAML tests'
3535
RSpec::Core::RakeTask.new(:rest_api) do |t|
36+
ENV['TEST_SUITE'] = 'platinum'
3637
t.pattern = 'spec/xpack/rest_api_yaml_spec.rb'
3738
end
3839

0 commit comments

Comments
 (0)