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 ...@@ -28,16 +28,16 @@ module Gitlab
end end
end end
def create_empty_index(with_alias: true) def create_empty_index(with_alias: true, options: {})
if index_exists? if index_exists?
raise "Index under '#{target_name}' already exists, use `recreate_index` to recreate it." raise "Index under '#{target_name}' already exists, use `recreate_index` to recreate it."
end end
new_index_name = with_alias ? "#{target_name}-#{Time.now.strftime("%Y%m%d-%H%M")}" : target_name
settings = {} settings = {}
mappings = {} mappings = {}
new_index_name = with_alias ? "#{target_name}-#{Time.now.strftime("%Y%m%d-%H%M")}" : target_name
[ [
Project, Project,
Issue, Issue,
...@@ -52,6 +52,9 @@ module Gitlab ...@@ -52,6 +52,9 @@ module Gitlab
mappings.deep_merge!(klass.__elasticsearch__.mappings.to_hash) mappings.deep_merge!(klass.__elasticsearch__.mappings.to_hash)
end end
settings.merge!(options[:settings]) if options[:settings]
mappings.merge!(options[:mappings]) if options[:mappings]
create_index_options = { create_index_options = {
index: new_index_name, index: new_index_name,
body: { body: {
......
...@@ -4,7 +4,7 @@ RSpec.configure do |config| ...@@ -4,7 +4,7 @@ RSpec.configure do |config|
config.before(:each, :elastic) do config.before(:each, :elastic) do
Elastic::ProcessBookkeepingService.clear_tracking! Elastic::ProcessBookkeepingService.clear_tracking!
Gitlab::Elastic::Helper.default.delete_index 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 end
config.after(:each, :elastic) do 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