summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-27 21:09:38 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-27 21:09:38 +0000
commit49c0e687c1cebabb117519a6a34ffc02a39261b0 (patch)
treefc4446dae3a53e67fc99a969fa00086bd93ba0a8 /spec/support
parent84f003a4cbf0d57afdaae8cc4f28af549b34ff33 (diff)
downloadgitlab-ce-49c0e687c1cebabb117519a6a34ffc02a39261b0.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/shared_examples/services/repositories/housekeeping_shared_examples.rb50
-rw-r--r--spec/support/shared_examples/workers/concerns/git_garbage_collect_methods_shared_examples.rb108
2 files changed, 6 insertions, 152 deletions
diff --git a/spec/support/shared_examples/services/repositories/housekeeping_shared_examples.rb b/spec/support/shared_examples/services/repositories/housekeeping_shared_examples.rb
index 8a937303711..8cc71230ba4 100644
--- a/spec/support/shared_examples/services/repositories/housekeeping_shared_examples.rb
+++ b/spec/support/shared_examples/services/repositories/housekeeping_shared_examples.rb
@@ -65,12 +65,9 @@ RSpec.shared_examples 'housekeeps repository' do
# At push 200
expect(resource.git_garbage_collect_worker_klass).to receive(:perform_async).with(resource.id, :gc, :the_lease_key, :the_uuid)
.once
- # At push 50, 100, 150
- expect(resource.git_garbage_collect_worker_klass).to receive(:perform_async).with(resource.id, :full_repack, :the_lease_key, :the_uuid)
- .exactly(3).times
- # At push 10, 20, ... (except those above)
+ # At push 10, 20, ... (except the gc call)
expect(resource.git_garbage_collect_worker_klass).to receive(:perform_async).with(resource.id, :incremental_repack, :the_lease_key, :the_uuid)
- .exactly(16).times
+ .exactly(19).times
201.times do
subject.increment!
@@ -79,37 +76,6 @@ RSpec.shared_examples 'housekeeps repository' do
expect(resource.pushes_since_gc).to eq(1)
end
-
- context 'when optimized_repository feature flag is disabled' do
- before do
- stub_feature_flags(optimized_housekeeping: false)
- end
-
- it 'calls also the garbage collect worker with pack_refs every 6 commits' 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(resource.git_garbage_collect_worker_klass).to receive(:perform_async).with(resource.id, :gc, :the_lease_key, :the_uuid)
- .once
- # At push 50, 100, 150
- expect(resource.git_garbage_collect_worker_klass).to receive(:perform_async).with(resource.id, :full_repack, :the_lease_key, :the_uuid)
- .exactly(3).times
- # At push 10, 20, ... (except those above)
- expect(resource.git_garbage_collect_worker_klass).to receive(:perform_async).with(resource.id, :incremental_repack, :the_lease_key, :the_uuid)
- .exactly(16).times
- # At push 6, 12, 18, ... (except those above)
- expect(resource.git_garbage_collect_worker_klass).to receive(:perform_async).with(resource.id, :pack_refs, :the_lease_key, :the_uuid)
- .exactly(27).times
-
- 201.times do
- subject.increment!
- subject.execute if subject.needed?
- end
-
- expect(resource.pushes_since_gc).to eq(1)
- end
- end
end
it 'runs the task specifically requested' do
@@ -136,15 +102,11 @@ RSpec.shared_examples 'housekeeps repository' do
expect(subject.needed?).to eq(true)
end
- context 'when optimized_housekeeping is disabled' do
- before do
- stub_feature_flags(optimized_housekeeping: false)
- end
+ it 'when incremental repack period is not multiple of gc period' do
+ allow(Gitlab::CurrentSettings).to receive(:housekeeping_incremental_repack_period).and_return(12)
+ allow(resource).to receive(:pushes_since_gc).and_return(200)
- it 'returns true pack refs is needed' do
- allow(resource).to receive(:pushes_since_gc).and_return(described_class::PACK_REFS_PERIOD)
- expect(subject.needed?).to eq(true)
- end
+ expect(subject.needed?).to eq(true)
end
end
diff --git a/spec/support/shared_examples/workers/concerns/git_garbage_collect_methods_shared_examples.rb b/spec/support/shared_examples/workers/concerns/git_garbage_collect_methods_shared_examples.rb
index 503e331ea2e..ba1bdfa7aa8 100644
--- a/spec/support/shared_examples/workers/concerns/git_garbage_collect_methods_shared_examples.rb
+++ b/spec/support/shared_examples/workers/concerns/git_garbage_collect_methods_shared_examples.rb
@@ -24,19 +24,6 @@ RSpec.shared_examples 'can collect git garbage' do |update_statistics: true|
subject.perform(*params)
end
-
- context 'when optimized_housekeeping feature is disabled' do
- before do
- stub_feature_flags(optimized_housekeeping: false)
- end
-
- specify do
- expect(subject).to receive(:get_gitaly_client).with(task, repository.raw_repository).and_return(repository_service)
- expect(repository_service).to receive(gitaly_task)
-
- subject.perform(*params)
- end
- end
end
shared_examples 'it updates the resource statistics' do
@@ -91,20 +78,6 @@ RSpec.shared_examples 'can collect git garbage' do |update_statistics: true|
expect { subject.perform(*params) }.to raise_exception(Gitlab::Git::Repository::NoRepository)
end
-
- context 'when optimized_housekeeping feature flag is disabled' do
- before do
- stub_feature_flags(optimized_housekeeping: false)
- end
-
- it 'handles gRPC errors' do
- allow_next_instance_of(Gitlab::GitalyClient::RepositoryService, repository.raw_repository) do |instance|
- allow(instance).to receive(:garbage_collect).and_raise(GRPC::NotFound)
- end
-
- expect { subject.perform(*params) }.to raise_exception(Gitlab::Git::Repository::NoRepository)
- end
- end
end
context 'with different lease than the active one' do
@@ -161,51 +134,6 @@ RSpec.shared_examples 'can collect git garbage' do |update_statistics: true|
end
end
- context 'repack_full' do
- let(:task) { :full_repack }
- let(:gitaly_task) { :repack_full }
-
- before do
- expect(subject).to receive(:get_lease_uuid).and_return(lease_uuid)
- end
-
- it_behaves_like 'it calls Gitaly'
- it_behaves_like 'it updates the resource statistics' if update_statistics
- end
-
- context 'pack_refs' do
- let(:task) { :pack_refs }
- let(:gitaly_task) { :pack_refs }
-
- before do
- expect(subject).to receive(:get_lease_uuid).and_return(lease_uuid)
- end
-
- it_behaves_like 'it calls Gitaly' do
- let(:repository_service) { instance_double(Gitlab::GitalyClient::RefService) }
- end
-
- it 'does not update the resource statistics' do
- expect(statistics_service_klass).not_to receive(:new)
-
- subject.perform(*params)
- end
- end
-
- context 'repack_incremental' do
- let(:task) { :incremental_repack }
- let(:gitaly_task) { :repack_incremental }
-
- before do
- expect(subject).to receive(:get_lease_uuid).and_return(lease_uuid)
-
- statistics_keys.delete(:repository_size)
- end
-
- it_behaves_like 'it calls Gitaly'
- it_behaves_like 'it updates the resource statistics' if update_statistics
- end
-
context 'prune' do
before do
expect(subject).to receive(:get_lease_uuid).and_return(lease_uuid)
@@ -219,41 +147,5 @@ RSpec.shared_examples 'can collect git garbage' do |update_statistics: true|
subject.perform(resource.id, 'prune', lease_key, lease_uuid)
end
end
-
- shared_examples 'gc tasks' do
- before do
- allow(subject).to receive(:get_lease_uuid).and_return(lease_uuid)
- allow(subject).to receive(:bitmaps_enabled?).and_return(bitmaps_enabled)
-
- stub_feature_flags(optimized_housekeeping: false)
- end
-
- it 'cleans up repository after finishing' do
- expect(resource).to receive(:cleanup).and_call_original
-
- subject.perform(resource.id, 'gc', lease_key, lease_uuid)
- end
-
- it 'prune calls garbage_collect with the option prune: true' do
- repository_service = instance_double(Gitlab::GitalyClient::RepositoryService)
-
- expect(subject).to receive(:get_gitaly_client).with(:prune, repository.raw_repository).and_return(repository_service)
- expect(repository_service).to receive(:garbage_collect).with(bitmaps_enabled, prune: true)
-
- subject.perform(resource.id, 'prune', lease_key, lease_uuid)
- end
- end
-
- context 'with bitmaps enabled' do
- let(:bitmaps_enabled) { true }
-
- include_examples 'gc tasks'
- end
-
- context 'with bitmaps disabled' do
- let(:bitmaps_enabled) { false }
-
- include_examples 'gc tasks'
- end
end
end