diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2016-10-27 14:59:52 +0200 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2016-11-04 14:30:11 +0100 |
commit | 6bcc52a53678ca68001189c801497862d3f6e758 (patch) | |
tree | 5b8ebf525e2fcf18d1e3c3b9de6c1e1d6180a94d /spec/services/projects | |
parent | e4c05de75ccec1b0d64a7a994f05d54bffc903e5 (diff) | |
download | gitlab-ce-6bcc52a53678ca68001189c801497862d3f6e758.tar.gz |
Refine Git garbage collection
Diffstat (limited to 'spec/services/projects')
-rw-r--r-- | spec/services/projects/housekeeping_service_spec.rb | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/spec/services/projects/housekeeping_service_spec.rb b/spec/services/projects/housekeeping_service_spec.rb index cf90b33dfb4..57a5aa5cedc 100644 --- a/spec/services/projects/housekeeping_service_spec.rb +++ b/spec/services/projects/housekeeping_service_spec.rb @@ -14,8 +14,10 @@ describe Projects::HousekeepingService do describe '#execute' do it 'enqueues a sidekiq job' do - expect(subject).to receive(:try_obtain_lease).and_return(true) - expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id) + expect(subject).to receive(:try_obtain_lease).and_return(:the_uuid) + expect(subject).to receive(:lease_key).and_return(:the_lease_key) + expect(subject).to receive(:task).and_return(:the_task) + expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :the_task, :the_lease_key, :the_uuid) subject.execute expect(project.reload.pushes_since_gc).to eq(0) @@ -58,4 +60,26 @@ describe Projects::HousekeepingService do end.to change { project.pushes_since_gc }.from(0).to(1) end end + + it 'uses all three kinds of housekeeping we offer' do + allow(subject).to receive(:try_obtain_lease).and_return(:the_uuid) + allow(subject).to receive(:lease_key).and_return(:the_lease_key) + + # At push 200 + expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :gc, :the_lease_key, :the_uuid). + exactly(1).times + # At push 50, 100, 150 + expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :full_repack, :the_lease_key, :the_uuid). + exactly(3).times + # At push 10, 20, ... (except those above) + expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :incremental_repack, :the_lease_key, :the_uuid). + exactly(16).times + + 201.times do + subject.increment! + subject.execute if subject.needed? + end + + expect(project.pushes_since_gc).to eq(1) + end end |