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:
piyush110786 2015-09-14 11:14:58 +05:30
parent 882db60cfc
commit c3328e4a1c
2 changed files with 17 additions and 4 deletions

View File

@ -56,18 +56,24 @@ class TelemetryAlarmingAPITestJSON(base.BaseTelemetryTest):
'comparison_operator': 'eq',
'threshold': 70.0,
'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(
alarm_id,
threshold_rule=new_rule,
name=alarm_name,
name=alarm_name_updated,
type='threshold')
self.assertEqual(alarm_name, body['name'])
self.assertEqual(alarm_name_updated, body['name'])
self.assertDictContainsSubset(new_rule, body['threshold_rule'])
# Get and verify details of an alarm after update
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'])
# 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
self.telemetry_client.delete_alarm(alarm_id)
self.assertRaises(lib_exc.NotFound,

View File

@ -140,3 +140,10 @@ class TelemetryClient(service_client.ServiceClient):
self.expected_success(200, resp.status)
body = self.deserialize(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)