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
21216d47
Commit
21216d47
authored
Sep 30, 2021
by
George Koltsov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused BulkImports files
parent
717f1534
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
214 deletions
+0
-214
ee/lib/bulk_imports/pipeline/epic_base.rb
ee/lib/bulk_imports/pipeline/epic_base.rb
+0
-57
ee/spec/lib/bulk_imports/pipeline/epic_base_spec.rb
ee/spec/lib/bulk_imports/pipeline/epic_base_spec.rb
+0
-157
No files found.
ee/lib/bulk_imports/pipeline/epic_base.rb
deleted
100644 → 0
View file @
717f1534
# frozen_string_literal: true
module
BulkImports
module
Pipeline
class
EpicBase
include
::
BulkImports
::
Pipeline
def
initialize
(
context
)
super
(
context
)
return
if
context
.
group
.
blank?
@epic_iids
=
context
.
group
.
epics
.
order
(
iid: :desc
).
pluck
(
:iid
)
# rubocop: disable CodeReuse/ActiveRecord
set_next_epic
end
def
run
return
skip!
(
skip_reason
)
if
current_epic_iid
.
blank?
super
end
private
attr_reader
:epic_iids
def
after_run
(
extracted_data
)
set_next_epic
unless
extracted_data
.
has_next_page?
if
has_next_page_or_next_epic?
(
extracted_data
)
run
end
end
def
set_next_epic
context
.
extra
[
:epic_iid
]
=
epic_iids
.
pop
end
def
has_next_page_or_next_epic?
(
extracted_data
)
extracted_data
.
has_next_page?
||
current_epic_iid
end
def
current_epic_iid
context
.
extra
[
:epic_iid
]
end
def
skip_reason
if
context
.
group
.
blank?
'Skipping because bulk import has no group'
else
'Skipping because group has no epics'
end
end
end
end
end
ee/spec/lib/bulk_imports/pipeline/epic_base_spec.rb
deleted
100644 → 0
View file @
717f1534
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
BulkImports
::
Pipeline
::
EpicBase
do
let
(
:pipeline_class
)
do
Class
.
new
(
BulkImports
::
Pipeline
::
EpicBase
)
do
def
extract
(
_
)
::
BulkImports
::
Pipeline
::
ExtractedData
.
new
end
def
transform
(
_
,
data
)
data
end
def
load
(
_
,
data
)
data
end
end
end
subject
{
MyPipeline
.
new
(
context
)
}
before
do
stub_const
(
'MyPipeline'
,
pipeline_class
)
end
context
'when the group was not imported'
do
let_it_be
(
:pipeline_tracker
)
{
create
(
:bulk_import_tracker
)
}
let_it_be
(
:context
)
{
BulkImports
::
Pipeline
::
Context
.
new
(
pipeline_tracker
)
}
it
'skips the pipeline'
do
expect_next_instance_of
(
Gitlab
::
Import
::
Logger
)
do
|
logger
|
expect
(
logger
).
to
receive
(
:warn
)
.
with
(
bulk_import_id:
pipeline_tracker
.
entity
.
bulk_import
.
id
,
bulk_import_entity_id:
pipeline_tracker
.
entity
.
id
,
bulk_import_entity_type:
pipeline_tracker
.
entity
.
source_type
,
message:
'Skipping because bulk import has no group'
,
pipeline_class:
'MyPipeline'
)
end
expect
{
subject
.
run
}
.
to
change
(
pipeline_tracker
,
:status_name
).
to
(
:skipped
)
end
end
context
'when the group was already imported'
do
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:entity
)
{
create
(
:bulk_import_entity
,
group:
group
)
}
let_it_be
(
:pipeline_tracker
)
{
create
(
:bulk_import_tracker
,
entity:
entity
)
}
let_it_be
(
:context
)
{
BulkImports
::
Pipeline
::
Context
.
new
(
pipeline_tracker
)
}
context
'when the group has no epics'
do
it
'skips the pipeline'
do
expect_next_instance_of
(
Gitlab
::
Import
::
Logger
)
do
|
logger
|
expect
(
logger
).
to
receive
(
:warn
)
.
with
(
bulk_import_id:
entity
.
bulk_import
.
id
,
bulk_import_entity_id:
entity
.
id
,
bulk_import_entity_type:
entity
.
source_type
,
context_extra:
{
epic_iid:
nil
},
message:
'Skipping because group has no epics'
,
pipeline_class:
'MyPipeline'
)
end
expect
{
subject
.
run
}
.
to
change
(
pipeline_tracker
,
:status_name
).
to
(
:skipped
)
end
end
context
'when the group has one epic with one page of data'
do
it
'runs the pipeline for each epic'
do
create
(
:epic
,
group:
group
)
expect
(
subject
)
.
to
receive
(
:run
)
.
once
.
and_call_original
subject
.
run
end
end
context
'when the group has one epic with multiple page of data'
do
it
'runs the pipeline for page'
do
create
(
:epic
,
group:
group
)
first_page
=
::
BulkImports
::
Pipeline
::
ExtractedData
.
new
(
page_info:
{
'has_next_page'
=>
true
,
'next_page'
=>
'page'
})
last_page
=
::
BulkImports
::
Pipeline
::
ExtractedData
.
new
(
page_info:
{
'has_next_page'
=>
false
})
expect
(
subject
)
.
to
receive
(
:extract
)
.
and_return
(
first_page
,
last_page
)
expect
(
subject
)
.
to
receive
(
:run
)
.
twice
.
and_call_original
subject
.
run
end
end
context
'when the group has multiple epics with one page of data'
do
it
'runs the pipeline once for each epic'
do
create
(
:epic
,
group:
group
)
create
(
:epic
,
group:
group
)
expect
(
subject
)
.
to
receive
(
:run
)
.
twice
.
and_call_original
subject
.
run
end
end
context
'when the group has multiple epics with multiple pages of data'
do
it
'runs the pipeline once for each page of each epic'
do
create
(
:epic
,
group:
group
)
create
(
:epic
,
group:
group
)
first_page
=
::
BulkImports
::
Pipeline
::
ExtractedData
.
new
(
page_info:
{
'has_next_page'
=>
true
,
'next_page'
=>
'page'
})
last_page
=
::
BulkImports
::
Pipeline
::
ExtractedData
.
new
(
page_info:
{
'has_next_page'
=>
false
})
expect
(
subject
)
.
to
receive
(
:extract
)
.
and_return
(
first_page
,
# first epic
last_page
,
# first epic
first_page
,
# last epic
last_page
# last epic
)
expect
(
subject
)
.
to
receive
(
:run
)
.
exactly
(
4
).
times
.
and_call_original
subject
.
run
end
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