Test stabilization: Make ES indexes more unique and remove delete indexes only if necessary.
This commit is contained in:
parent
c25a55457b
commit
f34f0d14de
1 changed files with 13 additions and 5 deletions
|
@ -25,7 +25,9 @@ module SearchindexHelper
|
|||
# Setting.set('es_password', 'zammad')
|
||||
|
||||
if ENV['ES_INDEX_RAND'].present?
|
||||
ENV['ES_INDEX'] = "es_index_#{rand(999_999_999)}"
|
||||
rand_id = ENV.fetch('CI_JOB_ID', "r#{rand(999)}")
|
||||
test_method_name = method_name.gsub(/[^\w]/, '_')
|
||||
ENV['ES_INDEX'] = "es_index_#{test_method_name}_#{rand_id}_#{rand(999_999_999)}"
|
||||
end
|
||||
if ENV['ES_INDEX'].blank?
|
||||
raise "ERROR: Need ES_INDEX - hint ES_INDEX='estest.local_zammad'"
|
||||
|
@ -39,11 +41,17 @@ module SearchindexHelper
|
|||
end
|
||||
|
||||
def rebuild_searchindex
|
||||
# drop/create indexes
|
||||
Rake::Task.clear
|
||||
Zammad::Application.load_tasks
|
||||
#Rake::Task["searchindex:drop"].execute
|
||||
#Rake::Task["searchindex:create"].execute
|
||||
Rake::Task['searchindex:rebuild'].execute
|
||||
|
||||
if ENV['ES_INDEX_RAND'].blank?
|
||||
Rake::Task['searchindex:rebuild'].execute
|
||||
else
|
||||
# if we have a random index we don't need
|
||||
# to drop the index in the first place
|
||||
Rake::Task['searchindex:create'].execute
|
||||
Rake::Task['searchindex:reload'].execute
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue