X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Ftest%2FOpenStack%2Fintegration%2Ftest_alarm_integration.py;h=fbec56c74e9e59db727d88fd3b157d6f4846a2cc;hb=93699898c51364cde193d8d441f4aed45670e7bf;hp=278c8c209bf54900069ab7d6c326ff3097d70580;hpb=e80db311a29dc8562dc84ae3336af167bac2ec5b;p=osm%2FMON.git diff --git a/osm_mon/test/OpenStack/integration/test_alarm_integration.py b/osm_mon/test/OpenStack/integration/test_alarm_integration.py index 278c8c2..fbec56c 100644 --- a/osm_mon/test/OpenStack/integration/test_alarm_integration.py +++ b/osm_mon/test/OpenStack/integration/test_alarm_integration.py @@ -33,9 +33,8 @@ from kafka.errors import KafkaError from osm_mon.core.auth import AuthManager from osm_mon.core.database import DatabaseManager, VimCredentials -from osm_mon.core.message_bus.producer import KafkaProducer as Producer from osm_mon.plugins.OpenStack import response -from osm_mon.plugins.OpenStack.Aodh import alarming +from osm_mon.plugins.OpenStack.Aodh import alarm_handler from osm_mon.plugins.OpenStack.common import Common log = logging.getLogger(__name__) @@ -44,7 +43,6 @@ mock_creds = VimCredentials() mock_creds.config = '{}' -@mock.patch.object(Producer, "publish_alarm_request", mock.Mock()) @mock.patch.object(DatabaseManager, "save_alarm", mock.Mock()) @mock.patch.object(Common, "get_auth_token", mock.Mock()) @mock.patch.object(Common, "get_endpoint", mock.Mock()) @@ -64,7 +62,7 @@ class AlarmIntegrationTest(unittest.TestCase): except KafkaError: self.skipTest('Kafka server not present.') # Set up common and alarming class instances - self.alarms = alarming.Alarming() + self.alarms = alarm_handler.OpenstackAlarmHandler() self.openstack_auth = Common() def tearDown(self): @@ -73,8 +71,8 @@ class AlarmIntegrationTest(unittest.TestCase): @mock.patch.object(Common, "perform_request") @mock.patch.object(AuthManager, 'get_credentials') - @mock.patch.object(alarming.Alarming, "update_alarm") - @mock.patch.object(response.OpenStack_Response, "generate_response") + @mock.patch.object(alarm_handler.OpenstackAlarmHandler, "update_alarm") + @mock.patch.object(response.OpenStackResponseBuilder, "generate_response") def test_update_alarm_req(self, resp, update_alarm, get_creds, perf_req): """Test Aodh update alarm request message from KafkaProducer.""" # Set-up message, producer and consumer for tests @@ -93,7 +91,7 @@ class AlarmIntegrationTest(unittest.TestCase): if message.key == "update_alarm_request": # Mock a valid alarm update update_alarm.return_value = "alarm_id" - self.alarms.alarming(message, 'test_id') + self.alarms.handle_message(message, 'test_id') # A response message is generated and sent via MON's producer resp.assert_called_with( @@ -105,8 +103,8 @@ class AlarmIntegrationTest(unittest.TestCase): @mock.patch.object(Common, "perform_request") @mock.patch.object(AuthManager, 'get_credentials') - @mock.patch.object(alarming.Alarming, "configure_alarm") - @mock.patch.object(response.OpenStack_Response, "generate_response") + @mock.patch.object(alarm_handler.OpenstackAlarmHandler, "configure_alarm") + @mock.patch.object(response.OpenStackResponseBuilder, "generate_response") def test_create_alarm_req(self, resp, config_alarm, get_creds, perf_req): """Test Aodh create alarm request message from KafkaProducer.""" # Set-up message, producer and consumer for tests @@ -131,7 +129,7 @@ class AlarmIntegrationTest(unittest.TestCase): if message.key == "create_alarm_request": # Mock a valid alarm creation config_alarm.return_value = "alarm_id" - self.alarms.alarming(message, 'test_id') + self.alarms.handle_message(message, 'test_id') # A response message is generated and sent via MON's produce resp.assert_called_with( @@ -143,8 +141,8 @@ class AlarmIntegrationTest(unittest.TestCase): @mock.patch.object(Common, "perform_request") @mock.patch.object(AuthManager, 'get_credentials') - @mock.patch.object(alarming.Alarming, "list_alarms") - @mock.patch.object(response.OpenStack_Response, "generate_response") + @mock.patch.object(alarm_handler.OpenstackAlarmHandler, "list_alarms") + @mock.patch.object(response.OpenStackResponseBuilder, "generate_response") def test_list_alarm_req(self, resp, list_alarm, get_creds, perf_req): """Test Aodh list alarm request message from KafkaProducer.""" # Set-up message, producer and consumer for tests @@ -162,7 +160,7 @@ class AlarmIntegrationTest(unittest.TestCase): if message.key == "list_alarm_request": # Mock an empty list generated by the request list_alarm.return_value = [] - self.alarms.alarming(message, 'test_id') + self.alarms.handle_message(message, 'test_id') # Response message is generated resp.assert_called_with( @@ -174,8 +172,8 @@ class AlarmIntegrationTest(unittest.TestCase): @mock.patch.object(Common, "perform_request") @mock.patch.object(AuthManager, 'get_credentials') - @mock.patch.object(alarming.Alarming, "delete_alarm") - @mock.patch.object(response.OpenStack_Response, "generate_response") + @mock.patch.object(alarm_handler.OpenstackAlarmHandler, "delete_alarm") + @mock.patch.object(response.OpenStackResponseBuilder, "generate_response") def test_delete_alarm_req(self, resp, del_alarm, get_creds, perf_req): """Test Aodh delete alarm request message from KafkaProducer.""" # Set-up message, producer and consumer for tests @@ -191,7 +189,7 @@ class AlarmIntegrationTest(unittest.TestCase): for message in self.req_consumer: if message.key == "delete_alarm_request": - self.alarms.alarming(message, 'test_id') + self.alarms.handle_message(message, 'test_id') # Response message is generated and sent by MON's producer resp.assert_called_with( @@ -202,7 +200,7 @@ class AlarmIntegrationTest(unittest.TestCase): self.fail("No message received in consumer") @mock.patch.object(AuthManager, 'get_credentials') - @mock.patch.object(alarming.Alarming, "update_alarm_state") + @mock.patch.object(alarm_handler.OpenstackAlarmHandler, "update_alarm_state") def test_ack_alarm_req(self, ack_alarm, get_creds): """Test Aodh acknowledge alarm request message from KafkaProducer.""" # Set-up message, producer and consumer for tests @@ -216,7 +214,7 @@ class AlarmIntegrationTest(unittest.TestCase): for message in self.req_consumer: if message.key == "acknowledge_alarm": - self.alarms.alarming(message, 'test_id') + self.alarms.handle_message(message, 'test_id') ack_alarm.assert_called_with(mock.ANY, mock.ANY, 'alarm_id', True) return