def test_fetch_alarms_for_unknown_instance(self): instance_id = 'i-123456' self.create_alarm(dimensions={'InstanceId': [instance_id]}) cw_conn = boto.connect_cloudwatch('us-east') instance_alarms = Alarm.get_alarms_for_resource( 'unlikely-id', dimension_key='InstanceId', cw_conn=cw_conn) self.assertEqual(len(instance_alarms), 0)
def test_fetch_alarms_for_unknown_instance(self): instance_id = 'i-123456' cw_conn, alarm_created = self.create_alarm( dimensions={'InstanceId': [instance_id]}) instance_alarms = Alarm.get_alarms_for_resource( 'unlikely-id', dimension_key='InstanceId', cw_conn=cw_conn) self.assertEqual(len(instance_alarms), 0)
def test_fetch_resource_alarm_status_insufficient(self): """Status should display 'Insufficient data' when at least one is insufficient and none are in alarm state""" item_id = 'i-123456' alarms = [ self.make_alarm(item_id, state_value='OK'), self.make_alarm(item_id, state_value='INSUFFICIENT_DATA'), ] alarm_status = Alarm.get_resource_alarm_status(item_id, alarms) self.assertEqual(alarm_status, 'Insufficient data')
def test_fetch_resource_alarm_status_ok(self): """Status should display OK if resource has alarms and none are insufficient or in alarm state""" item_id = 'i-123456' alarms = [ self.make_alarm(item_id, state_value='OK'), self.make_alarm(item_id, state_value='OK') ] alarm_status = Alarm.get_resource_alarm_status(item_id, alarms) self.assertEqual(alarm_status, 'OK')
def test_fetch_alarms_for_load_balancer(self): elb_name = 'test_elb' alarm_kwargs = dict( metric='RequestCount', namespace='AWS/ELB', statistic='Sum', unit=None, dimensions={'LoadBalancerName': elb_name}, ) cw_conn, alarm_created = self.create_alarm(**alarm_kwargs) elb_alarms = Alarm.get_alarms_for_resource(elb_name, dimension_key='LoadBalancerName', cw_conn=cw_conn) self.assertEqual(len(elb_alarms), 1)
def test_fetch_resource_alarm_status_alarm(self): """Status should display 'Alarm' when at least one is in alarm state""" item_id = 'i-123456' alarms = [ self.make_alarm(item_id, state_value='OK'), self.make_alarm(item_id, state_value='INSUFFICIENT_DATA'), self.make_alarm(item_id, state_value='ALARM'), ] alarm_status = Alarm.get_resource_alarm_status(item_id, alarms) self.assertEqual(alarm_status, 'Alarm')
def test_fetch_alarms_for_load_balancer(self): elb_name = 'test_elb' alarm_kwargs = dict( metric='RequestCount', namespace='AWS/ELB', statistic='Sum', unit=None, dimensions={'LoadBalancerName': elb_name}, ) cw_conn, alarm_created = self.create_alarm(**alarm_kwargs) elb_alarms = Alarm.get_alarms_for_resource( elb_name, dimension_key='LoadBalancerName', cw_conn=cw_conn) self.assertEqual(len(elb_alarms), 1)
def test_fetch_alarms_for_unknown_instance(self): instance_id = 'i-123456' self.create_alarm(dimensions={'InstanceId': [instance_id]}) cw_conn = boto.connect_cloudwatch('us-east') instance_alarms = Alarm.get_alarms_for_resource('unlikely-id', dimension_key='InstanceId', cw_conn=cw_conn) self.assertEqual(len(instance_alarms), 0)
def test_fetch_alarms_for_unknown_instance(self): instance_id = 'i-123456' cw_conn, alarm_created = self.create_alarm(dimensions={'InstanceId': [instance_id]}) instance_alarms = Alarm.get_alarms_for_resource('unlikely-id', dimension_key='InstanceId', cw_conn=cw_conn) self.assertEqual(len(instance_alarms), 0)