diff --git a/src/service/clmcservice/graphapi/tests.py b/src/service/clmcservice/graphapi/tests.py index c26aa2c1bf48291fac7b67a6d63bd7d50f95b2c7..33cdd5bb897ddea0c1db9e7141774c561a8a35de 100644 --- a/src/service/clmcservice/graphapi/tests.py +++ b/src/service/clmcservice/graphapi/tests.py @@ -147,10 +147,10 @@ class TestGraphAPI(object): graph_1_id = request_id # check that the appropriate nodes have been created + sfp_names = set([node["name"] for node in graph_db.nodes.match("ServiceFunctionPackage")]) + assert sfp_names == {"nginx", "minio"}, "The graph must contain 2 service function packages - nginx and minio" sf_names = set([node["name"] for node in graph_db.nodes.match("ServiceFunction")]) - assert sf_names == {"nginx", "minio"}, "The graph must contain 2 service functions - nginx and minio" - sf_i_names = set([node["name"] for node in graph_db.nodes.match("ServiceFunctionInstance")]) - assert sf_i_names == {"nginx_1", "minio_1"}, "The graph must contain 2 service function instances - nginx_1 and minio_1" + assert sf_names == {"nginx_1", "minio_1"}, "The graph must contain 2 service functions - nginx_1 and minio_1" endpoints = set([node["name"] for node in graph_db.nodes.match("Endpoint", uuid=request_id)]) assert endpoints == {"minio_1_ep1", "nginx_1_ep1", "nginx_1_ep2"}, "The graph must contain 3 endpoints - minio_1_ep1, nginx_1_ep1, nginx_1_ep2" sfci_names = set([node["name"] for node in graph_db.nodes.match("ServiceFunctionChainInstance")]) @@ -167,14 +167,14 @@ class TestGraphAPI(object): ("minio_1_ep1", "Endpoint", "DC4", "ComputeNode", "hostedBy"), ("nginx_1_ep1", "Endpoint", "DC4", "ComputeNode", "hostedBy"), ("nginx_1_ep2", "Endpoint", "DC6", "ComputeNode", "hostedBy"), - ("minio_1", "ServiceFunctionInstance", "minio_1_ep1", "Endpoint", "realisedBy"), - ("nginx_1", "ServiceFunctionInstance", "nginx_1_ep1", "Endpoint", "realisedBy"), - ("nginx_1", "ServiceFunctionInstance", "nginx_1_ep2", "Endpoint", "realisedBy"), - ("minio_1", "ServiceFunctionInstance", "minio", "ServiceFunction", "instanceOf"), - ("nginx_1", "ServiceFunctionInstance", "test_sfc_premium", "ServiceFunctionChainInstance", "utilizedBy"), - ("minio_1", "ServiceFunctionInstance", "test_sfc_premium", "ServiceFunctionChainInstance", "utilizedBy"), - ("nginx", "ServiceFunction", "test_sfc", "ServiceFunctionChain", "utilizedBy"), - ("minio", "ServiceFunction", "test_sfc", "ServiceFunctionChain", "utilizedBy"), + ("minio_1", "ServiceFunction", "minio_1_ep1", "Endpoint", "realisedBy"), + ("nginx_1", "ServiceFunction", "nginx_1_ep1", "Endpoint", "realisedBy"), + ("nginx_1", "ServiceFunction", "nginx_1_ep2", "Endpoint", "realisedBy"), + ("minio_1", "ServiceFunction", "minio", "ServiceFunctionPackage", "instanceOf"), + ("nginx_1", "ServiceFunction", "test_sfc_premium", "ServiceFunctionChainInstance", "utilizedBy"), + ("minio_1", "ServiceFunction", "test_sfc_premium", "ServiceFunctionChainInstance", "utilizedBy"), + ("nginx", "ServiceFunctionPackage", "test_sfc", "ServiceFunctionChain", "utilizedBy"), + ("minio", "ServiceFunctionPackage", "test_sfc", "ServiceFunctionChain", "utilizedBy"), ("test_sfc_premium", "ServiceFunctionChainInstance", "test_sfc", "ServiceFunctionChain", "instanceOf"), ), graph_db, request_id ) @@ -187,7 +187,7 @@ class TestGraphAPI(object): assert endpoint_node["request_size"] == pytest.approx(request_size, 1), "Wrong request size attribute of endpoint node" assert endpoint_node["response_size"] == pytest.approx(response_size, 1), "Wrong response size attribute of endpoint node" - # send a new request for a new service function chain and check the new subgraph has been created + # send a new request for a new service function chain instance and check the new subgraph has been created service_functions = dict(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)", @@ -206,10 +206,10 @@ class TestGraphAPI(object): graph_2_id = request_id # check the new nodes have been created - assert graph_db.nodes.match("ServiceFunction", name="apache").first() is not None, "Service function apache must have been added to the graph" + assert graph_db.nodes.match("ServiceFunctionPackage", name="apache").first() is not None, "Service function package apache must have been added to the graph" - for sf_i in ("apache_1", "minio_2"): - assert graph_db.nodes.match("ServiceFunctionInstance", name=sf_i).first() is not None, "Service function instance {0} must have been added to the graph".format(sf_i) + for sf in ("apache_1", "minio_2"): + assert graph_db.nodes.match("ServiceFunction", name=sf).first() is not None, "Service function {0} must have been added to the graph".format(sf) for ep in ("minio_2_ep1", "apache_1_ep1"): assert graph_db.nodes.match("Endpoint", name=ep, uuid=request_id).first() is not None, "Endpoint {0} must have been added to the graph".format(ep) @@ -225,14 +225,14 @@ class TestGraphAPI(object): ( ("minio_2_ep1", "Endpoint", "DC5", "ComputeNode", "hostedBy"), ("apache_1_ep1", "Endpoint", "DC5", "ComputeNode", "hostedBy"), - ("minio_2", "ServiceFunctionInstance", "minio_2_ep1", "Endpoint", "realisedBy"), - ("apache_1", "ServiceFunctionInstance", "apache_1_ep1", "Endpoint", "realisedBy"), - ("minio_2", "ServiceFunctionInstance", "minio", "ServiceFunction", "instanceOf"), - ("apache_1", "ServiceFunctionInstance", "apache", "ServiceFunction", "instanceOf"), - ("minio_2", "ServiceFunctionInstance", "test_sfc_non_premium", "ServiceFunctionChainInstance", "utilizedBy"), - ("apache_1", "ServiceFunctionInstance", "test_sfc_non_premium", "ServiceFunctionChainInstance", "utilizedBy"), - ("minio", "ServiceFunction", "test_sfc", "ServiceFunctionChain", "utilizedBy"), - ("apache", "ServiceFunction", "test_sfc", "ServiceFunctionChain", "utilizedBy"), + ("minio_2", "ServiceFunction", "minio_2_ep1", "Endpoint", "realisedBy"), + ("apache_1", "ServiceFunction", "apache_1_ep1", "Endpoint", "realisedBy"), + ("minio_2", "ServiceFunction", "minio", "ServiceFunctionPackage", "instanceOf"), + ("apache_1", "ServiceFunction", "apache", "ServiceFunctionPackage", "instanceOf"), + ("minio_2", "ServiceFunction", "test_sfc_non_premium", "ServiceFunctionChainInstance", "utilizedBy"), + ("apache_1", "ServiceFunction", "test_sfc_non_premium", "ServiceFunctionChainInstance", "utilizedBy"), + ("minio", "ServiceFunctionPackage", "test_sfc", "ServiceFunctionChain", "utilizedBy"), + ("apache", "ServiceFunctionPackage", "test_sfc", "ServiceFunctionChain", "utilizedBy"), ("test_sfc_non_premium", "ServiceFunctionChainInstance", "test_sfc", "ServiceFunctionChain", "instanceOf") ), graph_db, request_id ) @@ -279,8 +279,8 @@ class TestGraphAPI(object): assert len(graph_db.nodes.match("Endpoint")) == 0, "All endpoint nodes should have been deleted" assert set([node["name"] for node in graph_db.nodes.match("ComputeNode")]) == set(["DC" + str(i) for i in range(1, 7)]), "Compute nodes must not be deleted" - assert set([node["name"] for node in graph_db.nodes.match("ServiceFunctionInstance")]) == {"nginx_1", "apache_1", "minio_1", "minio_2"}, "Service function instances must not be deleted." - assert set([node["name"] for node in graph_db.nodes.match("ServiceFunction")]) == {"nginx", "minio", "apache"}, "Service functions must not be deleted" + assert set([node["name"] for node in graph_db.nodes.match("ServiceFunction")]) == {"nginx_1", "apache_1", "minio_1", "minio_2"}, "Service functions must not be deleted." + assert set([node["name"] for node in graph_db.nodes.match("ServiceFunctionPackage")]) == {"nginx", "minio", "apache"}, "Service function packages must not be deleted" assert set([node["name"] for node in graph_db.nodes.match("ServiceFunctionChainInstance")]) == {"test_sfc_premium", "test_sfc_non_premium"}, "Service function chain instances must not be deleted" assert set([node["name"] for node in graph_db.nodes.match("ServiceFunctionChain")]) == {"test_sfc"}, "Service function chains must not be deleted" diff --git a/src/service/clmcservice/graphapi/utilities.py b/src/service/clmcservice/graphapi/utilities.py index 2ac899d30186aa7a8985d1f245fc8b33873c2941..5704b1d7391d32486340b2f472387ca822f0a3ac 100644 --- a/src/service/clmcservice/graphapi/utilities.py +++ b/src/service/clmcservice/graphapi/utilities.py @@ -229,9 +229,9 @@ def build_temporal_graph(request_id, from_timestamp, to_timestamp, json_queries, query_to_execute = INFLUX_QUERY_TEMPLATE.format(response_time_field, request_size_field, response_size_field, db, rp, measurement, sfc, sfci, from_timestamp, to_timestamp) # create a node for the service function if it doesn't exist - service_function_node = find_or_create_node(graph, "ServiceFunction", name=service_function) + service_function_package_node = find_or_create_node(graph, "ServiceFunctionPackage", name=service_function) # crate a utilizedBy edge between the service function and the service function chain - find_or_create_edge(graph, "utilizedBy", service_function_node, service_function_chain_node) + find_or_create_edge(graph, "utilizedBy", service_function_package_node, service_function_chain_node) log.info("Executing query: {0}".format(query_to_execute)) result = influx_client.query(query_to_execute) # execute the query @@ -249,17 +249,17 @@ def build_temporal_graph(request_id, from_timestamp, to_timestamp, json_queries, request_size = result_point["mean_request_size"] # extract the avg request size of the SF from the result response_size = result_point["mean_response_size"] # extract the avg response size of the SF from the result - # create a ServiceFunctionInstance node from the tag value (if it is not already created) - service_function_instance_node = find_or_create_node(graph, "ServiceFunctionInstance", name=tags["sf"]) - # create an edge between the instance and the service function (if it is not already created) - find_or_create_edge(graph, "instanceOf", service_function_instance_node, service_function_node) - # crate a utilizedBy edge between the service function instance and the service function chain instance - find_or_create_edge(graph, "utilizedBy", service_function_instance_node, service_function_chain_instance_node) + # create a ServiceFunction node from the tag value (if it is not already created) + service_function_node = find_or_create_node(graph, "ServiceFunction", name=tags["sf"]) + # create an edge between the the service function and the package (if it is not already created) + find_or_create_edge(graph, "instanceOf", service_function_node, service_function_package_node) + # crate a utilizedBy edge between the service function and the service function chain instance + find_or_create_edge(graph, "utilizedBy", service_function_node, service_function_chain_instance_node) # create an Endpoint node from the tag value (if it is not already created) ipendpoint_node = find_or_create_node(graph, "Endpoint", name=tags["sfe"], response_time=response_time, request_size=request_size, response_size=response_size, uuid=request_id) - # create an edge between the instance and the endpoint (if it is not already created) - find_or_create_edge(graph, "realisedBy", service_function_instance_node, ipendpoint_node) + # create an edge between the service function and the endpoint (if it is not already created) + find_or_create_edge(graph, "realisedBy", service_function_node, ipendpoint_node) # create a ComputeNode node from the tag value (if it is not already created) compute_node = find_or_create_node(graph, "ComputeNode", name=tags["location"]) diff --git a/src/test/MANIFEST.in b/src/test/MANIFEST.in index 839a767b00e517e889ce264b9dff90252ddd44bf..ed111d81e6155a5b655eccd7382faf3d4f6b1707 100644 --- a/src/test/MANIFEST.in +++ b/src/test/MANIFEST.in @@ -1,2 +1,2 @@ include MANIFEST.in -recursive-include clmctest _version.py *.yml *.sh *.json *.conf \ No newline at end of file +recursive-include clmctest _version.py *.yml *.yaml *.sh *.json *.conf \ No newline at end of file diff --git a/src/test/clmctest/alerts/__init__.py b/src/test/clmctest/alerts/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a93a4bf16d8eee8666c6a28c3e40306983804a29 100644 --- a/src/test/clmctest/alerts/__init__.py +++ b/src/test/clmctest/alerts/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/python3 diff --git a/src/test/setup.py b/src/test/setup.py index 78c16282f64d6cbfd25cc32ed19cbe13849ed05e..8a52b180bedef919d1ca496cf26eb3ea26ee8843 100644 --- a/src/test/setup.py +++ b/src/test/setup.py @@ -51,7 +51,7 @@ setup( url='https://gitlab.it-innovation.soton.ac.uk/FLAME/flame-clmc', packages=find_packages(exclude=["services"]), include_package_data=True, - package_data={'': ['_version.py', '*.yml', '*.sh', '*.json', '*.conf']}, + package_data={'': ['_version.py', '*.yml', '*.yaml', '*.sh', '*.json', '*.conf']}, long_description="FLAME CLMC", classifiers=[ "Development Status :: Alpha",