-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing Healthchecks support for #39
- Loading branch information
1 parent
75ced02
commit 561a1cc
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from amqpstorm.management.base import ManagementHandler | ||
|
||
|
||
|
||
class HealthChecks(ManagementHandler): | ||
def get(self, node=None): | ||
"""Run basic healthchecks against the current node, or against a given | ||
node. | ||
Example response: | ||
> {"status":"ok"} | ||
> {"status":"failed","reason":"string"} | ||
:param node: Node name | ||
:raises ApiError: Raises if the remote server encountered an error. | ||
:raises ApiConnectionError: Raises if there was a connectivity issue. | ||
:rtype: dict | ||
""" | ||
if not node: |
26 changes: 26 additions & 0 deletions
26
amqpstorm/tests/functional/management/healthcheck_tests.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from amqpstorm.management import ManagementApi | ||
from amqpstorm.tests import HTTP_URL | ||
from amqpstorm.tests import PASSWORD | ||
from amqpstorm.tests import USERNAME | ||
from amqpstorm.tests.utility import TestFunctionalFramework | ||
from amqpstorm.tests.utility import setup | ||
|
||
|
||
class ApiHealthchecksFunctionalTests(TestFunctionalFramework): | ||
@setup() | ||
def test_healthtests_get(self): | ||
api = ManagementApi(HTTP_URL, USERNAME, PASSWORD) | ||
|
||
result = api.healthchecks.get() | ||
self.assertIsInstance(result, dict) | ||
self.assertEqual(result['status'], 'ok') | ||
|
||
@setup() | ||
def test_healthtests_get_with_node_name(self): | ||
api = ManagementApi(HTTP_URL, USERNAME, PASSWORD) | ||
|
||
node_name = api.overview()['contexts'][0]['node'] | ||
|
||
result = api.healthchecks.get(node_name) | ||
self.assertIsInstance(result, dict) | ||
self.assertEqual(result['status'], 'ok') |