diff options
author | Stan Hu <stanhu@gmail.com> | 2019-03-31 06:38:23 -0700 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-04-01 13:33:16 -0300 |
commit | d4c6a3af78c0ef8257c453980832c4d419aabb51 (patch) | |
tree | 0bb125fa5169fd1fb75b7b3a6f757b8ad1ab77be /spec | |
parent | 8813447c6fd6a9c843433cc7dfda6a95fc4c2b58 (diff) | |
download | gitlab-ce-d4c6a3af78c0ef8257c453980832c4d419aabb51.tar.gz |
Force a full GC after importing a projectsh-force-gc-after-import
During a project import, it's possible that new branches are created by
the importer to handle pull requests that have been created from forked
projects, which would increment the `pushes_since_gc` value via
`HousekeepingService.increment!` before a full garbage collection gets
to run. This causes HousekeepingService to skip the full `git gc` and
move to the incremental repack mode. To ensure that a garbage collection
is run to pack refs and objects, explicitly execute the task.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/59477
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/projects/after_import_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/projects/housekeeping_service_spec.rb | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/spec/services/projects/after_import_service_spec.rb b/spec/services/projects/after_import_service_spec.rb index 4dd6c6dab86..765b4ffae8f 100644 --- a/spec/services/projects/after_import_service_spec.rb +++ b/spec/services/projects/after_import_service_spec.rb @@ -13,7 +13,7 @@ describe Projects::AfterImportService do describe '#execute' do before do allow(Projects::HousekeepingService) - .to receive(:new).with(project).and_return(housekeeping_service) + .to receive(:new).with(project, :gc).and_return(housekeeping_service) allow(housekeeping_service) .to receive(:execute).and_yield diff --git a/spec/services/projects/housekeeping_service_spec.rb b/spec/services/projects/housekeeping_service_spec.rb index 18ecef1c0a1..12ae9105627 100644 --- a/spec/services/projects/housekeeping_service_spec.rb +++ b/spec/services/projects/housekeeping_service_spec.rb @@ -88,6 +88,19 @@ describe Projects::HousekeepingService do expect(project.pushes_since_gc).to eq(1) end end + + it 'runs the task specifically requested' do + housekeeping = described_class.new(project, :gc) + + allow(housekeeping).to receive(:try_obtain_lease).and_return(:gc_uuid) + allow(housekeeping).to receive(:lease_key).and_return(:gc_lease_key) + + expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :gc, :gc_lease_key, :gc_uuid).twice + + 2.times do + housekeeping.execute + end + end end describe '#needed?' do |