X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Ftest%2FOpenStack%2Fintegration%2Ftest_metric_integration.py;h=45a34d304a71697f262ca643ded089765be3472a;hb=a2c06b12bae40e48ab989e0c75e5a3ad6fabe916;hp=c130973260f636571f54edacead3f0e2d2774123;hpb=b85fc8cdf840080b10d01c33b4a57a2a39bcc0f1;p=osm%2FMON.git diff --git a/osm_mon/test/OpenStack/integration/test_metric_integration.py b/osm_mon/test/OpenStack/integration/test_metric_integration.py index c130973..45a34d3 100644 --- a/osm_mon/test/OpenStack/integration/test_metric_integration.py +++ b/osm_mon/test/OpenStack/integration/test_metric_integration.py @@ -73,23 +73,18 @@ class MetricIntegrationTest(unittest.TestCase): def test_create_metric_req(self, resp, create_resp, config_metric): """Test Gnocchi create metric request message from producer.""" # Set-up message, producer and consumer for tests - payload = {"vim_type": "OpenSTACK", - "vim_uuid": "1", - "correlation_id": 123, - "metric_create": - {"metric_name": "cpu_utilization", - "resource_uuid": "resource_id"}} + payload = {"metric_create_request": {"correlation_id": 123, + "metric_name": "cpu_utilization", + "resource_uuid": "resource_id"}} self.producer.send('metric_request', key="create_metric_request", value=json.dumps(payload)) for message in self.req_consumer: - # Check the vim desired by the message - vim_type = json.loads(message.value)["vim_type"].lower() - if vim_type == "openstack": + if message.key == "create_metric_request": # A valid metric is created config_metric.return_value = "metric_id", "resource_id", True - self.metric_req.metric_calls(message) + self.metric_req.metric_calls(message, 'test_id') # A response message is generated and sent by MON's producer resp.assert_called_with( @@ -122,7 +117,7 @@ class MetricIntegrationTest(unittest.TestCase): if message.key == "delete_metric_request": # Metric has been deleted del_metric.return_value = True - self.metric_req.metric_calls(message) + self.metric_req.metric_calls(message, 'test_id') # A response message is generated and sent by MON's producer resp.assert_called_with( @@ -157,7 +152,7 @@ class MetricIntegrationTest(unittest.TestCase): if message.key == "read_metric_data_request": # Mock empty lists generated by the request message read_data.return_value = [], [] - self.metric_req.metric_calls(message) + self.metric_req.metric_calls(message, 'test_id') # A response message is generated and sent by MON's producer resp.assert_called_with( @@ -191,7 +186,7 @@ class MetricIntegrationTest(unittest.TestCase): if message.key == "list_metric_request": # Mock an empty list generated by the request list_metrics.return_value = [] - self.metric_req.metric_calls(message) + self.metric_req.metric_calls(message, 'test_id') # A response message is generated and sent by MON's producer resp.assert_called_with( @@ -210,12 +205,9 @@ class MetricIntegrationTest(unittest.TestCase): def test_update_metrics_req(self, resp, update_resp, get_id): """Test Gnocchi update metric request message from KafkaProducer.""" # Set-up message, producer and consumer for tests - payload = {"vim_type": "OpenSTACK", - "vim_uuid": "test_id", - "correlation_id": 123, - "metric_create": - {"metric_name": "my_metric", - "resource_uuid": "resource_id", }} + payload = {"metric_create_request": {"metric_name": "my_metric", + "correlation_id": 123, + "resource_uuid": "resource_id", }} self.producer.send('metric_request', key="update_metric_request", value=json.dumps(payload)) @@ -225,7 +217,7 @@ class MetricIntegrationTest(unittest.TestCase): if message.key == "update_metric_request": # Gnocchi doesn't support metric updates get_id.return_value = "metric_id" - self.metric_req.metric_calls(message) + self.metric_req.metric_calls(message, 'test_id') # Response message is generated and sent via MON's producer # No metric update has taken place