Commit 478de5cf authored by Tetiana Chupryna's avatar Tetiana Chupryna

Merge branch 'georgekoltsov/add-container-policy-pipeline' into 'master'

Add Container Expiration Policy & Service Desk Setting to GitLab Migration

See merge request gitlab-org/gitlab!75653
parents 5f95cd5a 956261ca
......@@ -19,6 +19,8 @@ RSpec.describe BulkImports::Projects::Stage do
[4, BulkImports::Projects::Pipelines::ProtectedBranchesPipeline],
[4, BulkImports::Projects::Pipelines::CiPipelinesPipeline],
[4, BulkImports::Projects::Pipelines::ProjectFeaturePipeline],
[4, BulkImports::Projects::Pipelines::ContainerExpirationPolicyPipeline],
[4, BulkImports::Projects::Pipelines::ServiceDeskSettingPipeline],
[5, BulkImports::Common::Pipelines::WikiPipeline],
[5, BulkImports::Common::Pipelines::UploadsPipeline],
[5, BulkImports::Projects::Pipelines::AutoDevopsPipeline],
......
# frozen_string_literal: true
module BulkImports
module Projects
module Pipelines
class ContainerExpirationPolicyPipeline
include NdjsonPipeline
relation_name 'container_expiration_policy'
extractor ::BulkImports::Common::Extractors::NdjsonExtractor, relation: relation
end
end
end
end
# frozen_string_literal: true
module BulkImports
module Projects
module Pipelines
class ServiceDeskSettingPipeline
include NdjsonPipeline
relation_name 'service_desk_setting'
extractor ::BulkImports::Common::Extractors::NdjsonExtractor, relation: relation
end
end
end
end
......@@ -59,6 +59,14 @@ module BulkImports
pipeline: BulkImports::Projects::Pipelines::ProjectFeaturePipeline,
stage: 4
},
container_expiration_policy: {
pipeline: BulkImports::Projects::Pipelines::ContainerExpirationPolicyPipeline,
stage: 4
},
service_desk_setting: {
pipeline: BulkImports::Projects::Pipelines::ServiceDeskSettingPipeline,
stage: 4
},
wiki: {
pipeline: BulkImports::Common::Pipelines::WikiPipeline,
stage: 5
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe BulkImports::Projects::Pipelines::ContainerExpirationPolicyPipeline do
let_it_be(:project) { create(:project) }
let_it_be(:entity) { create(:bulk_import_entity, :project_entity, project: project) }
let_it_be(:tracker) { create(:bulk_import_tracker, entity: entity) }
let_it_be(:context) { BulkImports::Pipeline::Context.new(tracker) }
let_it_be(:policy) do
{
'created_at' => '2019-12-13 13:45:04 UTC',
'updated_at' => '2019-12-14 13:45:04 UTC',
'next_run_at' => '2019-12-15 13:45:04 UTC',
'name_regex' => 'test',
'name_regex_keep' => 'regex_keep',
'cadence' => '3month',
'older_than' => '1month',
'keep_n' => 100,
'enabled' => true
}
end
subject(:pipeline) { described_class.new(context) }
describe '#run' do
it 'imports project feature', :aggregate_failures do
allow_next_instance_of(BulkImports::Common::Extractors::NdjsonExtractor) do |extractor|
allow(extractor).to receive(:extract).and_return(BulkImports::Pipeline::ExtractedData.new(data: [[policy, 0]]))
end
pipeline.run
policy.each_pair do |key, value|
expect(entity.project.container_expiration_policy.public_send(key)).to eq(value)
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe BulkImports::Projects::Pipelines::ServiceDeskSettingPipeline do
let_it_be(:project) { create(:project) }
let_it_be(:entity) { create(:bulk_import_entity, :project_entity, project: project) }
let_it_be(:tracker) { create(:bulk_import_tracker, entity: entity) }
let_it_be(:context) { BulkImports::Pipeline::Context.new(tracker) }
let_it_be(:setting) { { 'issue_template_key' => 'test', 'project_key' => 'key' } }
subject(:pipeline) { described_class.new(context) }
describe '#run' do
it 'imports project feature', :aggregate_failures do
allow_next_instance_of(BulkImports::Common::Extractors::NdjsonExtractor) do |extractor|
allow(extractor).to receive(:extract).and_return(BulkImports::Pipeline::ExtractedData.new(data: [[setting, 0]]))
end
pipeline.run
setting.each_pair do |key, value|
expect(entity.project.service_desk_setting.public_send(key)).to eq(value)
end
end
end
end
......@@ -20,6 +20,8 @@ RSpec.describe BulkImports::Projects::Stage do
[4, BulkImports::Projects::Pipelines::ProtectedBranchesPipeline],
[4, BulkImports::Projects::Pipelines::CiPipelinesPipeline],
[4, BulkImports::Projects::Pipelines::ProjectFeaturePipeline],
[4, BulkImports::Projects::Pipelines::ContainerExpirationPolicyPipeline],
[4, BulkImports::Projects::Pipelines::ServiceDeskSettingPipeline],
[5, BulkImports::Common::Pipelines::WikiPipeline],
[5, BulkImports::Common::Pipelines::UploadsPipeline],
[5, BulkImports::Projects::Pipelines::AutoDevopsPipeline],
......
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