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
1ddec596
Commit
1ddec596
authored
Dec 07, 2017
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Toon Claes: Expose Geo Node namespaces in status response
parent
297f1669
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
26 deletions
+49
-26
app/serializers/geo_node_status_entity.rb
app/serializers/geo_node_status_entity.rb
+7
-0
app/serializers/namespace_entity.rb
app/serializers/namespace_entity.rb
+3
-0
spec/factories/geo_node_statuses.rb
spec/factories/geo_node_statuses.rb
+1
-0
spec/fixtures/api/schemas/geo_node_status.json
spec/fixtures/api/schemas/geo_node_status.json
+6
-2
spec/serializers/geo_node_status_entity_spec.rb
spec/serializers/geo_node_status_entity_spec.rb
+32
-24
No files found.
app/serializers/geo_node_status_entity.rb
View file @
1ddec596
...
...
@@ -7,6 +7,7 @@ class GeoNodeStatusEntity < Grape::Entity
expose
:health
do
|
node
|
node
.
healthy?
?
'Healthy'
:
node
.
health
end
expose
:health_status
expose
:attachments_count
expose
:attachments_synced_count
...
...
@@ -37,4 +38,10 @@ class GeoNodeStatusEntity < Grape::Entity
expose
:cursor_last_event_timestamp
expose
:last_successful_status_check_timestamp
expose
:namespaces
,
using:
NamespaceEntity
def
namespaces
object
.
geo_node
.
namespaces
end
end
app/serializers/namespace_entity.rb
0 → 100644
View file @
1ddec596
class
NamespaceEntity
<
Grape
::
Entity
expose
:id
,
:name
,
:path
,
:kind
,
:full_path
,
:parent_id
end
spec/factories/geo_node_statuses.rb
View file @
1ddec596
...
...
@@ -18,6 +18,7 @@ FactoryGirl.define do
last_event_timestamp
Time
.
now
.
to_i
cursor_last_event_id
1
cursor_last_event_timestamp
Time
.
now
.
to_i
last_successful_status_check_timestamp
Time
.
now
.
beginning_of_day
end
trait
:unhealthy
do
...
...
spec/fixtures/api/schemas/geo_node_status.json
View file @
1ddec596
...
...
@@ -4,6 +4,7 @@
"geo_node_id"
,
"healthy"
,
"health"
,
"health_status"
,
"attachments_count"
,
"attachments_failed_count"
,
"attachments_synced_count"
,
...
...
@@ -17,12 +18,14 @@
"last_event_id"
,
"last_event_timestamp"
,
"cursor_last_event_id"
,
"cursor_last_event_timestamp"
"cursor_last_event_timestamp"
,
"namespaces"
],
"properties"
:
{
"geo_node_id"
:
{
"type"
:
"integer"
},
"healthy"
:
{
"type"
:
"boolean"
},
"health"
:
{
"type"
:
[
"string"
,
"null"
]
},
"health_status"
:
{
"type"
:
"string"
},
"attachments_count"
:
{
"type"
:
"integer"
},
"attachments_failed_count"
:
{
"type"
:
"integer"
},
"attachments_synced_count"
:
{
"type"
:
"integer"
},
...
...
@@ -40,7 +43,8 @@
"last_event_timestamp"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"cursor_last_event_id"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"cursor_last_event_timestamp"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"last_successful_status_check_timestamp"
:
{
"type"
:
[
"integer"
,
"null"
]
}
"last_successful_status_check_timestamp"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"namespaces"
:
{
"type"
:
"array"
}
},
"additionalProperties"
:
false
}
spec/serializers/geo_node_status_entity_spec.rb
View file @
1ddec596
require
'spec_helper'
describe
GeoNodeStatusEntity
,
:postgresql
do
let
(
:geo_node_status
)
do
GeoNodeStatus
.
new
(
geo_node_id:
1
,
health:
''
,
attachments_count:
329
,
attachments_failed_count:
25
,
attachments_synced_count:
141
,
lfs_objects_count:
256
,
lfs_objects_failed_count:
12
,
lfs_objects_synced_count:
123
,
repositories_count:
10
,
repositories_synced_count:
5
,
repositories_failed_count:
0
,
last_successful_status_check_timestamp:
Time
.
now
.
beginning_of_day
)
end
let
(
:entity
)
do
described_class
.
new
(
geo_node_status
,
request:
double
)
end
let
(
:error
)
do
'Could not connect to Geo database'
end
let
(
:geo_node_status
)
{
build
(
:geo_node_status
)
}
let
(
:entity
)
{
described_class
.
new
(
geo_node_status
,
request:
double
)
}
let
(
:error
)
{
'Could not connect to Geo database'
}
subject
{
entity
.
as_json
}
...
...
@@ -44,6 +23,7 @@ describe GeoNodeStatusEntity, :postgresql do
it
{
is_expected
.
to
have_key
(
:repositories_synced_count
)}
it
{
is_expected
.
to
have_key
(
:repositories_synced_in_percentage
)
}
it
{
is_expected
.
to
have_key
(
:last_successful_status_check_timestamp
)
}
it
{
is_expected
.
to
have_key
(
:namespaces
)
}
describe
'#healthy'
do
context
'when node is healthy'
do
...
...
@@ -87,19 +67,47 @@ describe GeoNodeStatusEntity, :postgresql do
describe
'#attachments_synced_in_percentage'
do
it
'formats as percentage'
do
geo_node_status
.
assign_attributes
(
attachments_count:
329
,
attachments_failed_count:
25
,
attachments_synced_count:
141
)
expect
(
subject
[
:attachments_synced_in_percentage
]).
to
eq
'42.86%'
end
end
describe
'#lfs_objects_synced_in_percentage'
do
it
'formats as percentage'
do
geo_node_status
.
assign_attributes
(
lfs_objects_count:
256
,
lfs_objects_failed_count:
12
,
lfs_objects_synced_count:
123
)
expect
(
subject
[
:lfs_objects_synced_in_percentage
]).
to
eq
'48.05%'
end
end
describe
'#repositories_synced_in_percentage'
do
it
'formats as percentage'
do
geo_node_status
.
assign_attributes
(
repositories_count:
10
,
repositories_synced_count:
5
,
repositories_failed_count:
0
)
expect
(
subject
[
:repositories_synced_in_percentage
]).
to
eq
'50.00%'
end
end
describe
'#namespaces'
do
it
'returns empty array when full sync is active'
do
expect
(
subject
[
:namespaces
]).
to
be_empty
end
it
'returns array of namespace ids and paths for selective sync'
do
namespace
=
create
(
:namespace
)
geo_node_status
.
geo_node
.
namespaces
<<
namespace
expect
(
subject
[
:namespaces
]).
not_to
be_empty
expect
(
subject
[
:namespaces
]).
to
be_an
(
Array
)
expect
(
subject
[
:namespaces
].
first
[
:id
]).
to
eq
(
namespace
.
id
)
expect
(
subject
[
:namespaces
].
first
[
:path
]).
to
eq
(
namespace
.
path
)
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