Skip to content

Commit 4f38373

Browse files
committed
[CI] Test Runner: Delete ml trained models in x-pack cleanup
1 parent 5274c16 commit 4f38373

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

api-spec-testing/test_file.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,15 @@ def setup
134134
Elasticsearch::Transport::Transport::Errors::Conflict => e
135135
error = JSON.parse(e.message.gsub(/\[[0-9]{3}\] /, ''))['error']['root_cause'].first
136136
count += 1
137+
raise e if count > 9
137138

138139
logger = Logger.new($stdout)
139140
logger.error "#{error['type']}: #{error['reason']}"
140-
client.indices.delete(index: error['index']) if error['reason'] =~ /index \[.+\] already exists/
141-
raise e if count > 9
141+
if error['reason'] =~ /index \[.+\] already exists/
142+
client.indices.delete(index: error['index'])
143+
elsif (model_id_match = /Trained machine learning model \[([a-z-0-9]+)\] already exists/.match(error['reason']))
144+
client.machine_learning.delete_trained_model(model_id: model_id_match[1])
145+
end
142146

143147
sleep(1)
144148
redo

0 commit comments

Comments
 (0)