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
8e12d060
Commit
8e12d060
authored
Jan 03, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address review comments
parent
21770a42
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
13 deletions
+26
-13
app/models/storage_shard.rb
app/models/storage_shard.rb
+2
-3
spec/ee/spec/models/geo_node_status_spec.rb
spec/ee/spec/models/geo_node_status_spec.rb
+4
-6
spec/ee/spec/serializers/geo_node_status_entity_spec.rb
spec/ee/spec/serializers/geo_node_status_entity_spec.rb
+10
-3
spec/ee/support/geo_helpers.rb
spec/ee/support/geo_helpers.rb
+9
-0
spec/models/storage_shard_spec.rb
spec/models/storage_shard_spec.rb
+1
-1
No files found.
app/models/storage_shard.rb
View file @
8e12d060
...
@@ -4,11 +4,10 @@
...
@@ -4,11 +4,10 @@
class
StorageShard
class
StorageShard
include
ActiveModel
::
Model
include
ActiveModel
::
Model
attr_accessor
:name
,
:path
,
:gitaly_address
,
:gitaly_token
attr_accessor
:name
,
:path
validates
:name
,
presence:
true
validates
:name
,
presence:
true
validates
:path
,
presence:
true
validates
:path
,
presence:
true
validates
:gitaly_address
,
presence:
true
# Generates an array of StorageShard objects from the currrent storage
# Generates an array of StorageShard objects from the currrent storage
# configuration using the gitlab.yml array of key/value pairs:
# configuration using the gitlab.yml array of key/value pairs:
...
@@ -25,6 +24,6 @@ class StorageShard
...
@@ -25,6 +24,6 @@ class StorageShard
end
end
def
self
.
allowed_params
def
self
.
allowed_params
%i(name path
gitaly_address gitaly_token
)
.
freeze
%i(name path)
.
freeze
end
end
end
end
spec/ee/spec/models/geo_node_status_spec.rb
View file @
8e12d060
...
@@ -409,7 +409,7 @@ describe GeoNodeStatus, :geo do
...
@@ -409,7 +409,7 @@ describe GeoNodeStatus, :geo do
data
=
GeoNodeStatusSerializer
.
new
.
represent
(
status
).
as_json
data
=
GeoNodeStatusSerializer
.
new
.
represent
(
status
).
as_json
data
[
'id'
]
=
10000
data
[
'id'
]
=
10000
result
=
GeoNodeStatu
s
.
from_json
(
data
)
result
=
described_clas
s
.
from_json
(
data
)
expect
(
result
.
id
).
to
be_nil
expect
(
result
.
id
).
to
be_nil
expect
(
result
.
attachments_count
).
to
eq
(
status
.
attachments_count
)
expect
(
result
.
attachments_count
).
to
eq
(
status
.
attachments_count
)
...
@@ -419,16 +419,14 @@ describe GeoNodeStatus, :geo do
...
@@ -419,16 +419,14 @@ describe GeoNodeStatus, :geo do
end
end
describe
'#storage_shards_match?'
do
describe
'#storage_shards_match?'
do
before
do
before
{
stub_primary_node
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
).
and_return
(
true
)
end
it
'returns false if the storage shards do not match'
do
it
'returns false if the storage shards do not match'
do
status
=
create
(
:geo_node_status
)
status
=
create
(
:geo_node_status
)
data
=
GeoNodeStatusSerializer
.
new
.
represent
(
status
).
as_json
data
=
GeoNodeStatusSerializer
.
new
.
represent
(
status
).
as_json
data
[
'storage_shards'
].
first
[
'name'
]
=
'broken-shard'
data
[
'storage_shards'
].
first
[
'name'
]
=
'broken-shard'
result
=
GeoNodeStatu
s
.
from_json
(
data
)
result
=
described_clas
s
.
from_json
(
data
)
expect
(
result
.
storage_shards_match?
).
to
be
false
expect
(
result
.
storage_shards_match?
).
to
be
false
end
end
...
@@ -438,7 +436,7 @@ describe GeoNodeStatus, :geo do
...
@@ -438,7 +436,7 @@ describe GeoNodeStatus, :geo do
status
.
storage_shards
.
shuffle!
status
.
storage_shards
.
shuffle!
data
=
GeoNodeStatusSerializer
.
new
.
represent
(
status
).
as_json
data
=
GeoNodeStatusSerializer
.
new
.
represent
(
status
).
as_json
result
=
GeoNodeStatu
s
.
from_json
(
data
)
result
=
described_clas
s
.
from_json
(
data
)
expect
(
result
.
storage_shards_match?
).
to
be
true
expect
(
result
.
storage_shards_match?
).
to
be
true
end
end
...
...
spec/ee/spec/serializers/geo_node_status_entity_spec.rb
View file @
8e12d060
require
'spec_helper'
require
'spec_helper'
describe
GeoNodeStatusEntity
,
:postgresql
do
describe
GeoNodeStatusEntity
,
:postgresql
do
include
::
EE
::
GeoHelpers
let
(
:geo_node_status
)
{
build
(
:geo_node_status
)
}
let
(
:geo_node_status
)
{
build
(
:geo_node_status
)
}
let
(
:entity
)
{
described_class
.
new
(
geo_node_status
,
request:
double
)
}
let
(
:entity
)
{
described_class
.
new
(
geo_node_status
,
request:
double
)
}
let
(
:error
)
{
'Could not connect to Geo database'
}
let
(
:error
)
{
'Could not connect to Geo database'
}
subject
{
entity
.
as_json
}
subject
{
entity
.
as_json
}
before
do
before
{
stub_primary_node
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
).
and_return
(
true
)
end
it
{
is_expected
.
to
have_key
(
:geo_node_id
)
}
it
{
is_expected
.
to
have_key
(
:geo_node_id
)
}
it
{
is_expected
.
to
have_key
(
:healthy
)
}
it
{
is_expected
.
to
have_key
(
:healthy
)
}
...
@@ -143,4 +143,11 @@ describe GeoNodeStatusEntity, :postgresql do
...
@@ -143,4 +143,11 @@ describe GeoNodeStatusEntity, :postgresql do
expect
(
subject
[
:storage_shards
].
first
[
:path
]).
to
eq
(
shards
.
first
.
path
)
expect
(
subject
[
:storage_shards
].
first
[
:path
]).
to
eq
(
shards
.
first
.
path
)
end
end
end
end
context
'secondary Geo node'
do
before
{
stub_secondary_node
}
it
{
is_expected
.
to
have_key
(
:storage_shards
)
}
it
{
is_expected
.
not_to
have_key
(
:storage_shards_match
)
}
end
end
end
spec/ee/support/geo_helpers.rb
View file @
8e12d060
...
@@ -4,5 +4,14 @@ module EE
...
@@ -4,5 +4,14 @@ module EE
allow
(
::
Gitlab
::
Geo
).
to
receive
(
:current_node
).
and_return
(
node
)
allow
(
::
Gitlab
::
Geo
).
to
receive
(
:current_node
).
and_return
(
node
)
allow
(
node
).
to
receive
(
:current?
).
and_return
(
true
)
unless
node
.
nil?
allow
(
node
).
to
receive
(
:current?
).
and_return
(
true
)
unless
node
.
nil?
end
end
def
stub_primary_node
allow
(
::
Gitlab
::
Geo
).
to
receive
(
:primary?
).
and_return
(
true
)
end
def
stub_secondary_node
allow
(
::
Gitlab
::
Geo
).
to
receive
(
:primary?
).
and_return
(
false
)
allow
(
::
Gitlab
::
Geo
).
to
receive
(
:secondary?
).
and_return
(
false
)
end
end
end
end
end
spec/models/storage_shard_spec.rb
View file @
8e12d060
...
@@ -7,7 +7,7 @@ describe StorageShard do
...
@@ -7,7 +7,7 @@ describe StorageShard do
expect
(
shards
.
count
).
to
eq
(
Settings
.
repositories
.
storages
.
count
)
expect
(
shards
.
count
).
to
eq
(
Settings
.
repositories
.
storages
.
count
)
expect
(
shards
.
map
(
&
:name
)).
to
match_array
(
Settings
.
repositories
.
storages
.
keys
)
expect
(
shards
.
map
(
&
:name
)).
to
match_array
(
Settings
.
repositories
.
storages
.
keys
)
expect
(
shards
.
map
(
&
:path
)).
to
match_array
(
Settings
.
repositories
.
storages
.
values
.
map
{
|
x
|
x
.
path
}
)
expect
(
shards
.
map
(
&
:path
)).
to
match_array
(
Settings
.
repositories
.
storages
.
values
.
map
(
&
:path
)
)
end
end
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