diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/services/container_expiration_policies/cleanup_service_spec.rb | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) | |
download | gitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/services/container_expiration_policies/cleanup_service_spec.rb')
-rw-r--r-- | spec/services/container_expiration_policies/cleanup_service_spec.rb | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/spec/services/container_expiration_policies/cleanup_service_spec.rb b/spec/services/container_expiration_policies/cleanup_service_spec.rb index 8438073ceb0..34f69d24141 100644 --- a/spec/services/container_expiration_policies/cleanup_service_spec.rb +++ b/spec/services/container_expiration_policies/cleanup_service_spec.rb @@ -17,7 +17,7 @@ RSpec.describe ContainerExpirationPolicies::CleanupService do it 'completely clean up the repository' do expect(Projects::ContainerRepository::CleanupTagsService) - .to receive(:new).with(project, nil, cleanup_tags_service_params).and_return(cleanup_tags_service) + .to receive(:new).with(project, nil, cleanup_tags_service_params).and_return(cleanup_tags_service) expect(cleanup_tags_service).to receive(:execute).with(repository).and_return(status: :success) response = subject @@ -34,10 +34,14 @@ RSpec.describe ContainerExpirationPolicies::CleanupService do end context 'without a successful cleanup tags service execution' do - it 'partially clean up the repository' do + let(:cleanup_tags_service_response) { { status: :error, message: 'timeout' } } + + before do expect(Projects::ContainerRepository::CleanupTagsService) - .to receive(:new).and_return(double(execute: { status: :error, message: 'timeout' })) + .to receive(:new).and_return(double(execute: cleanup_tags_service_response)) + end + it 'partially clean up the repository' do response = subject aggregate_failures "checking the response and container repositories" do @@ -49,6 +53,39 @@ RSpec.describe ContainerExpirationPolicies::CleanupService do expect(repository.expiration_policy_completed_at).to eq(nil) end end + + context 'with a truncated cleanup tags service response' do + let(:cleanup_tags_service_response) do + { + status: :error, + original_size: 1000, + before_truncate_size: 800, + after_truncate_size: 200, + before_delete_size: 100 + } + end + + it 'partially clean up the repository' do + response = subject + + aggregate_failures "checking the response and container repositories" do + expect(response.success?).to eq(true) + expect(response.payload) + .to include( + cleanup_status: :unfinished, + container_repository_id: repository.id, + cleanup_tags_service_original_size: 1000, + cleanup_tags_service_before_truncate_size: 800, + cleanup_tags_service_after_truncate_size: 200, + cleanup_tags_service_before_delete_size: 100 + ) + expect(ContainerRepository.waiting_for_cleanup.count).to eq(1) + expect(repository.reload.cleanup_unfinished?).to be_truthy + expect(repository.expiration_policy_started_at).not_to eq(nil) + expect(repository.expiration_policy_completed_at).to eq(nil) + end + end + end end context 'with no repository' do |