Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-25 18:09:36 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-25 18:09:36 +0300
commitf4fb4d59484318767d9e687b3123b70fa01854be (patch)
treef8d6bfaf7cc483e68f39582a11b5276b9f441ae6 /spec/tasks
parentf6d19ed8eb581689706f192e64c349b33fb7a916 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/tasks')
-rw-r--r--spec/tasks/gitlab/db_rake_spec.rb22
1 files changed, 12 insertions, 10 deletions
diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb
index d22b5fb34d9..183e1ff0831 100644
--- a/spec/tasks/gitlab/db_rake_spec.rb
+++ b/spec/tasks/gitlab/db_rake_spec.rb
@@ -165,30 +165,32 @@ RSpec.describe 'gitlab:db namespace rake task' do
end
describe 'reindex' do
+ let(:reindex) { double('reindex') }
+ let(:indexes) { double('indexes') }
+
context 'when no index_name is given' do
- it 'raises an error' do
- expect do
- run_rake_task('gitlab:db:reindex', '')
- end.to raise_error(ArgumentError, /must give the index name/)
+ it 'rebuilds a random number of large indexes' do
+ expect(Gitlab::Database::PostgresIndex).to receive_message_chain('regular.random_few').and_return(indexes)
+ expect(Gitlab::Database::Reindexing).to receive(:perform).with(indexes)
+
+ run_rake_task('gitlab:db:reindex')
end
end
context 'with index name given' do
let(:index) { double('index') }
- let(:reindex) { double('reindex') }
it 'calls the index rebuilder with the proper arguments' do
- expect(Gitlab::Database::Reindexing::Index).to receive(:find_with_schema).with('public.foo_idx').and_return(index)
- expect(Gitlab::Database::Reindexing::ConcurrentReindex).to receive(:new).with(index, any_args).and_return(reindex)
- expect(reindex).to receive(:perform)
+ expect(Gitlab::Database::PostgresIndex).to receive(:by_identifier).with('public.foo_idx').and_return(index)
+ expect(Gitlab::Database::Reindexing).to receive(:perform).with(index)
run_rake_task('gitlab:db:reindex', '[public.foo_idx]')
end
it 'raises an error if the index does not exist' do
- expect(Gitlab::Database::Reindexing::Index).to receive(:find_with_schema).with('public.absent_index').and_return(nil)
+ expect(Gitlab::Database::PostgresIndex).to receive(:by_identifier).with('public.absent_index').and_raise(ActiveRecord::RecordNotFound)
- expect { run_rake_task('gitlab:db:reindex', '[public.absent_index]') }.to raise_error(ArgumentError, /index does not exist/)
+ expect { run_rake_task('gitlab:db:reindex', '[public.absent_index]') }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end