Skip to content
Snippets Groups Projects
Commit f60ddb01 authored by Erik Reid's avatar Erik Reid
Browse files

added /ping endpoint

parent b3634bba
Branches
Tags
No related merge requests found
...@@ -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
......
"""
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
...@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment