diff --git a/src/service/clmcservice/graphapi/tests.py b/src/service/clmcservice/graphapi/tests.py index bf36e6668ab7c837cf1709c1a4a8d02f3c027d48..0aa112252de3cb6f51fec039d7e6449f0b13e04b 100644 --- a/src/service/clmcservice/graphapi/tests.py +++ b/src/service/clmcservice/graphapi/tests.py @@ -123,19 +123,6 @@ class TestGraphAPI(object): switch_nodes = set([node["name"] for node in graph_db.nodes.match("Switch")]) assert switch_nodes == set("127.0.0." + str(i) for i in range(1, 7)), "Switch nodes must have been created by the db_testing_data fixture" - # test with invalid body - missing 'from' and 'to' parameters - service_functions = dict(nginx={"measurement_name": "nginx", "response_time_field": "mean(avg_processing_time)", - "request_size_field": "mean(avg_request_size)", "response_size_field": "mean(avg_response_size)"}, - minio={"measurement_name": "minio_http", "response_time_field": "mean(total_processing_time)/mean(total_requests_count)", - "request_size_field": "mean(total_requests_size)/mean(total_requests_count)", "response_size_field": "mean(total_response_size)/mean(total_requests_count)"}, - apache={"measurement_name": "apache", "response_time_field": "mean(avg_processing_time)", - "request_size_field": "mean(avg_request_size)", "response_size_field": "mean(avg_response_size)"}) - body = dumps(dict(service_function_chain="sfc", service_function_chain_instance="sfc_1", service_functions=service_functions)) - request = testing.DummyRequest() - request.body = body.encode(request.charset) - with pytest.raises(HTTPBadRequest): - GraphAPI(request).build_temporal_graph() - # Create a valid build request and send it to the API endpoint uuid_mock.return_value = self.graph_1_test_id service_functions = dict(nginx={"measurement_name": "nginx", "response_time_field": "mean(avg_processing_time)", @@ -508,12 +495,27 @@ class TestGraphAPI(object): error_raised = True assert error_raised, error_msg - def test_execute_pipeline_graph(self): + @patch('clmcservice.graphapi.views.uuid4') + def test_execute_pipeline_graph(self, uuid_mock): """ Tests the functionality to start a pipeline script executing the graph API workflow - build, query, delete """ - assert False, "Not implemented" + uuid_mock.return_value = "monitor_test_uuid1" + service_functions = dict(nginx={"measurement_name": "nginx", "response_time_field": "mean(avg_processing_time)", + "request_size_field": "mean(avg_request_size)", "response_size_field": "mean(avg_response_size)"}, + minio={"measurement_name": "minio_http", "response_time_field": "mean(total_processing_time)/mean(total_requests_count)", + "request_size_field": "mean(total_requests_size)/mean(total_requests_count)", "response_size_field": "mean(total_response_size)/mean(total_requests_count)"}) + monitor_json_body = dict(service_function_chain="test_sfc", service_function_chain_instance="test_sfc_premium", service_functions=service_functions) + monitor_json_body["query_period"] = 30 + monitor_json_body["results_measurement_name"] = "graph_measurements" + body = dumps(monitor_json_body) + request = testing.DummyRequest() + request.body = body.encode(request.charset) + response = GraphAPI(request).execute_graph_pipeline() + assert response == {"uuid": uuid_mock.return_value, "database": "test_sfc"} + + assert False, "Implement tests for checking that an actual process is started." @staticmethod def check_exist_relationship(relationships_tuple, graph, uuid):