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
2307b35f
Commit
2307b35f
authored
Nov 07, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an event store for hashed migration events
parent
8d2fa510
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
0 deletions
+84
-0
app/services/geo/hashed_storage_migrated_event_store.rb
app/services/geo/hashed_storage_migrated_event_store.rb
+33
-0
spec/services/geo/hashed_storage_migrated_event_store_spec.rb
.../services/geo/hashed_storage_migrated_event_store_spec.rb
+51
-0
No files found.
app/services/geo/hashed_storage_migrated_event_store.rb
0 → 100644
View file @
2307b35f
module
Geo
class
HashedStorageMigratedEventStore
<
EventStore
self
.
event_type
=
:hashed_storage_migrated_event
private
def
build_event
Geo
::
HashedStorageMigratedEvent
.
new
(
project:
project
,
old_storage_version:
old_storage_version
,
new_storage_version:
project
.
storage_version
,
repository_storage_name:
project
.
repository
.
storage
,
repository_storage_path:
project
.
repository_storage_path
,
old_disk_path:
old_disk_path
,
new_disk_path:
project
.
disk_path
,
old_wiki_disk_path:
old_wiki_disk_path
,
new_wiki_disk_path:
project
.
wiki
.
disk_path
)
end
def
old_storage_version
params
.
fetch
(
:old_storage_version
)
end
def
old_disk_path
params
.
fetch
(
:old_disk_path
)
end
def
old_wiki_disk_path
"
#{
old_disk_path
}
.wiki"
end
end
end
spec/services/geo/hashed_storage_migrated_event_store_spec.rb
0 → 100644
View file @
2307b35f
require
'spec_helper'
describe
Geo
::
HashedStorageMigratedEventStore
do
set
(
:project
)
{
create
(
:project
,
:hashed
,
path:
'bar'
)
}
set
(
:secondary_node
)
{
create
(
:geo_node
)
}
let
(
:old_disk_path
)
{
"
#{
project
.
namespace
.
full_path
}
/foo"
}
let
(
:old_wiki_disk_path
)
{
"
#{
old_disk_path
}
.wiki"
}
subject
(
:event_store
)
{
described_class
.
new
(
project
,
old_storage_version:
nil
,
old_disk_path:
old_disk_path
,
old_wiki_disk_path:
old_wiki_disk_path
)
}
describe
'#create'
do
it
'does not create an event when not running on a primary node'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
false
}
expect
{
event_store
.
create
}.
not_to
change
(
Geo
::
HashedStorageMigratedEvent
,
:count
)
end
context
'when running on a primary node'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
true
}
end
it
'does not create an event when there are no secondary nodes'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary_nodes
)
{
[]
}
expect
{
subject
.
create
}.
not_to
change
(
Geo
::
HashedStorageMigratedEvent
,
:count
)
end
it
'creates a hashed migration event'
do
expect
{
event_store
.
create
}.
to
change
(
Geo
::
HashedStorageMigratedEvent
,
:count
).
by
(
1
)
end
it
'tracks project attributes'
do
event_store
.
create
event
=
Geo
::
HashedStorageMigratedEvent
.
last
expect
(
event
).
to
have_attributes
(
repository_storage_name:
project
.
repository_storage
,
repository_storage_path:
project
.
repository_storage_path
,
old_storage_version:
nil
,
new_storage_version:
project
.
storage_version
,
old_disk_path:
old_disk_path
,
new_disk_path:
project
.
disk_path
,
old_wiki_disk_path:
old_wiki_disk_path
,
new_wiki_disk_path:
project
.
wiki
.
disk_path
)
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