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
3b0aedda
Commit
3b0aedda
authored
Sep 27, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send a Geo repository renamed event when migrating to hashed storage
parent
e96e3eb8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
5 deletions
+67
-5
app/services/geo/repository_renamed_event_store.rb
app/services/geo/repository_renamed_event_store.rb
+7
-3
app/services/projects/hashed_storage_migration_service.rb
app/services/projects/hashed_storage_migration_service.rb
+2
-0
ee/app/services/ee/projects/hashed_storage_migration_service.rb
.../services/ee/projects/hashed_storage_migration_service.rb
+17
-0
spec/ee/spec/services/ee/projects/hashed_storage_migration_service_spec.rb
...ices/ee/projects/hashed_storage_migration_service_spec.rb
+39
-0
spec/services/geo/repository_renamed_event_store_spec.rb
spec/services/geo/repository_renamed_event_store_spec.rb
+2
-2
No files found.
app/services/geo/repository_renamed_event_store.rb
View file @
3b0aedda
...
@@ -10,14 +10,18 @@ module Geo
...
@@ -10,14 +10,18 @@ module Geo
repository_storage_name:
project
.
repository
.
storage
,
repository_storage_name:
project
.
repository
.
storage
,
repository_storage_path:
project
.
repository_storage_path
,
repository_storage_path:
project
.
repository_storage_path
,
old_path_with_namespace:
old_path_with_namespace
,
old_path_with_namespace:
old_path_with_namespace
,
new_path_with_namespace:
project
.
full
_path
,
new_path_with_namespace:
project
.
disk
_path
,
old_wiki_path_with_namespace:
old_wiki_path_with_namespace
,
old_wiki_path_with_namespace:
old_wiki_path_with_namespace
,
new_wiki_path_with_namespace:
new_wiki_path_with_namespace
,
new_wiki_path_with_namespace:
new_wiki_path_with_namespace
,
old_path:
params
.
fetch
(
:old_path
)
,
old_path:
old_path
,
new_path:
project
.
path
new_path:
project
.
path
)
)
end
end
def
old_path
params
.
fetch
(
:old_path
)
end
def
old_path_with_namespace
def
old_path_with_namespace
params
.
fetch
(
:old_path_with_namespace
)
params
.
fetch
(
:old_path_with_namespace
)
end
end
...
@@ -27,7 +31,7 @@ module Geo
...
@@ -27,7 +31,7 @@ module Geo
end
end
def
new_wiki_path_with_namespace
def
new_wiki_path_with_namespace
project
.
wiki
.
full_path
"
#{
project
.
disk_path
}
.wiki"
end
end
end
end
end
end
app/services/projects/hashed_storage_migration_service.rb
View file @
3b0aedda
...
@@ -2,6 +2,8 @@ module Projects
...
@@ -2,6 +2,8 @@ module Projects
class
HashedStorageMigrationService
<
BaseService
class
HashedStorageMigrationService
<
BaseService
include
Gitlab
::
ShellAdapter
include
Gitlab
::
ShellAdapter
prepend
::
EE
::
Projects
::
HashedStorageMigrationService
attr_reader
:old_disk_path
,
:new_disk_path
attr_reader
:old_disk_path
,
:new_disk_path
def
initialize
(
project
,
logger
=
nil
)
def
initialize
(
project
,
logger
=
nil
)
...
...
ee/app/services/ee/projects/hashed_storage_migration_service.rb
0 → 100644
View file @
3b0aedda
module
EE
module
Projects
module
HashedStorageMigrationService
def
execute
raise
NotImplementedError
.
new
unless
defined?
(
super
)
super
do
::
Geo
::
RepositoryRenamedEventStore
.
new
(
project
,
old_path:
File
.
basename
(
old_disk_path
),
old_path_with_namespace:
old_disk_path
).
create
end
end
end
end
end
spec/ee/spec/services/ee/projects/hashed_storage_migration_service_spec.rb
0 → 100644
View file @
3b0aedda
require
'spec_helper'
describe
Projects
::
HashedStorageMigrationService
do
let
(
:project
)
{
create
(
:project
,
:empty_repo
,
:wiki_repo
)
}
let
(
:service
)
{
described_class
.
new
(
project
)
}
let
(
:legacy_storage
)
{
Storage
::
LegacyProject
.
new
(
project
)
}
let
(
:hashed_storage
)
{
Storage
::
HashedProject
.
new
(
project
)
}
describe
'#execute'
do
it
'creates a Geo::RepositoryRenamedEvent on success'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
).
and_return
(
true
)
expect
{
service
.
execute
}.
to
change
{
Geo
::
EventLog
.
count
}.
by
(
1
)
event
=
Geo
::
EventLog
.
first
.
event
expect
(
event
).
to
be_a
(
Geo
::
RepositoryRenamedEvent
)
expect
(
event
).
to
have_attributes
(
old_path:
project
.
path
,
new_path:
project
.
path
,
old_path_with_namespace:
legacy_storage
.
disk_path
,
new_path_with_namespace:
hashed_storage
.
disk_path
,
old_wiki_path_with_namespace:
legacy_storage
.
disk_path
+
'.wiki'
,
new_wiki_path_with_namespace:
hashed_storage
.
disk_path
+
'.wiki'
)
end
it
'does not create a Geo event on failure'
do
from_name
=
project
.
disk_path
to_name
=
hashed_storage
.
disk_path
allow
(
service
).
to
receive
(
:move_repository
).
and_call_original
allow
(
service
).
to
receive
(
:move_repository
).
with
(
from_name
,
to_name
).
once
{
false
}
# will disable first move only
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
).
and_return
(
true
)
expect
{
service
.
execute
}.
not_to
change
{
Geo
::
EventLog
.
count
}
end
end
end
spec/services/geo/repository_renamed_event_store_spec.rb
View file @
3b0aedda
...
@@ -31,9 +31,9 @@ describe Geo::RepositoryRenamedEventStore do
...
@@ -31,9 +31,9 @@ describe Geo::RepositoryRenamedEventStore do
expect
(
event
.
repository_storage_name
).
to
eq
(
project
.
repository_storage
)
expect
(
event
.
repository_storage_name
).
to
eq
(
project
.
repository_storage
)
expect
(
event
.
repository_storage_path
).
to
eq
(
project
.
repository_storage_path
)
expect
(
event
.
repository_storage_path
).
to
eq
(
project
.
repository_storage_path
)
expect
(
event
.
old_path_with_namespace
).
to
eq
(
old_path_with_namespace
)
expect
(
event
.
old_path_with_namespace
).
to
eq
(
old_path_with_namespace
)
expect
(
event
.
new_path_with_namespace
).
to
eq
(
project
.
full
_path
)
expect
(
event
.
new_path_with_namespace
).
to
eq
(
project
.
disk
_path
)
expect
(
event
.
old_wiki_path_with_namespace
).
to
eq
(
"
#{
old_path_with_namespace
}
.wiki"
)
expect
(
event
.
old_wiki_path_with_namespace
).
to
eq
(
"
#{
old_path_with_namespace
}
.wiki"
)
expect
(
event
.
new_wiki_path_with_namespace
).
to
eq
(
"
#{
project
.
full
_path
}
.wiki"
)
expect
(
event
.
new_wiki_path_with_namespace
).
to
eq
(
"
#{
project
.
disk
_path
}
.wiki"
)
expect
(
event
.
old_path
).
to
eq
(
old_path
)
expect
(
event
.
old_path
).
to
eq
(
old_path
)
expect
(
event
.
new_path
).
to
eq
(
project
.
path
)
expect
(
event
.
new_path
).
to
eq
(
project
.
path
)
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