summaryrefslogtreecommitdiff
path: root/spec/tasks
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-12-14 03:13:32 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-14 03:13:32 +0000
commitbe4229fb3ac31e2cc01c84b3a01ba58e1ba52a58 (patch)
tree39a6d06b3ef62dbbc6620e244d6e23f2e61024a7 /spec/tasks
parent1d54f384d509d9581730e24a64561e94132e41c1 (diff)
downloadgitlab-ce-be4229fb3ac31e2cc01c84b3a01ba58e1ba52a58.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/tasks')
-rw-r--r--spec/tasks/gitlab/db_rake_spec.rb43
1 files changed, 19 insertions, 24 deletions
diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb
index 48b879fea26..830d0dded2e 100644
--- a/spec/tasks/gitlab/db_rake_spec.rb
+++ b/spec/tasks/gitlab/db_rake_spec.rb
@@ -203,43 +203,38 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do
end
describe 'reindex' do
- let(:reindex) { double('reindex') }
- let(:indexes) { double('indexes') }
- let(:databases) { Gitlab::Database.database_base_models }
- let(:databases_count) { databases.count }
-
- it 'cleans up any leftover indexes' do
- expect(Gitlab::Database::Reindexing).to receive(:cleanup_leftovers!).exactly(databases_count).times
+ it 'delegates to Gitlab::Database::Reindexing' do
+ expect(Gitlab::Database::Reindexing).to receive(:invoke)
run_rake_task('gitlab:db:reindex')
end
- context 'when async index creation is enabled' do
- it 'executes async index creation prior to any reindexing actions' do
- stub_feature_flags(database_async_index_creation: true)
-
- expect(Gitlab::Database::AsyncIndexes).to receive(:create_pending_indexes!).ordered.exactly(databases_count).times
- expect(Gitlab::Database::Reindexing).to receive(:automatic_reindexing).ordered.exactly(databases_count).times
+ context 'when reindexing is not enabled' do
+ it 'is a no-op' do
+ expect(Gitlab::Database::Reindexing).to receive(:enabled?).and_return(false)
+ expect(Gitlab::Database::Reindexing).not_to receive(:invoke)
run_rake_task('gitlab:db:reindex')
end
end
+ end
- context 'when async index creation is disabled' do
- it 'does not execute async index creation' do
- stub_feature_flags(database_async_index_creation: false)
-
- expect(Gitlab::Database::AsyncIndexes).not_to receive(:create_pending_indexes!)
+ databases = ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml
+ ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |database_name|
+ describe "reindex:#{database_name}" do
+ it 'delegates to Gitlab::Database::Reindexing' do
+ expect(Gitlab::Database::Reindexing).to receive(:invoke).with(database_name)
- run_rake_task('gitlab:db:reindex')
+ run_rake_task("gitlab:db:reindex:#{database_name}")
end
- end
- context 'calls automatic reindexing' do
- it 'uses all candidate indexes' do
- expect(Gitlab::Database::Reindexing).to receive(:automatic_reindexing).exactly(databases_count).times
+ context 'when reindexing is not enabled' do
+ it 'is a no-op' do
+ expect(Gitlab::Database::Reindexing).to receive(:enabled?).and_return(false)
+ expect(Gitlab::Database::Reindexing).not_to receive(:invoke).with(database_name)
- run_rake_task('gitlab:db:reindex')
+ run_rake_task("gitlab:db:reindex:#{database_name}")
+ end
end
end
end