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
1653a4a4
Commit
1653a4a4
authored
Mar 06, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Toon: Changes for 404 node status, support for refresh param
parent
b63a22c6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
1 deletion
+74
-1
ee/lib/api/geo_nodes.rb
ee/lib/api/geo_nodes.rb
+19
-0
ee/spec/requests/api/geo_nodes_spec.rb
ee/spec/requests/api/geo_nodes_spec.rb
+55
-1
No files found.
ee/lib/api/geo_nodes.rb
View file @
1653a4a4
...
...
@@ -66,6 +66,8 @@ module API
strong_memoize
(
:geo_node_status
)
do
if
geo_node
.
current?
GeoNodeStatus
.
current_node_status
elsif
to_boolean
(
declared_params
(
include_missing:
false
)[
:refresh
])
::
Geo
::
NodeStatusFetchService
.
new
.
call
(
geo_node
)
else
geo_node
.
status
end
...
...
@@ -93,6 +95,9 @@ module API
desc
'Get metrics for a single Geo node'
do
success
EE
::
API
::
Entities
::
GeoNodeStatus
end
params
do
optional
:refresh
,
type:
Boolean
,
desc:
'Attempt to fetch the latest status from the Geo node directly, ignoring the cache'
end
get
'status'
do
not_found!
(
'GeoNode'
)
unless
geo_node
...
...
@@ -145,6 +150,20 @@ module API
render_validation_error!
(
geo_node
)
end
end
# Delete an existing Geo node
#
# Example request:
# DELETE /geo_nodes/:id
desc
'Delete an existing Geo secondary node'
do
success
EE
::
API
::
Entities
::
GeoNode
end
delete
do
not_found!
(
'GeoNode'
)
unless
geo_node
geo_node
.
destroy!
status
204
end
end
end
end
...
...
ee/spec/requests/api/geo_nodes_spec.rb
View file @
1653a4a4
...
...
@@ -34,9 +34,11 @@ describe API::GeoNodes, :geo, api: true do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/geo_node'
,
dir:
'ee'
)
expect
(
json_response
[
'web_edit_url'
]).
to
end_with
(
"/admin/geo_nodes/
#{
primary
.
id
}
/edit"
)
links
=
json_response
[
'_links'
]
expect
(
links
[
'self'
]).
to
end_with
(
"/api/v4/geo_nodes/
#{
primary
.
id
}
"
)
expect
(
links
[
'status'
]).
to
end_with
(
"/api/v4/geo_nodes/
#{
primary
.
id
}
/status"
)
expect
(
links
[
'repair'
]).
to
end_with
(
"/api/v4/geo_nodes/
#{
primary
.
id
}
/repair"
)
end
...
...
@@ -99,6 +101,32 @@ describe API::GeoNodes, :geo, api: true do
expect
(
response
).
to
match_response_schema
(
'public_api/v4/geo_node_status'
,
dir:
'ee'
)
end
it
'fetches the real-time status with `refresh=true`'
do
stub_current_geo_node
(
primary
)
new_status
=
build
(
:geo_node_status
,
:healthy
,
geo_node:
secondary
,
attachments_count:
923
,
lfs_objects_count:
652
)
expect
(
GeoNode
).
to
receive
(
:find
).
and_return
(
secondary
)
expect_any_instance_of
(
Geo
::
NodeStatusFetchService
).
to
receive
(
:call
).
and_return
(
new_status
)
get
api
(
"/geo_nodes/
#{
secondary
.
id
}
/status"
,
admin
),
refresh:
true
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/geo_node_status'
,
dir:
'ee'
)
expect
(
json_response
[
'attachments_count'
]).
to
eq
(
923
)
expect
(
json_response
[
'lfs_objects_count'
]).
to
eq
(
652
)
end
it
'returns 404 when no Geo Node status is not found'
do
stub_current_geo_node
(
primary
)
secondary_status
.
destroy!
expect
(
GeoNode
).
to
receive
(
:find
).
and_return
(
secondary
)
get
api
(
"/geo_nodes/
#{
secondary
.
id
}
/status"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
it_behaves_like
'404 response'
do
let
(
:request
)
{
get
api
(
"/geo_nodes/
#{
unexisting_node_id
}
/status"
,
admin
)
}
end
...
...
@@ -149,7 +177,7 @@ describe API::GeoNodes, :geo, api: true do
describe
'PUT /geo_nodes/:id'
do
it_behaves_like
'404 response'
do
let
(
:request
)
{
get
api
(
"/geo_nodes/
#{
unexisting_node_id
}
/status"
,
admin
)
}
let
(
:request
)
{
put
api
(
"/geo_nodes/
#{
unexisting_node_id
}
"
,
admin
),
{}
}
end
it
'denies access if not admin'
do
...
...
@@ -174,6 +202,32 @@ describe API::GeoNodes, :geo, api: true do
end
end
describe
'DELETE /geo_nodes/:id'
do
it_behaves_like
'404 response'
do
let
(
:request
)
{
delete
api
(
"/geo_nodes/
#{
unexisting_node_id
}
"
,
admin
)
}
end
it
'denies access if not admin'
do
delete
api
(
"/geo_nodes/
#{
secondary
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
it
'deletes the node'
do
delete
api
(
"/geo_nodes/
#{
secondary
.
id
}
"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
end
it
'returns 400 if Geo Node could not be deleted'
do
allow_any_instance_of
(
GeoNode
).
to
receive
(
:destroy!
).
and_raise
(
StandardError
,
'Something wrong'
)
delete
api
(
"/geo_nodes/
#{
secondary
.
id
}
"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
500
)
end
end
describe
'GET /geo_nodes/current/failures/:type'
do
it
'fetches the current node failures'
do
create
(
:geo_project_registry
,
:sync_failed
)
...
...
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