Commit a6515f14 authored by Allison Browne's avatar Allison Browne

Namespace existing Ci::JobArtifactsDestroyBatchService

Namespace Ci::JobArtifactsDestroyBatchService as
Ci::JobArtifacts::DestroyBatchService additionally namespace
the ee version of this file. EE::Ci::JobArtifactsDestroyBatchService
becomes EE::Ci::JobArtifacts::DestroyBatchService.
parent 5a5169f8
# frozen_string_literal: true # frozen_string_literal: true
module Ci module Ci
class JobArtifacts::DestroyExpiredService class JobArtifacts::DestroyAllExpiredService
include ::Gitlab::ExclusiveLeaseHelpers include ::Gitlab::ExclusiveLeaseHelpers
include ::Gitlab::LoopHelpers include ::Gitlab::LoopHelpers
...@@ -46,7 +46,7 @@ module Ci ...@@ -46,7 +46,7 @@ module Ci
end end
def destroy_batch_async(artifacts) def destroy_batch_async(artifacts)
Ci::JobArtifactsDestroyBatchService.new(artifacts).execute Ci::JobArtifacts::DestroyBatchService.new(artifacts).execute
end end
def loop_timeout?(start_at) def loop_timeout?(start_at)
......
# frozen_string_literal: true # frozen_string_literal: true
module Ci module Ci
class JobArtifactsDestroyBatchService class JobArtifacts::DestroyBatchService
include BaseServiceUtility include BaseServiceUtility
include ::Gitlab::Utils::StrongMemoize include ::Gitlab::Utils::StrongMemoize
...@@ -69,4 +69,4 @@ module Ci ...@@ -69,4 +69,4 @@ module Ci
end end
end end
Ci::JobArtifactsDestroyBatchService.prepend_if_ee('EE::Ci::JobArtifactsDestroyBatchService') Ci::JobArtifacts::DestroyBatchService.prepend_if_ee('EE::Ci::JobArtifacts::DestroyBatchService')
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module Ci module Ci
module PipelineArtifacts module PipelineArtifacts
class DestroyExpiredArtifactsService class DestroyAllExpiredService
include ::Gitlab::LoopHelpers include ::Gitlab::LoopHelpers
include ::Gitlab::Utils::StrongMemoize include ::Gitlab::Utils::StrongMemoize
......
...@@ -14,7 +14,7 @@ module Ci ...@@ -14,7 +14,7 @@ module Ci
feature_category :continuous_integration feature_category :continuous_integration
def perform def perform
service = ::Ci::PipelineArtifacts::DestroyExpiredArtifactsService.new service = ::Ci::PipelineArtifacts::DestroyAllExpiredService.new
artifacts_count = service.execute artifacts_count = service.execute
log_extra_metadata_on_done(:destroyed_pipeline_artifacts_count, artifacts_count) log_extra_metadata_on_done(:destroyed_pipeline_artifacts_count, artifacts_count)
end end
......
...@@ -10,7 +10,7 @@ class ExpireBuildArtifactsWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -10,7 +10,7 @@ class ExpireBuildArtifactsWorker # rubocop:disable Scalability/IdempotentWorker
feature_category :continuous_integration feature_category :continuous_integration
def perform def perform
service = Ci::JobArtifacts::DestroyExpiredService.new service = Ci::JobArtifacts::DestroyAllExpiredService.new
artifacts_count = service.execute artifacts_count = service.execute
log_extra_metadata_on_done(:destroyed_job_artifacts_count, artifacts_count) log_extra_metadata_on_done(:destroyed_job_artifacts_count, artifacts_count)
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module EE module EE
module Ci module Ci
module JobArtifactsDestroyBatchService module JobArtifacts::DestroyBatchService
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
private private
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shared_state do RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_shared_state do
include ExclusiveLeaseHelpers include ExclusiveLeaseHelpers
describe '.execute' do describe '.execute' do
...@@ -62,7 +62,7 @@ RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shar ...@@ -62,7 +62,7 @@ RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shar
context 'when failed to destroy artifact' do context 'when failed to destroy artifact' do
before do before do
stub_const('Ci::JobArtifacts::DestroyExpiredService::LOOP_LIMIT', 10) stub_const('Ci::JobArtifacts::DestroyAllExpiredService::LOOP_LIMIT', 10)
expect(Ci::DeletedObject) expect(Ci::DeletedObject)
.to receive(:bulk_import) .to receive(:bulk_import)
.once .once
...@@ -77,7 +77,7 @@ RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shar ...@@ -77,7 +77,7 @@ RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shar
context 'when there are artifacts more than batch sizes' do context 'when there are artifacts more than batch sizes' do
before do before do
stub_const('Ci::JobArtifacts::DestroyExpiredService::BATCH_SIZE', 1) stub_const('Ci::JobArtifacts::DestroyAllExpiredService::BATCH_SIZE', 1)
second_artifact.job.pipeline.unlocked! second_artifact.job.pipeline.unlocked!
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Ci::JobArtifactsDestroyBatchService do RSpec.describe Ci::JobArtifacts::DestroyBatchService do
describe '.execute' do describe '.execute' do
subject { service.execute } subject { service.execute }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shared_state do RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_shared_state do
include ExclusiveLeaseHelpers include ExclusiveLeaseHelpers
let(:service) { described_class.new } let(:service) { described_class.new }
...@@ -24,7 +24,7 @@ RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shar ...@@ -24,7 +24,7 @@ RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shar
job = create(:ci_build, pipeline: artifact.job.pipeline) job = create(:ci_build, pipeline: artifact.job.pipeline)
create(:ci_job_artifact, :archive, :expired, job: job) create(:ci_job_artifact, :archive, :expired, job: job)
stub_const('Ci::JobArtifacts::DestroyExpiredService::LOOP_LIMIT', 1) stub_const('Ci::JobArtifacts::DestroyAllExpiredService::LOOP_LIMIT', 1)
end end
it 'performs the smallest number of queries for job_artifacts' do it 'performs the smallest number of queries for job_artifacts' do
...@@ -113,7 +113,7 @@ RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shar ...@@ -113,7 +113,7 @@ RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shar
context 'when failed to destroy artifact' do context 'when failed to destroy artifact' do
before do before do
stub_const('Ci::JobArtifacts::DestroyExpiredService::LOOP_LIMIT', 10) stub_const('Ci::JobArtifacts::DestroyAllExpiredService::LOOP_LIMIT', 10)
end end
context 'when the import fails' do context 'when the import fails' do
...@@ -159,8 +159,8 @@ RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shar ...@@ -159,8 +159,8 @@ RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shar
let!(:second_artifact) { create(:ci_job_artifact, expire_at: 1.day.ago) } let!(:second_artifact) { create(:ci_job_artifact, expire_at: 1.day.ago) }
before do before do
stub_const('Ci::JobArtifacts::DestroyExpiredService::LOOP_TIMEOUT', 0.seconds) stub_const('Ci::JobArtifacts::DestroyAllExpiredService::LOOP_TIMEOUT', 0.seconds)
stub_const('Ci::JobArtifacts::DestroyExpiredService::BATCH_SIZE', 1) stub_const('Ci::JobArtifacts::DestroyAllExpiredService::BATCH_SIZE', 1)
second_artifact.job.pipeline.unlocked! second_artifact.job.pipeline.unlocked!
end end
...@@ -176,8 +176,8 @@ RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shar ...@@ -176,8 +176,8 @@ RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shar
context 'when loop reached loop limit' do context 'when loop reached loop limit' do
before do before do
stub_const('Ci::JobArtifacts::DestroyExpiredService::LOOP_LIMIT', 1) stub_const('Ci::JobArtifacts::DestroyAllExpiredService::LOOP_LIMIT', 1)
stub_const('Ci::JobArtifacts::DestroyExpiredService::BATCH_SIZE', 1) stub_const('Ci::JobArtifacts::DestroyAllExpiredService::BATCH_SIZE', 1)
second_artifact.job.pipeline.unlocked! second_artifact.job.pipeline.unlocked!
end end
...@@ -209,7 +209,7 @@ RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shar ...@@ -209,7 +209,7 @@ RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shar
context 'when there are artifacts more than batch sizes' do context 'when there are artifacts more than batch sizes' do
before do before do
stub_const('Ci::JobArtifacts::DestroyExpiredService::BATCH_SIZE', 1) stub_const('Ci::JobArtifacts::DestroyAllExpiredService::BATCH_SIZE', 1)
second_artifact.job.pipeline.unlocked! second_artifact.job.pipeline.unlocked!
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Ci::JobArtifactsDestroyBatchService do RSpec.describe Ci::JobArtifacts::DestroyBatchService do
include ExclusiveLeaseHelpers include ExclusiveLeaseHelpers
let(:artifacts) { Ci::JobArtifact.all } let(:artifacts) { Ci::JobArtifact.all }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Ci::PipelineArtifacts::DestroyExpiredArtifactsService do RSpec.describe Ci::PipelineArtifacts::DestroyAllExpiredService do
let(:service) { described_class.new } let(:service) { described_class.new }
describe '.execute' do describe '.execute' do
...@@ -10,7 +10,7 @@ RSpec.describe Ci::PipelineArtifacts::DestroyExpiredArtifactsService do ...@@ -10,7 +10,7 @@ RSpec.describe Ci::PipelineArtifacts::DestroyExpiredArtifactsService do
context 'when timeout happens' do context 'when timeout happens' do
before do before do
stub_const('Ci::PipelineArtifacts::DestroyExpiredArtifactsService::LOOP_TIMEOUT', 0.1.seconds) stub_const('Ci::PipelineArtifacts::DestroyAllExpiredService::LOOP_TIMEOUT', 0.1.seconds)
allow(service).to receive(:destroy_artifacts_batch) { true } allow(service).to receive(:destroy_artifacts_batch) { true }
end end
...@@ -27,8 +27,8 @@ RSpec.describe Ci::PipelineArtifacts::DestroyExpiredArtifactsService do ...@@ -27,8 +27,8 @@ RSpec.describe Ci::PipelineArtifacts::DestroyExpiredArtifactsService do
context 'when the loop limit is reached' do context 'when the loop limit is reached' do
before do before do
stub_const('::Ci::PipelineArtifacts::DestroyExpiredArtifactsService::LOOP_LIMIT', 1) stub_const('::Ci::PipelineArtifacts::DestroyAllExpiredService::LOOP_LIMIT', 1)
stub_const('::Ci::PipelineArtifacts::DestroyExpiredArtifactsService::BATCH_SIZE', 1) stub_const('::Ci::PipelineArtifacts::DestroyAllExpiredService::BATCH_SIZE', 1)
create_list(:ci_pipeline_artifact, 2, expire_at: 1.week.ago) create_list(:ci_pipeline_artifact, 2, expire_at: 1.week.ago)
end end
...@@ -44,7 +44,7 @@ RSpec.describe Ci::PipelineArtifacts::DestroyExpiredArtifactsService do ...@@ -44,7 +44,7 @@ RSpec.describe Ci::PipelineArtifacts::DestroyExpiredArtifactsService do
context 'when there are artifacts more than batch sizes' do context 'when there are artifacts more than batch sizes' do
before do before do
stub_const('Ci::PipelineArtifacts::DestroyExpiredArtifactsService::BATCH_SIZE', 1) stub_const('Ci::PipelineArtifacts::DestroyAllExpiredService::BATCH_SIZE', 1)
create_list(:ci_pipeline_artifact, 2, expire_at: 1.week.ago) create_list(:ci_pipeline_artifact, 2, expire_at: 1.week.ago)
end end
......
...@@ -11,7 +11,7 @@ RSpec.describe Ci::PipelineArtifacts::ExpireArtifactsWorker do ...@@ -11,7 +11,7 @@ RSpec.describe Ci::PipelineArtifacts::ExpireArtifactsWorker do
end end
it 'executes a service' do it 'executes a service' do
expect_next_instance_of(::Ci::PipelineArtifacts::DestroyExpiredArtifactsService) do |instance| expect_next_instance_of(::Ci::PipelineArtifacts::DestroyAllExpiredService) do |instance|
expect(instance).to receive(:execute) expect(instance).to receive(:execute)
end end
......
...@@ -7,7 +7,7 @@ RSpec.describe ExpireBuildArtifactsWorker do ...@@ -7,7 +7,7 @@ RSpec.describe ExpireBuildArtifactsWorker do
describe '#perform' do describe '#perform' do
it 'executes a service' do it 'executes a service' do
expect_next_instance_of(Ci::JobArtifacts::DestroyExpiredService) do |instance| expect_next_instance_of(Ci::JobArtifacts::DestroyAllExpiredService) do |instance|
expect(instance).to receive(:execute).and_call_original expect(instance).to receive(:execute).and_call_original
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