diff --git a/src/service/clmcservice/graphapi/tests.py b/src/service/clmcservice/graphapi/tests.py index 3d83f411d9be69eee8ae9eb7d873e92e4434af14..02e26c3ec611c5bb2766414b6cb315632f83a40d 100644 --- a/src/service/clmcservice/graphapi/tests.py +++ b/src/service/clmcservice/graphapi/tests.py @@ -388,7 +388,7 @@ class TestGraphAPI(object): assert error_raised, "HTTP Not Found error must be thrown for a non existing endpoint" # go through the set of input/output (expected) parameters and assert actual results match with expected ones - for dc, endpoint, forward_latencies, reverse_latencies, response_time, request_size, response_size, rtt, global_tags in ( + for startpoint, endpoint, forward_latencies, reverse_latencies, response_time, request_size, response_size, rtt, global_tags in ( ("DC6", "nginx_1_ep2", [], [], 22.2, 35600, 6420, 22.2, {"flame_location": "DC6", "flame_sfe": "nginx_1_ep2", "flame_server": "DC6", "flame_sfc": "test_sfc", "flame_sfci": "test_sfc_premium", "flame_sfp": "nginx", "flame_sf": "nginx_1"}), ("127.0.0.6", "nginx_1_ep2", [0], [0], 22.2, 35600, 6420, 22.2, {"flame_location": "DC6", "flame_sfe": "nginx_1_ep2", "flame_server": "DC6", "flame_sfc": "test_sfc", "flame_sfci": "test_sfc_premium", "flame_sfp": "nginx", "flame_sf": "nginx_1"}), ("ue6", "nginx_1_ep2", [0, 0], [0, 0], 22.2, 35600, 6420, 22.2, {"flame_location": "DC6", "flame_sfe": "nginx_1_ep2", "flame_server": "DC6", "flame_sfc": "test_sfc", "flame_sfci": "test_sfc_premium", "flame_sfp": "nginx", "flame_sf": "nginx_1"}), @@ -401,12 +401,12 @@ class TestGraphAPI(object): request = testing.DummyRequest() request.matchdict["graph_id"] = request_id request.params["endpoint"] = endpoint - request.params["startpoint"] = dc + request.params["startpoint"] = startpoint response = GraphAPI(request).run_rtt_query() # approximation is used to avoid long float numbers retrieved from influx, the test case ensures the results are different enough so that approximation of +-1 is good enough for testing assert response.pop("round_trip_time") == pytest.approx(rtt, 1), "Incorrect RTT response" assert response == {"forward_latencies": forward_latencies, "reverse_latencies": reverse_latencies, "total_forward_latency": sum(forward_latencies), "total_reverse_latency": sum(reverse_latencies), - "bandwidth": 104857600, "response_time": response_time, "global_tags": global_tags, + "bandwidth": 104857600, "response_time": response_time, "local_tags": {"traffic_source": startpoint}, "global_tags": global_tags, "request_size": request_size, "response_size": response_size}, "Incorrect RTT response" # send a new request for a new service function chain to create a second subgraph to test @@ -432,7 +432,7 @@ class TestGraphAPI(object): request_id = graph_subresponse["uuid"] # go through the set of input/output (expected) parameters and assert actual results match with expected ones - for dc, endpoint, forward_latencies, reverse_latencies, response_time, request_size, response_size, rtt, global_tags in ( + for startpoint, endpoint, forward_latencies, reverse_latencies, response_time, request_size, response_size, rtt, global_tags in ( ("DC5", "apache_1_ep1", [], [], 17.6, 1480, 7860, 17.6, {"flame_location": "DC5", "flame_sfe": "apache_1_ep1", "flame_server": "DC5", "flame_sfc": "test_sfc", "flame_sfci": "test_sfc_non_premium", "flame_sfp": "apache", "flame_sf": "apache_1"}), ("127.0.0.5", "apache_1_ep1", [0], [0], 17.6, 1480, 7860, 17.6, {"flame_location": "DC5", "flame_sfe": "apache_1_ep1", "flame_server": "DC5", "flame_sfc": "test_sfc", "flame_sfci": "test_sfc_non_premium", "flame_sfp": "apache", "flame_sf": "apache_1"}), ("DC5", "minio_2_ep1", [], [], 7, 2998, 3610, 7, {"flame_location": "DC5", "flame_sfe": "minio_2_ep1", "flame_server": "DC5", "flame_sfc": "test_sfc", "flame_sfci": "test_sfc_non_premium", "flame_sfp": "minio", "flame_sf": "minio_2"}), @@ -447,14 +447,14 @@ class TestGraphAPI(object): request = testing.DummyRequest() request.matchdict["graph_id"] = request_id request.params["endpoint"] = endpoint - request.params["startpoint"] = dc + request.params["startpoint"] = startpoint response = GraphAPI(request).run_rtt_query() # approximation is used to avoid long float numbers retrieved from influx, the test case ensures the results are different enough so that approximation of +-1 is good enough for testing assert response.pop("request_size") == pytest.approx(request_size, 1), "Incorrect RTT response" assert response.pop("response_size") == pytest.approx(response_size, 1), "Incorrect RTT response" assert response.pop("round_trip_time") == pytest.approx(rtt, 1), "Incorrect RTT response" assert response == {"forward_latencies": forward_latencies, "reverse_latencies": reverse_latencies, "total_forward_latency": sum(forward_latencies), "total_reverse_latency": sum(reverse_latencies), - "bandwidth": 104857600, "response_time": response_time, "global_tags": global_tags}, "Incorrect RTT response" + "bandwidth": 104857600, "response_time": response_time, "local_tags": {"traffic_source": startpoint}, "global_tags": global_tags}, "Incorrect RTT response" def test_delete_network_graph(self): """ diff --git a/src/service/clmcservice/graphapi/views.py b/src/service/clmcservice/graphapi/views.py index 8cde0757540a9f04a07cdbdbbd9c1273eaa0978b..4abedc4075ff580c1373ec8f513ce49ac1eaa357 100644 --- a/src/service/clmcservice/graphapi/views.py +++ b/src/service/clmcservice/graphapi/views.py @@ -167,6 +167,7 @@ class GraphAPI(object): result["global_tags"] = {"flame_sfe": endpoint_node["name"], "flame_server": hosted_by_node["name"], "flame_location": hosted_by_node["name"], "flame_sfc": reference_node["sfc"], "flame_sfci": reference_node["sfci"], "flame_sfp": sf_package_node["name"], "flame_sf": sf_node["name"]} + result["local_tags"] = {"traffic_source": startpoint_node_label} # calculate the Round-Trip-Time total_forward_latency = sum(result["forward_latencies"])