diff options
Diffstat (limited to 'spec/lib/gitlab/database/reindexing/coordinator_spec.rb')
-rw-r--r-- | spec/lib/gitlab/database/reindexing/coordinator_spec.rb | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/spec/lib/gitlab/database/reindexing/coordinator_spec.rb b/spec/lib/gitlab/database/reindexing/coordinator_spec.rb index ae6362ba812..085fd3061ad 100644 --- a/spec/lib/gitlab/database/reindexing/coordinator_spec.rb +++ b/spec/lib/gitlab/database/reindexing/coordinator_spec.rb @@ -9,16 +9,9 @@ RSpec.describe Gitlab::Database::Reindexing::Coordinator do describe '.perform' do subject { described_class.new(index, notifier).perform } - before do - swapout_view_for_table(:postgres_indexes) - - allow(Gitlab::Database::Reindexing::ConcurrentReindex).to receive(:new).with(index).and_return(reindexer) - allow(Gitlab::Database::Reindexing::ReindexAction).to receive(:create_for).with(index).and_return(action) - end - let(:index) { create(:postgres_index) } let(:notifier) { instance_double(Gitlab::Database::Reindexing::GrafanaNotifier, notify_start: nil, notify_end: nil) } - let(:reindexer) { instance_double(Gitlab::Database::Reindexing::ConcurrentReindex, perform: nil) } + let(:reindexer) { instance_double(Gitlab::Database::Reindexing::ReindexConcurrently, perform: nil) } let(:action) { create(:reindex_action, index: index) } let!(:lease) { stub_exclusive_lease(lease_key, uuid, timeout: lease_timeout) } @@ -26,6 +19,13 @@ RSpec.describe Gitlab::Database::Reindexing::Coordinator do let(:lease_timeout) { 1.day } let(:uuid) { 'uuid' } + before do + swapout_view_for_table(:postgres_indexes) + + allow(Gitlab::Database::Reindexing::ReindexConcurrently).to receive(:new).with(index).and_return(reindexer) + allow(Gitlab::Database::Reindexing::ReindexAction).to receive(:create_for).with(index).and_return(action) + end + context 'locking' do it 'acquires a lock while reindexing' do expect(lease).to receive(:try_obtain).ordered.and_return(uuid) @@ -39,7 +39,7 @@ RSpec.describe Gitlab::Database::Reindexing::Coordinator do it 'does not perform reindexing actions if lease is not granted' do expect(lease).to receive(:try_obtain).ordered.and_return(false) - expect(Gitlab::Database::Reindexing::ConcurrentReindex).not_to receive(:new) + expect(Gitlab::Database::Reindexing::ReindexConcurrently).not_to receive(:new) subject end |