diff --git a/Changelog.md b/Changelog.md index 1087e9a906a2d68f0900843918a521d676336cd0..31e6c80a0033635261027312ca20fc96147da482 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. +## [0.84] - 2022-03-07 +- DBOARD3-536: added /ping endpoint + ## [0.83] - 2022-03-02 - DBOARD3-533: allow netconf configuration 'inactive' attribute (e.g. rt1.bra.sk) - POL1-565: return non-monitored services in /msr/services diff --git a/docs/source/protocol.rst b/docs/source/protocol.rst index ccbb59d5edff3d86b11f491d59a10d6b5e7f8be0..6a6366f78a144572c490237b070a05a59943d6b7 100644 --- a/docs/source/protocol.rst +++ b/docs/source/protocol.rst @@ -17,14 +17,7 @@ and www.json.org for more details. .. contents:: :local: -/version -------------- - -.. autofunction:: inventory_provider.routes.default.version - - -API modules --------------- +.. automodule:: inventory_provider.routes.default .. automodule:: inventory_provider.routes.classifier diff --git a/inventory_provider/routes/default.py b/inventory_provider/routes/default.py index 13b8fb1231af358009227d84ae041b85b63b5806..ea82dd88bdccf786bbd5e514e2c3038c4b7591ee 100644 --- a/inventory_provider/routes/default.py +++ b/inventory_provider/routes/default.py @@ -1,3 +1,23 @@ +""" +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 from flask import Blueprint, jsonify, current_app @@ -72,3 +92,15 @@ def version(): if latch: version_params['latch'] = latch 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 diff --git a/setup.py b/setup.py index 34abd94d96d02f779570b7f7c43fed0f85aafc29..a610e4c946116414e32ea55acef78d62f92ce85e 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='inventory-provider', - version="0.83", + version="0.84", author='GEANT', author_email='swd@geant.org', description='Dashboard inventory provider', diff --git a/test/test_general_routes.py b/test/test_general_routes.py index 8bc82db71c96426f68d502f8fe4dac4e2414cd40..40efb46d4e907a18b36c46950d2c06f046230d70 100644 --- a/test/test_general_routes.py +++ b/test/test_general_routes.py @@ -63,3 +63,15 @@ def test_load_json_docs(data_config, mocked_redis): for ifc in common.load_json_docs( data_config, 'netconf-interfaces:*', num_threads=20): 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