Commit 7d0a610f authored by Dmitry Gruzd's avatar Dmitry Gruzd

Improve ES specs runtime

parent 10f20692
......@@ -28,16 +28,16 @@ module Gitlab
end
end
def create_empty_index(with_alias: true)
def create_empty_index(with_alias: true, options: {})
if index_exists?
raise "Index under '#{target_name}' already exists, use `recreate_index` to recreate it."
end
new_index_name = with_alias ? "#{target_name}-#{Time.now.strftime("%Y%m%d-%H%M")}" : target_name
settings = {}
mappings = {}
new_index_name = with_alias ? "#{target_name}-#{Time.now.strftime("%Y%m%d-%H%M")}" : target_name
[
Project,
Issue,
......@@ -52,6 +52,9 @@ module Gitlab
mappings.deep_merge!(klass.__elasticsearch__.mappings.to_hash)
end
settings.merge!(options[:settings]) if options[:settings]
mappings.merge!(options[:mappings]) if options[:mappings]
create_index_options = {
index: new_index_name,
body: {
......
......@@ -4,7 +4,7 @@ RSpec.configure do |config|
config.before(:each, :elastic) do
Elastic::ProcessBookkeepingService.clear_tracking!
Gitlab::Elastic::Helper.default.delete_index
Gitlab::Elastic::Helper.default.create_empty_index
Gitlab::Elastic::Helper.default.create_empty_index(options: { settings: { number_of_replicas: 0 } })
end
config.after(:each, :elastic) do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment