Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inventory-provider
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
dashboardv3
inventory-provider
Commits
f60ddb01
Commit
f60ddb01
authored
3 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
added /ping endpoint
parent
b3634bba
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/source/protocol.rst
+1
-8
1 addition, 8 deletions
docs/source/protocol.rst
inventory_provider/routes/default.py
+32
-0
32 additions, 0 deletions
inventory_provider/routes/default.py
test/test_general_routes.py
+12
-0
12 additions, 0 deletions
test/test_general_routes.py
with
45 additions
and
8 deletions
docs/source/protocol.rst
+
1
−
8
View file @
f60ddb01
...
@@ -17,14 +17,7 @@ and www.json.org for more details.
...
@@ -17,14 +17,7 @@ and www.json.org for more details.
.. contents:: :local:
.. contents:: :local:
/version
.. automodule:: inventory_provider.routes.default
-------------
.. autofunction:: inventory_provider.routes.default.version
API modules
--------------
.. automodule:: inventory_provider.routes.classifier
.. automodule:: inventory_provider.routes.classifier
...
...
This diff is collapsed.
Click to expand it.
inventory_provider/routes/default.py
+
32
−
0
View file @
f60ddb01
"""
Health-related Endpoints
=========================
These endpoints are intended for checking the status of the service.
.. contents:: :local:
/version
---------------------
.. autofunction:: inventory_provider.routes.default.version
/ping
-----------------------------
.. autofunction:: inventory_provider.routes.default.ping
"""
import
pkg_resources
import
pkg_resources
from
flask
import
Blueprint
,
jsonify
,
current_app
from
flask
import
Blueprint
,
jsonify
,
current_app
...
@@ -72,3 +92,15 @@ def version():
...
@@ -72,3 +92,15 @@ def version():
if
latch
:
if
latch
:
version_params
[
'
latch
'
]
=
latch
version_params
[
'
latch
'
]
=
latch
return
jsonify
(
version_params
)
return
jsonify
(
version_params
)
@routes.route
(
'
/ping
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
def
ping
():
"""
This method can be used to verify the web service is alive
and processing requests. This endpoint is used by haproxy
for backend http checks.
There
'
s no response payload, only 204 (empty content) will be returned.
"""
return
''
,
204
This diff is collapsed.
Click to expand it.
test/test_general_routes.py
+
12
−
0
View file @
f60ddb01
...
@@ -63,3 +63,15 @@ def test_load_json_docs(data_config, mocked_redis):
...
@@ -63,3 +63,15 @@ def test_load_json_docs(data_config, mocked_redis):
for
ifc
in
common
.
load_json_docs
(
for
ifc
in
common
.
load_json_docs
(
data_config
,
'
netconf-interfaces:*
'
,
num_threads
=
20
):
data_config
,
'
netconf-interfaces:*
'
,
num_threads
=
20
):
jsonschema
.
validate
(
ifc
,
INTERFACE_SCHEMA
)
jsonschema
.
validate
(
ifc
,
INTERFACE_SCHEMA
)
def
test_ping_post
(
client
):
rv
=
client
.
post
(
'
ping
'
)
assert
rv
.
status_code
==
204
assert
len
(
rv
.
data
)
==
0
def
test_ping_get
(
client
):
rv
=
client
.
get
(
'
ping
'
)
assert
rv
.
status_code
==
204
assert
len
(
rv
.
data
)
==
0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment