Commit 10fb2344 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'speed-up-elastic-specs' into 'master'

Improve ES specs runtime

See merge request gitlab-org/gitlab!33951
parents beabd19f 7d0a610f
......@@ -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