Commit 5a5169f8 authored by Allison Browne's avatar Allison Browne

Namespace existing Ci::DestroyExpiredJobArtifactsService

Namespace Ci::DestroyExpiredJobArtifactsService as
Ci::JobArtifacts::DestroyExpiredService
parent 7e74e647
# frozen_string_literal: true
module Ci
class DestroyExpiredJobArtifactsService
class JobArtifacts::DestroyExpiredService
include ::Gitlab::ExclusiveLeaseHelpers
include ::Gitlab::LoopHelpers
......
......@@ -10,7 +10,7 @@ class ExpireBuildArtifactsWorker # rubocop:disable Scalability/IdempotentWorker
feature_category :continuous_integration
def perform
service = Ci::DestroyExpiredJobArtifactsService.new
service = Ci::JobArtifacts::DestroyExpiredService.new
artifacts_count = service.execute
log_extra_metadata_on_done(:destroyed_job_artifacts_count, artifacts_count)
end
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared_state do
RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shared_state do
include ExclusiveLeaseHelpers
describe '.execute' do
......@@ -62,7 +62,7 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared
context 'when failed to destroy artifact' do
before do
stub_const('Ci::DestroyExpiredJobArtifactsService::LOOP_LIMIT', 10)
stub_const('Ci::JobArtifacts::DestroyExpiredService::LOOP_LIMIT', 10)
expect(Ci::DeletedObject)
.to receive(:bulk_import)
.once
......@@ -77,7 +77,7 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared
context 'when there are artifacts more than batch sizes' do
before do
stub_const('Ci::DestroyExpiredJobArtifactsService::BATCH_SIZE', 1)
stub_const('Ci::JobArtifacts::DestroyExpiredService::BATCH_SIZE', 1)
second_artifact.job.pipeline.unlocked!
end
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared_state do
RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :clean_gitlab_redis_shared_state do
include ExclusiveLeaseHelpers
let(:service) { described_class.new }
......@@ -24,7 +24,7 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared
job = create(:ci_build, pipeline: artifact.job.pipeline)
create(:ci_job_artifact, :archive, :expired, job: job)
stub_const('Ci::DestroyExpiredJobArtifactsService::LOOP_LIMIT', 1)
stub_const('Ci::JobArtifacts::DestroyExpiredService::LOOP_LIMIT', 1)
end
it 'performs the smallest number of queries for job_artifacts' do
......@@ -113,7 +113,7 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared
context 'when failed to destroy artifact' do
before do
stub_const('Ci::DestroyExpiredJobArtifactsService::LOOP_LIMIT', 10)
stub_const('Ci::JobArtifacts::DestroyExpiredService::LOOP_LIMIT', 10)
end
context 'when the import fails' do
......@@ -159,8 +159,8 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared
let!(:second_artifact) { create(:ci_job_artifact, expire_at: 1.day.ago) }
before do
stub_const('Ci::DestroyExpiredJobArtifactsService::LOOP_TIMEOUT', 0.seconds)
stub_const('Ci::DestroyExpiredJobArtifactsService::BATCH_SIZE', 1)
stub_const('Ci::JobArtifacts::DestroyExpiredService::LOOP_TIMEOUT', 0.seconds)
stub_const('Ci::JobArtifacts::DestroyExpiredService::BATCH_SIZE', 1)
second_artifact.job.pipeline.unlocked!
end
......@@ -176,8 +176,8 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared
context 'when loop reached loop limit' do
before do
stub_const('Ci::DestroyExpiredJobArtifactsService::LOOP_LIMIT', 1)
stub_const('Ci::DestroyExpiredJobArtifactsService::BATCH_SIZE', 1)
stub_const('Ci::JobArtifacts::DestroyExpiredService::LOOP_LIMIT', 1)
stub_const('Ci::JobArtifacts::DestroyExpiredService::BATCH_SIZE', 1)
second_artifact.job.pipeline.unlocked!
end
......@@ -209,7 +209,7 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared
context 'when there are artifacts more than batch sizes' do
before do
stub_const('Ci::DestroyExpiredJobArtifactsService::BATCH_SIZE', 1)
stub_const('Ci::JobArtifacts::DestroyExpiredService::BATCH_SIZE', 1)
second_artifact.job.pipeline.unlocked!
end
......
......@@ -7,7 +7,7 @@ RSpec.describe ExpireBuildArtifactsWorker do
describe '#perform' do
it 'executes a service' do
expect_next_instance_of(Ci::DestroyExpiredJobArtifactsService) do |instance|
expect_next_instance_of(Ci::JobArtifacts::DestroyExpiredService) 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