Commit aea69299 authored by Allison Browne's avatar Allison Browne

Switch to nested module and class definition

Switch to nested module and classes instead of compact
to follow this guideline:

https://github.com/rubocop/ruby-style-guide\#namespace-definition
parent a6515f14
# frozen_string_literal: true # frozen_string_literal: true
module Ci module Ci
class JobArtifacts::CreateService < ::BaseService module JobArtifacts
class CreateService < ::BaseService
include Gitlab::Utils::UsageData include Gitlab::Utils::UsageData
ArtifactsExistError = Class.new(StandardError) ArtifactsExistError = Class.new(StandardError)
...@@ -169,4 +170,5 @@ module Ci ...@@ -169,4 +170,5 @@ module Ci
Clusters::ParseClusterApplicationsArtifactService.new(job, job.user).execute(artifact) Clusters::ParseClusterApplicationsArtifactService.new(job, job.user).execute(artifact)
end end
end end
end
end end
# frozen_string_literal: true # frozen_string_literal: true
module Ci module Ci
class JobArtifacts::DestroyAllExpiredService module JobArtifacts
class DestroyAllExpiredService
include ::Gitlab::ExclusiveLeaseHelpers include ::Gitlab::ExclusiveLeaseHelpers
include ::Gitlab::LoopHelpers include ::Gitlab::LoopHelpers
...@@ -53,4 +54,5 @@ module Ci ...@@ -53,4 +54,5 @@ module Ci
Time.current > start_at + LOOP_TIMEOUT Time.current > start_at + LOOP_TIMEOUT
end end
end end
end
end end
# frozen_string_literal: true # frozen_string_literal: true
module Ci module Ci
class JobArtifacts::DestroyBatchService module JobArtifacts
class DestroyBatchService
include BaseServiceUtility include BaseServiceUtility
include ::Gitlab::Utils::StrongMemoize include ::Gitlab::Utils::StrongMemoize
# Danger: Private - Should only be called in Ci Services that pass a batch of job artifacts # Danger: Private - Should only be called in Ci Services that pass a batch of job artifacts
# Not for use outsie of the ci namespace # Not for use outside of the Ci:: namespace
# Adds the passed batch of job artifacts to the `ci_deleted_objects` table # Adds the passed batch of job artifacts to the `ci_deleted_objects` table
# for asyncronous destruction of the objects in Object Storage via the `Ci::DeleteObjectsService` # for asyncronous destruction of the objects in Object Storage via the `Ci::DeleteObjectsService`
...@@ -67,6 +68,7 @@ module Ci ...@@ -67,6 +68,7 @@ module Ci
end end
end end
end end
end
end end
Ci::JobArtifacts::DestroyBatchService.prepend_if_ee('EE::Ci::JobArtifacts::DestroyBatchService') Ci::JobArtifacts::DestroyBatchService.prepend_if_ee('EE::Ci::JobArtifacts::DestroyBatchService')
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
module EE module EE
module Ci module Ci
module JobArtifacts::DestroyBatchService module JobArtifacts
module DestroyBatchService
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
private private
...@@ -19,4 +20,5 @@ module EE ...@@ -19,4 +20,5 @@ module EE
end end
end end
end end
end
end end
...@@ -24,7 +24,7 @@ RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_s ...@@ -24,7 +24,7 @@ RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_s
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::DestroyAllExpiredService::LOOP_LIMIT', 1) stub_const("#{described_class}::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::DestroyAllExpiredService, :clean_gitlab_redis_s ...@@ -113,7 +113,7 @@ RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_s
context 'when failed to destroy artifact' do context 'when failed to destroy artifact' do
before do before do
stub_const('Ci::JobArtifacts::DestroyAllExpiredService::LOOP_LIMIT', 10) stub_const("#{described_class}::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::DestroyAllExpiredService, :clean_gitlab_redis_s ...@@ -159,8 +159,8 @@ RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_s
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::DestroyAllExpiredService::LOOP_TIMEOUT', 0.seconds) stub_const("#{described_class}::LOOP_TIMEOUT", 0.seconds)
stub_const('Ci::JobArtifacts::DestroyAllExpiredService::BATCH_SIZE', 1) stub_const("#{described_class}::BATCH_SIZE", 1)
second_artifact.job.pipeline.unlocked! second_artifact.job.pipeline.unlocked!
end end
...@@ -176,8 +176,8 @@ RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_s ...@@ -176,8 +176,8 @@ RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_s
context 'when loop reached loop limit' do context 'when loop reached loop limit' do
before do before do
stub_const('Ci::JobArtifacts::DestroyAllExpiredService::LOOP_LIMIT', 1) stub_const("#{described_class}::LOOP_LIMIT", 1)
stub_const('Ci::JobArtifacts::DestroyAllExpiredService::BATCH_SIZE', 1) stub_const("#{described_class}::BATCH_SIZE", 1)
second_artifact.job.pipeline.unlocked! second_artifact.job.pipeline.unlocked!
end end
...@@ -209,7 +209,7 @@ RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_s ...@@ -209,7 +209,7 @@ RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_s
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::DestroyAllExpiredService::BATCH_SIZE', 1) stub_const("#{described_class}::BATCH_SIZE", 1)
second_artifact.job.pipeline.unlocked! second_artifact.job.pipeline.unlocked!
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