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
4b12a6ab
Commit
4b12a6ab
authored
Jan 02, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More clean up with GeoNodeStatus
parent
f90d7af4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
ee/app/models/geo_node_status.rb
ee/app/models/geo_node_status.rb
+10
-2
spec/ee/spec/models/geo_node_status_spec.rb
spec/ee/spec/models/geo_node_status_spec.rb
+5
-5
spec/factories/geo_node_statuses.rb
spec/factories/geo_node_statuses.rb
+1
-1
No files found.
ee/app/models/geo_node_status.rb
View file @
4b12a6ab
...
...
@@ -159,7 +159,7 @@ class GeoNodeStatus < ActiveRecord::Base
def
storage_shards_match?
return
unless
Gitlab
::
Geo
.
primary?
shards_match?
(
storage_shards
.
as_json
,
current_shards
.
as_json
)
shards_match?
(
current_shards
,
primary_shards
)
end
def
[]
(
key
)
...
...
@@ -169,7 +169,15 @@ class GeoNodeStatus < ActiveRecord::Base
private
def
current_shards
StorageShardSerializer
.
new
.
represent
(
StorageShard
.
all
)
serialize_storage_shards
(
storage_shards
)
end
def
primary_shards
serialize_storage_shards
(
StorageShard
.
all
)
end
def
serialize_storage_shards
(
shards
)
StorageShardSerializer
.
new
.
represent
(
shards
).
as_json
end
def
shards_match?
(
first
,
second
)
...
...
spec/ee/spec/models/geo_node_status_spec.rb
View file @
4b12a6ab
...
...
@@ -425,22 +425,22 @@ describe GeoNodeStatus, :geo do
it
'returns false if the storage shards do not match'
do
status
=
create
(
:geo_node_status
)
status
.
storage_shards
.
first
[
'name'
]
=
'broken-shard'
data
=
status
.
as_json
data
=
GeoNodeStatusSerializer
.
new
.
represent
(
status
).
as_json
data
[
'storage_shards'
].
first
[
'name'
]
=
'broken-shard'
result
=
GeoNodeStatus
.
from_json
(
data
)
expect
(
status
.
storage_shards_match?
).
to
be
false
expect
(
result
.
storage_shards_match?
).
to
be
false
end
it
'returns true if the storage shards match in different order'
do
status
=
create
(
:geo_node_status
)
status
.
storage_shards
.
shuffle!
data
=
status
.
as_json
data
=
GeoNodeStatusSerializer
.
new
.
represent
(
status
)
.
as_json
result
=
GeoNodeStatus
.
from_json
(
data
)
expect
(
status
.
storage_shards_match?
).
to
be
true
expect
(
result
.
storage_shards_match?
).
to
be
true
end
end
end
spec/factories/geo_node_statuses.rb
View file @
4b12a6ab
...
...
@@ -2,7 +2,7 @@ FactoryBot.define do
factory
:geo_node_status
do
sequence
(
:id
)
geo_node
storage_shards
{
StorageShard
Serializer
.
new
.
represent
(
StorageShard
.
all
)
}
storage_shards
{
StorageShard
.
all
}
trait
:healthy
do
health
nil
...
...
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