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
3b77bc6c
Commit
3b77bc6c
authored
Nov 20, 2019
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move designs repository to the new storage if it exists
parent
4b9d7b80
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
24 deletions
+54
-24
ee/app/services/projects/update_repository_storage_service.rb
...pp/services/projects/update_repository_storage_service.rb
+11
-0
ee/spec/services/projects/update_repository_storage_service_spec.rb
...rvices/projects/update_repository_storage_service_spec.rb
+43
-24
No files found.
ee/app/services/projects/update_repository_storage_service.rb
View file @
3b77bc6c
...
...
@@ -23,6 +23,10 @@ module Projects
result
&&=
mirror_repository
(
new_repository_storage_key
,
type:
Gitlab
::
GlRepository
::
WIKI
)
end
if
project
.
design_repository
.
exists?
result
&&=
mirror_repository
(
new_repository_storage_key
,
type:
Gitlab
::
GlRepository
::
DESIGN
)
end
if
result
mark_old_paths_for_archive
...
...
@@ -71,6 +75,13 @@ module Projects
wiki
.
disk_path
,
"
#{
new_project_path
}
.wiki"
)
end
if
design_repository
.
exists?
GitlabShellWorker
.
perform_async
(
:mv_repository
,
old_repository_storage
,
design_repository
.
disk_path
,
"
#{
new_project_path
}
.design"
)
end
end
end
...
...
ee/spec/services/projects/update_repository_storage_service_spec.rb
View file @
3b77bc6c
...
...
@@ -14,7 +14,7 @@ describe Projects::UpdateRepositoryStorageService do
allow
(
Time
).
to
receive
(
:now
).
and_return
(
time
)
end
context
'without wiki'
do
context
'without wiki
and design repository
'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
repository_read_only:
true
,
wiki_enabled:
false
)
}
context
'when the move succeeds'
do
...
...
@@ -56,47 +56,43 @@ describe Projects::UpdateRepositoryStorageService do
end
end
context
'with wiki'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
repository_read_only:
true
,
wiki_enabled:
true
)
}
shared_examples
'moves repository to another storage'
do
|
repository_type
|
let
(
:project
_repository_double
)
{
double
(
:repository
)
}
let
(
:repository_double
)
{
double
(
:repository
)
}
let
(
:wiki_repository_double
)
{
double
(
:repository
)
}
before
do
project
.
create_wiki
# Default stub for non-specified params
allow
(
Gitlab
::
Git
::
Repository
).
to
receive
(
:new
).
and_call_original
relative_path
=
project
.
repository
.
raw
.
relative_path
allow
(
Gitlab
::
Git
::
Repository
).
to
receive
(
:new
)
.
with
(
'test_second_storage'
,
relative_path
,
"project-
#{
project
.
id
}
"
,
project
.
full_path
)
.
and_return
(
repository_double
)
.
with
(
'test_second_storage'
,
project
.
repository
.
raw
.
relative_path
,
project
.
repository
.
gl_repository
,
project
.
repository
.
full_path
)
.
and_return
(
project_
repository_double
)
wiki_relative_path
=
project
.
wiki
.
repository
.
raw
.
relative_path
allow
(
Gitlab
::
Git
::
Repository
).
to
receive
(
:new
)
.
with
(
'test_second_storage'
,
wiki_relative_path
,
"wiki-
#{
project
.
id
}
"
,
project
.
wiki
.
full_path
)
.
and_return
(
wiki_
repository_double
)
.
with
(
'test_second_storage'
,
repository
.
raw
.
relative_path
,
repository
.
gl_repository
,
repository
.
full_path
)
.
and_return
(
repository_double
)
end
context
'when the move succeeds'
do
it
'moves the repository and its wiki to the new storage and unmarks the repository as read only'
do
old_path
=
Gitlab
::
GitalyClient
::
StorageSettings
.
allow_disk_access
do
it
"moves the project and its
#{
repository_type
}
repository to the new storage and unmarks the repository as read only"
do
old_p
roject_repository_p
ath
=
Gitlab
::
GitalyClient
::
StorageSettings
.
allow_disk_access
do
project
.
repository
.
path_to_repo
end
old_wiki_path
=
project
.
wiki
.
full_path
expect
(
repository_double
).
to
receive
(
:fetch_repository_as_mirror
)
old_repository_path
=
repository
.
full_path
allow
(
project_repository_double
).
to
receive
(
:fetch_repository_as_mirror
)
.
with
(
project
.
repository
.
raw
).
and_return
(
true
)
expect
(
wiki_
repository_double
).
to
receive
(
:fetch_repository_as_mirror
)
.
with
(
project
.
wiki
.
repository
.
raw
).
and_return
(
true
)
allow
(
repository_double
).
to
receive
(
:fetch_repository_as_mirror
)
.
with
(
repository
.
raw
).
and_return
(
true
)
subject
.
execute
(
'test_second_storage'
)
expect
(
project
).
not_to
be_repository_read_only
expect
(
project
.
repository_storage
).
to
eq
(
'test_second_storage'
)
expect
(
gitlab_shell
.
repository_exists?
(
'default'
,
old_path
)).
to
be
(
false
)
expect
(
gitlab_shell
.
repository_exists?
(
'default'
,
old_
wiki
_path
)).
to
be
(
false
)
expect
(
gitlab_shell
.
repository_exists?
(
'default'
,
old_p
roject_repository_p
ath
)).
to
be
(
false
)
expect
(
gitlab_shell
.
repository_exists?
(
'default'
,
old_
repository
_path
)).
to
be
(
false
)
end
end
...
...
@@ -108,12 +104,13 @@ describe Projects::UpdateRepositoryStorageService do
end
end
context
'when the move of the wiki fails'
do
context
"when the move of the
#{
repository_type
}
repository fails"
do
it
'unmarks the repository as read-only without updating the repository storage'
do
expect
(
repository_double
).
to
receive
(
:fetch_repository_as_mirror
)
allow
(
project_
repository_double
).
to
receive
(
:fetch_repository_as_mirror
)
.
with
(
project
.
repository
.
raw
).
and_return
(
true
)
expect
(
wiki_repository_double
).
to
receive
(
:fetch_repository_as_mirror
)
.
with
(
project
.
wiki
.
repository
.
raw
).
and_return
(
false
)
allow
(
repository_double
).
to
receive
(
:fetch_repository_as_mirror
)
.
with
(
repository
.
raw
).
and_return
(
false
)
expect
(
GitlabShellWorker
).
not_to
receive
(
:perform_async
)
subject
.
execute
(
'test_second_storage'
)
...
...
@@ -124,6 +121,28 @@ describe Projects::UpdateRepositoryStorageService do
end
end
context
'with wiki repository'
do
include_examples
'moves repository to another storage'
,
'wiki'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
repository_read_only:
true
,
wiki_enabled:
true
)
}
let
(
:repository
)
{
project
.
wiki
.
repository
}
before
do
project
.
create_wiki
end
end
end
context
'with design repository'
do
include_examples
'moves repository to another storage'
,
'design'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
repository_read_only:
true
)
}
let
(
:repository
)
{
project
.
design_repository
}
before
do
project
.
design_repository
.
create_if_not_exists
end
end
end
context
'when a object pool was joined'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
wiki_enabled:
false
,
repository_read_only:
true
)
}
let
(
:pool
)
{
create
(
:pool_repository
,
:ready
,
source_project:
project
)
}
...
...
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