Commit aec9b7b0 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch 'merge-elastic-rake-specs' into 'master'

Merge 2 different elastic rake spec files into one

See merge request gitlab-org/gitlab!48114
parents b3e348fb c1d3b27d
# frozen_string_literal: true
require 'rake_helper'
RSpec.describe 'elastic rake tasks', :elastic do
before do
Rake.application.rake_require 'tasks/gitlab/elastic'
end
describe 'create_empty_index' do
subject { run_rake_task('gitlab:elastic:create_empty_index') }
before do
es_helper.delete_index
end
it 'creates an index' do
expect { subject }.to change { es_helper.index_exists? }.from(false).to(true)
end
it 'marks all migrations as completed' do
expect(Elastic::DataMigrationService).to receive(:mark_all_as_completed!).and_call_original
expect(Elastic::MigrationRecord.persisted_versions(completed: true)).to eq([])
subject
refresh_index!
migrations = Elastic::DataMigrationService.migrations.map(&:version)
expect(Elastic::MigrationRecord.persisted_versions(completed: true)).to eq(migrations)
end
end
describe 'delete_index' do
subject { run_rake_task('gitlab:elastic:delete_index') }
it 'removes the index' do
expect { subject }.to change { es_helper.index_exists? }.from(true).to(false)
end
end
end
...@@ -7,6 +7,37 @@ RSpec.describe 'gitlab:elastic namespace rake tasks', :elastic do ...@@ -7,6 +7,37 @@ RSpec.describe 'gitlab:elastic namespace rake tasks', :elastic do
Rake.application.rake_require 'tasks/gitlab/elastic' Rake.application.rake_require 'tasks/gitlab/elastic'
end end
describe 'create_empty_index' do
subject { run_rake_task('gitlab:elastic:create_empty_index') }
before do
es_helper.delete_index
end
it 'creates an index' do
expect { subject }.to change { es_helper.index_exists? }.from(false).to(true)
end
it 'marks all migrations as completed' do
expect(Elastic::DataMigrationService).to receive(:mark_all_as_completed!).and_call_original
expect(Elastic::MigrationRecord.persisted_versions(completed: true)).to eq([])
subject
refresh_index!
migrations = Elastic::DataMigrationService.migrations.map(&:version)
expect(Elastic::MigrationRecord.persisted_versions(completed: true)).to eq(migrations)
end
end
describe 'delete_index' do
subject { run_rake_task('gitlab:elastic:delete_index') }
it 'removes the index' do
expect { subject }.to change { es_helper.index_exists? }.from(true).to(false)
end
end
context "with elasticsearch_indexing enabled" do context "with elasticsearch_indexing enabled" do
before do before do
stub_ee_application_setting(elasticsearch_indexing: true) stub_ee_application_setting(elasticsearch_indexing: true)
......
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