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