Commit d3bf53e3 authored by Toon Claes's avatar Toon Claes

Tune the spec to test the bare minimum

Instead of running the sync 10 times, just run it twice and see if the
worker attempts other projects than it did in the first run.
parent 575b677f
......@@ -93,25 +93,21 @@ describe Geo::RepositorySyncWorker do
context 'all repositories fail' do
before do
allow_any_instance_of(described_class).to receive(:db_retrieve_batch_size).and_return(4)
allow_any_instance_of(described_class).to receive(:max_capacity).and_return(5)
allow_any_instance_of(described_class).to receive(:db_retrieve_batch_size).and_return(2) # Must be >1 because of the Geo::BaseSchedulerWorker#interleave
allow_any_instance_of(described_class).to receive(:max_capacity).and_return(3) # Must be more than db_retrieve_batch_size
allow_any_instance_of(Project).to receive(:ensure_repository).and_raise(Gitlab::Shell::Error.new('foo'))
allow_any_instance_of(Geo::ProjectSyncWorker).to receive(:sync_wiki?).and_return(false)
allow_any_instance_of(Geo::RepositorySyncService).to receive(:expire_repository_caches)
allow_any_instance_of(Geo::RepositorySyncService).to receive(:try_obtain_lease) { |&arg| arg.call }
create_list(:project, 20, :random_last_repository_updated_at)
create_list(:project, 4, :random_last_repository_updated_at)
end
it 'attempts to sync them all' do
Sidekiq::Testing.inline! do
10.times do
subject.perform
break if Geo::ProjectRegistry.count == Project.count
end
end
it 'does not retry the same projects over and over again' do
Sidekiq::Testing.inline! { subject.perform }
expect(Geo::ProjectRegistry.count).to eq(Project.count)
expect do
Sidekiq::Testing.inline! { subject.perform }
end.to change { Geo::ProjectRegistry.count }
end
end
end
......
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