Test case updated with alarm history api
Test case Updated This is to check the functionality of alarm history api: Fetch the history of specific alarm ID then verify that create and update operation are reflected in result. Change-Id: Ied3b7596e1c3ec9a45b1cb07299ffb4cdd0cf390
This commit is contained in:
parent
882db60cfc
commit
c3328e4a1c
@ -56,18 +56,24 @@ class TelemetryAlarmingAPITestJSON(base.BaseTelemetryTest):
|
|||||||
'comparison_operator': 'eq',
|
'comparison_operator': 'eq',
|
||||||
'threshold': 70.0,
|
'threshold': 70.0,
|
||||||
'period': 60}
|
'period': 60}
|
||||||
alarm_name = data_utils.rand_name('telemetry-alarm-update')
|
alarm_name_updated = data_utils.rand_name('telemetry-alarm-update')
|
||||||
body = self.telemetry_client.update_alarm(
|
body = self.telemetry_client.update_alarm(
|
||||||
alarm_id,
|
alarm_id,
|
||||||
threshold_rule=new_rule,
|
threshold_rule=new_rule,
|
||||||
name=alarm_name,
|
name=alarm_name_updated,
|
||||||
type='threshold')
|
type='threshold')
|
||||||
self.assertEqual(alarm_name, body['name'])
|
self.assertEqual(alarm_name_updated, body['name'])
|
||||||
self.assertDictContainsSubset(new_rule, body['threshold_rule'])
|
self.assertDictContainsSubset(new_rule, body['threshold_rule'])
|
||||||
# Get and verify details of an alarm after update
|
# Get and verify details of an alarm after update
|
||||||
body = self.telemetry_client.show_alarm(alarm_id)
|
body = self.telemetry_client.show_alarm(alarm_id)
|
||||||
self.assertEqual(alarm_name, body['name'])
|
self.assertEqual(alarm_name_updated, body['name'])
|
||||||
self.assertDictContainsSubset(new_rule, body['threshold_rule'])
|
self.assertDictContainsSubset(new_rule, body['threshold_rule'])
|
||||||
|
# Get history for the alarm and verify the same
|
||||||
|
body = self.telemetry_client.show_alarm_history(alarm_id)
|
||||||
|
self.assertEqual("rule change", body[0]['type'])
|
||||||
|
self.assertIn(alarm_name_updated, body[0]['detail'])
|
||||||
|
self.assertEqual("creation", body[1]['type'])
|
||||||
|
self.assertIn(alarm_name, body[1]['detail'])
|
||||||
# Delete alarm and verify if deleted
|
# Delete alarm and verify if deleted
|
||||||
self.telemetry_client.delete_alarm(alarm_id)
|
self.telemetry_client.delete_alarm(alarm_id)
|
||||||
self.assertRaises(lib_exc.NotFound,
|
self.assertRaises(lib_exc.NotFound,
|
||||||
|
@ -140,3 +140,10 @@ class TelemetryClient(service_client.ServiceClient):
|
|||||||
self.expected_success(200, resp.status)
|
self.expected_success(200, resp.status)
|
||||||
body = self.deserialize(body)
|
body = self.deserialize(body)
|
||||||
return service_client.ResponseBodyData(resp, body)
|
return service_client.ResponseBodyData(resp, body)
|
||||||
|
|
||||||
|
def show_alarm_history(self, alarm_id):
|
||||||
|
uri = "%s/alarms/%s/history" % (self.uri_prefix, alarm_id)
|
||||||
|
resp, body = self.get(uri)
|
||||||
|
self.expected_success(200, resp.status)
|
||||||
|
body = self.deserialize(body)
|
||||||
|
return service_client.ResponseBodyList(resp, body)
|
||||||
|
Loading…
Reference in New Issue
Block a user