Add failied project information in health API response
Change-Id: I66e2fd940b5dffb7c820afa77966ac918c99a028
This commit is contained in:
parent
efc880799b
commit
a99bb30894
|
@ -62,9 +62,13 @@ def get_health():
|
|||
'msg': 'Tenant usage successfully collected and up-to-date.'
|
||||
}
|
||||
else:
|
||||
failed_projects = [{"name": p.name, "id": p.id} for p in
|
||||
failed_projects]
|
||||
|
||||
result['usage_collection'] = {
|
||||
'status': Status.FAIL.name,
|
||||
'msg': 'Failed to collect usage for %s projects.' % failed_count
|
||||
'msg': 'Failed to collect usage for %s projects.' % failed_count,
|
||||
'failed_projects': failed_projects,
|
||||
}
|
||||
|
||||
try:
|
||||
|
|
|
@ -87,10 +87,19 @@ class HealthTest(base.DistilWithDbTestCase):
|
|||
)
|
||||
|
||||
ret = health.get_health()
|
||||
projects = ret['usage_collection'].get('failed_projects')
|
||||
|
||||
self.assertIsNotNone(projects)
|
||||
self.assertEqual(2, len(projects))
|
||||
self.assertEqual('FAIL', ret['usage_collection'].get('status'))
|
||||
self.assertIn('2', ret['usage_collection'].get('msg'))
|
||||
|
||||
p_names = [p['name'] for p in projects]
|
||||
p_ids = [p['id'] for p in projects]
|
||||
|
||||
self.assertEqual(["project_1", "project_2"], p_names)
|
||||
self.assertEqual(["111", "222"], p_ids)
|
||||
|
||||
@mock.patch('odoorpc.ODOO')
|
||||
@mock.patch('distil.common.openstack.get_projects')
|
||||
def test_get_health_with_erp_backend_fail(self, mock_get_projects,
|
||||
|
|
Loading…
Reference in New Issue