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 # frozen_string_literal: true
module Ci module Ci
class DestroyExpiredJobArtifactsService class JobArtifacts::DestroyExpiredService
include ::Gitlab::ExclusiveLeaseHelpers include ::Gitlab::ExclusiveLeaseHelpers
include ::Gitlab::LoopHelpers include ::Gitlab::LoopHelpers
......
...@@ -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::DestroyExpiredJobArtifactsService.new service = Ci::JobArtifacts::DestroyExpiredService.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 @@
require 'spec_helper' 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 include ExclusiveLeaseHelpers
describe '.execute' do describe '.execute' do
...@@ -62,7 +62,7 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared ...@@ -62,7 +62,7 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared
context 'when failed to destroy artifact' do context 'when failed to destroy artifact' do
before do before do
stub_const('Ci::DestroyExpiredJobArtifactsService::LOOP_LIMIT', 10) stub_const('Ci::JobArtifacts::DestroyExpiredService::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::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared ...@@ -77,7 +77,7 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared
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::DestroyExpiredJobArtifactsService::BATCH_SIZE', 1) stub_const('Ci::JobArtifacts::DestroyExpiredService::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::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared_state do RSpec.describe Ci::JobArtifacts::DestroyExpiredService, :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::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared ...@@ -24,7 +24,7 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared
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::DestroyExpiredJobArtifactsService::LOOP_LIMIT', 1) stub_const('Ci::JobArtifacts::DestroyExpiredService::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::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared ...@@ -113,7 +113,7 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared
context 'when failed to destroy artifact' do context 'when failed to destroy artifact' do
before do before do
stub_const('Ci::DestroyExpiredJobArtifactsService::LOOP_LIMIT', 10) stub_const('Ci::JobArtifacts::DestroyExpiredService::LOOP_LIMIT', 10)
end end
context 'when the import fails' do context 'when the import fails' do
...@@ -159,8 +159,8 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared ...@@ -159,8 +159,8 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared
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::DestroyExpiredJobArtifactsService::LOOP_TIMEOUT', 0.seconds) stub_const('Ci::JobArtifacts::DestroyExpiredService::LOOP_TIMEOUT', 0.seconds)
stub_const('Ci::DestroyExpiredJobArtifactsService::BATCH_SIZE', 1) stub_const('Ci::JobArtifacts::DestroyExpiredService::BATCH_SIZE', 1)
second_artifact.job.pipeline.unlocked! second_artifact.job.pipeline.unlocked!
end end
...@@ -176,8 +176,8 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared ...@@ -176,8 +176,8 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared
context 'when loop reached loop limit' do context 'when loop reached loop limit' do
before do before do
stub_const('Ci::DestroyExpiredJobArtifactsService::LOOP_LIMIT', 1) stub_const('Ci::JobArtifacts::DestroyExpiredService::LOOP_LIMIT', 1)
stub_const('Ci::DestroyExpiredJobArtifactsService::BATCH_SIZE', 1) stub_const('Ci::JobArtifacts::DestroyExpiredService::BATCH_SIZE', 1)
second_artifact.job.pipeline.unlocked! second_artifact.job.pipeline.unlocked!
end end
...@@ -209,7 +209,7 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared ...@@ -209,7 +209,7 @@ RSpec.describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared
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::DestroyExpiredJobArtifactsService::BATCH_SIZE', 1) stub_const('Ci::JobArtifacts::DestroyExpiredService::BATCH_SIZE', 1)
second_artifact.job.pipeline.unlocked! second_artifact.job.pipeline.unlocked!
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::DestroyExpiredJobArtifactsService) do |instance| expect_next_instance_of(Ci::JobArtifacts::DestroyExpiredService) 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