Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ab4c50ac
Commit
ab4c50ac
authored
Sep 20, 2021
by
George Koltsov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Project Migration Labels
- Add labels to Project Migration when using Group Migration tool
parent
cf940e83
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
85 additions
and
24 deletions
+85
-24
app/models/bulk_imports/entity.rb
app/models/bulk_imports/entity.rb
+10
-0
app/models/bulk_imports/export_status.rb
app/models/bulk_imports/export_status.rb
+1
-1
app/workers/bulk_import_worker.rb
app/workers/bulk_import_worker.rb
+1
-1
app/workers/bulk_imports/export_request_worker.rb
app/workers/bulk_imports/export_request_worker.rb
+1
-4
ee/spec/lib/ee/bulk_imports/groups/stage_spec.rb
ee/spec/lib/ee/bulk_imports/groups/stage_spec.rb
+1
-1
lib/bulk_imports/common/extractors/ndjson_extractor.rb
lib/bulk_imports/common/extractors/ndjson_extractor.rb
+1
-1
lib/bulk_imports/common/pipelines/labels_pipeline.rb
lib/bulk_imports/common/pipelines/labels_pipeline.rb
+1
-1
lib/bulk_imports/groups/stage.rb
lib/bulk_imports/groups/stage.rb
+1
-1
lib/bulk_imports/projects/stage.rb
lib/bulk_imports/projects/stage.rb
+5
-1
spec/lib/bulk_imports/common/pipelines/labels_pipeline_spec.rb
...lib/bulk_imports/common/pipelines/labels_pipeline_spec.rb
+1
-1
spec/lib/bulk_imports/groups/stage_spec.rb
spec/lib/bulk_imports/groups/stage_spec.rb
+1
-1
spec/lib/bulk_imports/projects/stage_spec.rb
spec/lib/bulk_imports/projects/stage_spec.rb
+2
-1
spec/models/bulk_imports/entity_spec.rb
spec/models/bulk_imports/entity_spec.rb
+36
-0
spec/workers/bulk_import_worker_spec.rb
spec/workers/bulk_import_worker_spec.rb
+2
-2
spec/workers/bulk_imports/export_request_worker_spec.rb
spec/workers/bulk_imports/export_request_worker_spec.rb
+21
-8
No files found.
app/models/bulk_imports/entity.rb
View file @
ab4c50ac
...
...
@@ -20,6 +20,8 @@
class
BulkImports::Entity
<
ApplicationRecord
self
.
table_name
=
'bulk_import_entities'
EXPORT_RELATIONS_URL
=
'/%{resource}/%{full_path}/export_relations'
belongs_to
:bulk_import
,
optional:
false
belongs_to
:parent
,
class_name:
'BulkImports::Entity'
,
optional:
true
...
...
@@ -102,6 +104,14 @@ class BulkImports::Entity < ApplicationRecord
end
end
def
pluralized_name
source_type
.
gsub
(
'_entity'
,
''
).
pluralize
end
def
export_relations_url_path
@export_relations_url_path
||=
EXPORT_RELATIONS_URL
%
{
resource:
pluralized_name
,
full_path:
encoded_source_full_path
}
end
private
def
validate_parent_is_a_group
...
...
app/models/bulk_imports/export_status.rb
View file @
ab4c50ac
...
...
@@ -41,7 +41,7 @@ module BulkImports
end
def
status_endpoint
"/groups/
#{
entity
.
encoded_source_full_path
}
/export_relations/status"
File
.
join
(
entity
.
export_relations_url_path
,
'status'
)
end
end
end
app/workers/bulk_import_worker.rb
View file @
ab4c50ac
...
...
@@ -26,7 +26,7 @@ class BulkImportWorker # rubocop:disable Scalability/IdempotentWorker
created_entities
.
first
(
next_batch_size
).
each
do
|
entity
|
entity
.
create_pipeline_trackers!
BulkImports
::
ExportRequestWorker
.
perform_async
(
entity
.
id
)
if
entity
.
group_entity?
BulkImports
::
ExportRequestWorker
.
perform_async
(
entity
.
id
)
BulkImports
::
EntityWorker
.
perform_async
(
entity
.
id
)
entity
.
start!
...
...
app/workers/bulk_imports/export_request_worker.rb
View file @
ab4c50ac
...
...
@@ -10,8 +10,6 @@ module BulkImports
worker_has_external_dependencies!
feature_category
:importers
GROUP_EXPORTED_URL_PATH
=
"/groups/%s/export_relations"
def
perform
(
entity_id
)
entity
=
BulkImports
::
Entity
.
find
(
entity_id
)
...
...
@@ -21,8 +19,7 @@ module BulkImports
private
def
request_export
(
entity
)
http_client
(
entity
.
bulk_import
.
configuration
)
.
post
(
GROUP_EXPORTED_URL_PATH
%
entity
.
encoded_source_full_path
)
http_client
(
entity
.
bulk_import
.
configuration
).
post
(
entity
.
export_relations_url_path
)
end
def
http_client
(
configuration
)
...
...
ee/spec/lib/ee/bulk_imports/groups/stage_spec.rb
View file @
ab4c50ac
...
...
@@ -9,7 +9,7 @@ RSpec.describe BulkImports::Groups::Stage do
[
1
,
BulkImports
::
Groups
::
Pipelines
::
GroupAvatarPipeline
],
[
1
,
BulkImports
::
Groups
::
Pipelines
::
SubgroupEntitiesPipeline
],
[
1
,
BulkImports
::
Groups
::
Pipelines
::
MembersPipeline
],
[
1
,
BulkImports
::
Groups
::
Pipelines
::
LabelsPipeline
],
[
1
,
BulkImports
::
Common
::
Pipelines
::
LabelsPipeline
],
[
1
,
BulkImports
::
Groups
::
Pipelines
::
MilestonesPipeline
],
[
1
,
BulkImports
::
Groups
::
Pipelines
::
BadgesPipeline
],
[
1
,
BulkImports
::
Groups
::
Pipelines
::
IterationsPipeline
],
...
...
lib/bulk_imports/common/extractors/ndjson_extractor.rb
View file @
ab4c50ac
...
...
@@ -60,7 +60,7 @@ module BulkImports
def
relative_resource_url
(
context
)
strong_memoize
(
:relative_resource_url
)
do
resource
=
context
.
portable
.
class
.
name
.
downcase
.
pluraliz
e
resource
=
context
.
entity
.
pluralized_nam
e
encoded_full_path
=
context
.
entity
.
encoded_source_full_path
EXPORT_DOWNLOAD_URL_PATH
%
{
resource:
resource
,
full_path:
encoded_full_path
,
relation:
relation
}
...
...
lib/bulk_imports/
groups
/pipelines/labels_pipeline.rb
→
lib/bulk_imports/
common
/pipelines/labels_pipeline.rb
View file @
ab4c50ac
# frozen_string_literal: true
module
BulkImports
module
Groups
module
Common
module
Pipelines
class
LabelsPipeline
include
NdjsonPipeline
...
...
lib/bulk_imports/groups/stage.rb
View file @
ab4c50ac
...
...
@@ -24,7 +24,7 @@ module BulkImports
stage:
1
},
labels:
{
pipeline:
BulkImports
::
Groups
::
Pipelines
::
LabelsPipeline
,
pipeline:
BulkImports
::
Common
::
Pipelines
::
LabelsPipeline
,
stage:
1
},
milestones:
{
...
...
lib/bulk_imports/projects/stage.rb
View file @
ab4c50ac
...
...
@@ -11,9 +11,13 @@ module BulkImports
pipeline:
BulkImports
::
Projects
::
Pipelines
::
ProjectPipeline
,
stage:
0
},
labels:
{
pipeline:
BulkImports
::
Common
::
Pipelines
::
LabelsPipeline
,
stage:
1
},
finisher:
{
pipeline:
BulkImports
::
Common
::
Pipelines
::
EntityFinisher
,
stage:
1
stage:
2
}
}
end
...
...
spec/lib/bulk_imports/
groups
/pipelines/labels_pipeline_spec.rb
→
spec/lib/bulk_imports/
common
/pipelines/labels_pipeline_spec.rb
View file @
ab4c50ac
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
RSpec
.
describe
BulkImports
::
Groups
::
Pipelines
::
LabelsPipeline
do
RSpec
.
describe
BulkImports
::
Common
::
Pipelines
::
LabelsPipeline
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:bulk_import
)
{
create
(
:bulk_import
,
user:
user
)
}
...
...
spec/lib/bulk_imports/groups/stage_spec.rb
View file @
ab4c50ac
...
...
@@ -9,7 +9,7 @@ RSpec.describe BulkImports::Groups::Stage do
[
1
,
BulkImports
::
Groups
::
Pipelines
::
GroupAvatarPipeline
],
[
1
,
BulkImports
::
Groups
::
Pipelines
::
SubgroupEntitiesPipeline
],
[
1
,
BulkImports
::
Groups
::
Pipelines
::
MembersPipeline
],
[
1
,
BulkImports
::
Groups
::
Pipelines
::
LabelsPipeline
],
[
1
,
BulkImports
::
Common
::
Pipelines
::
LabelsPipeline
],
[
1
,
BulkImports
::
Groups
::
Pipelines
::
MilestonesPipeline
],
[
1
,
BulkImports
::
Groups
::
Pipelines
::
BadgesPipeline
],
[
2
,
BulkImports
::
Groups
::
Pipelines
::
BoardsPipeline
]
...
...
spec/lib/bulk_imports/projects/stage_spec.rb
View file @
ab4c50ac
...
...
@@ -6,7 +6,8 @@ RSpec.describe BulkImports::Projects::Stage do
let
(
:pipelines
)
do
[
[
0
,
BulkImports
::
Projects
::
Pipelines
::
ProjectPipeline
],
[
1
,
BulkImports
::
Common
::
Pipelines
::
EntityFinisher
]
[
1
,
BulkImports
::
Common
::
Pipelines
::
LabelsPipeline
],
[
2
,
BulkImports
::
Common
::
Pipelines
::
EntityFinisher
]
]
end
...
...
spec/models/bulk_imports/entity_spec.rb
View file @
ab4c50ac
...
...
@@ -207,4 +207,40 @@ RSpec.describe BulkImports::Entity, type: :model do
expect
(
entity
.
pipeline_exists?
(
'BulkImports::Groups::Pipelines::InexistentPipeline'
)).
to
eq
(
false
)
end
end
describe
'#pluralized_name'
do
context
'when entity is group'
do
it
'returns groups'
do
entity
=
build
(
:bulk_import_entity
,
:group_entity
)
expect
(
entity
.
pluralized_name
).
to
eq
(
'groups'
)
end
end
context
'when entity is project'
do
it
'returns projects'
do
entity
=
build
(
:bulk_import_entity
,
:project_entity
)
expect
(
entity
.
pluralized_name
).
to
eq
(
'projects'
)
end
end
end
describe
'#export_relations_url_path'
do
context
'when entity is group'
do
it
'returns group export relations url'
do
entity
=
build
(
:bulk_import_entity
,
:group_entity
)
expect
(
entity
.
export_relations_url_path
).
to
eq
(
"/groups/
#{
entity
.
encoded_source_full_path
}
/export_relations"
)
end
end
context
'when entity is project'
do
it
'returns project export relations url'
do
entity
=
build
(
:bulk_import_entity
,
:project_entity
)
expect
(
entity
.
export_relations_url_path
).
to
eq
(
"/projects/
#{
entity
.
encoded_source_full_path
}
/export_relations"
)
end
end
end
end
spec/workers/bulk_import_worker_spec.rb
View file @
ab4c50ac
...
...
@@ -111,10 +111,10 @@ RSpec.describe BulkImportWorker do
end
context
'when there are project entities to process'
do
it
'
does not enqueue
ExportRequestWorker'
do
it
'
enqueues
ExportRequestWorker'
do
create
(
:bulk_import_entity
,
:created
,
:project_entity
,
bulk_import:
bulk_import
)
expect
(
BulkImports
::
ExportRequestWorker
).
not_to
receive
(
:perform_async
)
expect
(
BulkImports
::
ExportRequestWorker
).
to
receive
(
:perform_async
).
once
subject
.
perform
(
bulk_import
.
id
)
end
...
...
spec/workers/bulk_imports/export_request_worker_spec.rb
View file @
ab4c50ac
...
...
@@ -5,7 +5,6 @@ require 'spec_helper'
RSpec
.
describe
BulkImports
::
ExportRequestWorker
do
let_it_be
(
:bulk_import
)
{
create
(
:bulk_import
)
}
let_it_be
(
:config
)
{
create
(
:bulk_import_configuration
,
bulk_import:
bulk_import
)
}
let_it_be
(
:entity
)
{
create
(
:bulk_import_entity
,
source_full_path:
'foo/bar'
,
bulk_import:
bulk_import
)
}
let_it_be
(
:version_url
)
{
'https://gitlab.example/api/v4/version'
}
let
(
:response_double
)
{
double
(
code:
200
,
success?:
true
,
parsed_response:
{})
}
...
...
@@ -20,16 +19,30 @@ RSpec.describe BulkImports::ExportRequestWorker do
allow
(
Gitlab
::
HTTP
).
to
receive
(
:post
).
and_return
(
response_double
)
end
include_examples
'an idempotent worker'
do
it
'requests relations export'
do
expected
=
"/groups/foo%2Fbar/export_relations"
shared_examples
'requests relations export for api resource'
do
include_examples
'an idempotent worker'
do
it
'requests relations export'
do
expect_next_instance_of
(
BulkImports
::
Clients
::
HTTP
)
do
|
client
|
expect
(
client
).
to
receive
(
:post
).
with
(
expected
).
twice
end
expect_next_instance_of
(
BulkImports
::
Clients
::
HTTP
)
do
|
client
|
expect
(
client
).
to
receive
(
:post
).
with
(
expected
).
twice
perform_multiple
(
job_args
)
end
perform_multiple
(
job_args
)
end
end
context
'when entity is group'
do
let
(
:entity
)
{
create
(
:bulk_import_entity
,
:group_entity
,
source_full_path:
'foo/bar'
,
bulk_import:
bulk_import
)
}
let
(
:expected
)
{
'/groups/foo%2Fbar/export_relations'
}
include_examples
'requests relations export for api resource'
end
context
'when entity is project'
do
let
(
:entity
)
{
create
(
:bulk_import_entity
,
:project_entity
,
source_full_path:
'foo/bar'
,
bulk_import:
bulk_import
)
}
let
(
:expected
)
{
'/projects/foo%2Fbar/export_relations'
}
include_examples
'requests relations export for api resource'
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment