Merge "Fix API reference for list service statuses"

This commit is contained in:
Zuul 2022-02-18 02:49:58 +00:00 committed by Gerrit Code Review
commit 99fe04953f
5 changed files with 52 additions and 3 deletions

View File

@ -10,7 +10,7 @@ using HTTP.
List Statuses
=============
.. rest_method:: GET /v2/service_status
.. rest_method:: GET /v2/service_statuses
List all Services and statuses.

View File

@ -2,7 +2,7 @@
"service_statuses": [
{
"links": {
"self": "http://127.0.0.1:9001/v2/service_status/af91edb5-ede8-453f-af13-feabdd088f9c"
"self": "http://127.0.0.1:9001/v2/service_statuses/af91edb5-ede8-453f-af13-feabdd088f9c"
},
"hostname": "dns-2.example.com.",
"status": "UP",
@ -15,6 +15,6 @@
}
],
"links": {
"self": "http://127.0.0.1:9001/v2/service_status"
"self": "http://127.0.0.1:9001/v2/service_statuses"
}
}

View File

@ -58,6 +58,13 @@ class RootController(object):
errors = errors.ErrorsController()
pools = pools.PoolsController()
service_statuses = service_status.ServiceStatusController()
# This is a compatibility workaround for a mistake published in the
# Designate API reference that listed the URL path as /v2/service_status
# instead of /v2/service_statuses as it was implemented.
# https://bugs.launchpad.net/designate/+bug/1919183
service_status = service_statuses
tsigkeys = tsigkeys.TsigKeysController()
recordsets = recordsets.RecordSetsViewController()
quotas = quotas.QuotasController()

View File

@ -46,6 +46,42 @@ class ApiV2ServiceStatusTest(ApiV2TestCase):
self._assert_paging(data, '/service_statuses', key='service_statuses')
def test_legacy_list_service_status(self):
"""Test the legacy list service status path.
Historically the Designate API reference showed the list
service status URL path as /v2/service_status where the actual
path was /v2/service_statuses.
https://bugs.launchpad.net/designate/+bug/1919183
A compatibility workaround was added as this was a published
API reference. This test covers that alternate URL path.
"""
# Set the policy file as this is an admin-only API
self.policy({'find_service_statuses': '@'})
response = self.client.get('/service_status/')
# Check the headers are what we expect
self.assertEqual(200, response.status_int)
self.assertEqual('application/json', response.content_type)
# Check the body structure is what we expect
self.assertIn('service_statuses', response.json)
self.assertIn('links', response.json)
self.assertIn('self', response.json['links'])
# Test with 0 service_statuses
# Seeing that Central is started there will be 1 here already..
self.assertEqual(0, len(response.json['service_statuses']))
data = [self.update_service_status(
hostname="foo%s" % i, service_name="bar") for i in range(0, 10)]
self._assert_paging(data, '/service_status', key='service_statuses')
def test_get_service_status(self):
service_status = self.update_service_status(fixture=0)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixed an issue with the API reference using the wrong path for list
service statuses. In addition a compatibility workaround was added
for the incorrect /v2/service_status path.