Skip to content
Snippets Groups Projects
Commit f28a4570 authored by Nikolay Stanchev's avatar Nikolay Stanchev
Browse files

Updates node types used in Neo4j

parent 5d961d41
No related branches found
No related tags found
No related merge requests found
...@@ -147,10 +147,10 @@ class TestGraphAPI(object): ...@@ -147,10 +147,10 @@ class TestGraphAPI(object):
graph_1_id = request_id graph_1_id = request_id
# check that the appropriate nodes have been created # 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")]) 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" assert sf_names == {"nginx_1", "minio_1"}, "The graph must contain 2 service functions - nginx_1 and minio_1"
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"
endpoints = set([node["name"] for node in graph_db.nodes.match("Endpoint", uuid=request_id)]) 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" 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")]) sfci_names = set([node["name"] for node in graph_db.nodes.match("ServiceFunctionChainInstance")])
...@@ -167,14 +167,14 @@ class TestGraphAPI(object): ...@@ -167,14 +167,14 @@ class TestGraphAPI(object):
("minio_1_ep1", "Endpoint", "DC4", "ComputeNode", "hostedBy"), ("minio_1_ep1", "Endpoint", "DC4", "ComputeNode", "hostedBy"),
("nginx_1_ep1", "Endpoint", "DC4", "ComputeNode", "hostedBy"), ("nginx_1_ep1", "Endpoint", "DC4", "ComputeNode", "hostedBy"),
("nginx_1_ep2", "Endpoint", "DC6", "ComputeNode", "hostedBy"), ("nginx_1_ep2", "Endpoint", "DC6", "ComputeNode", "hostedBy"),
("minio_1", "ServiceFunctionInstance", "minio_1_ep1", "Endpoint", "realisedBy"), ("minio_1", "ServiceFunction", "minio_1_ep1", "Endpoint", "realisedBy"),
("nginx_1", "ServiceFunctionInstance", "nginx_1_ep1", "Endpoint", "realisedBy"), ("nginx_1", "ServiceFunction", "nginx_1_ep1", "Endpoint", "realisedBy"),
("nginx_1", "ServiceFunctionInstance", "nginx_1_ep2", "Endpoint", "realisedBy"), ("nginx_1", "ServiceFunction", "nginx_1_ep2", "Endpoint", "realisedBy"),
("minio_1", "ServiceFunctionInstance", "minio", "ServiceFunction", "instanceOf"), ("minio_1", "ServiceFunction", "minio", "ServiceFunctionPackage", "instanceOf"),
("nginx_1", "ServiceFunctionInstance", "test_sfc_premium", "ServiceFunctionChainInstance", "utilizedBy"), ("nginx_1", "ServiceFunction", "test_sfc_premium", "ServiceFunctionChainInstance", "utilizedBy"),
("minio_1", "ServiceFunctionInstance", "test_sfc_premium", "ServiceFunctionChainInstance", "utilizedBy"), ("minio_1", "ServiceFunction", "test_sfc_premium", "ServiceFunctionChainInstance", "utilizedBy"),
("nginx", "ServiceFunction", "test_sfc", "ServiceFunctionChain", "utilizedBy"), ("nginx", "ServiceFunctionPackage", "test_sfc", "ServiceFunctionChain", "utilizedBy"),
("minio", "ServiceFunction", "test_sfc", "ServiceFunctionChain", "utilizedBy"), ("minio", "ServiceFunctionPackage", "test_sfc", "ServiceFunctionChain", "utilizedBy"),
("test_sfc_premium", "ServiceFunctionChainInstance", "test_sfc", "ServiceFunctionChain", "instanceOf"), ("test_sfc_premium", "ServiceFunctionChainInstance", "test_sfc", "ServiceFunctionChain", "instanceOf"),
), graph_db, request_id ), graph_db, request_id
) )
...@@ -187,7 +187,7 @@ class TestGraphAPI(object): ...@@ -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["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" 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)", 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)"}, "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)", apache={"measurement_name": "apache", "response_time_field": "mean(avg_processing_time)",
...@@ -206,10 +206,10 @@ class TestGraphAPI(object): ...@@ -206,10 +206,10 @@ class TestGraphAPI(object):
graph_2_id = request_id graph_2_id = request_id
# check the new nodes have been created # 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"): for sf 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) 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"): 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) 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): ...@@ -225,14 +225,14 @@ class TestGraphAPI(object):
( (
("minio_2_ep1", "Endpoint", "DC5", "ComputeNode", "hostedBy"), ("minio_2_ep1", "Endpoint", "DC5", "ComputeNode", "hostedBy"),
("apache_1_ep1", "Endpoint", "DC5", "ComputeNode", "hostedBy"), ("apache_1_ep1", "Endpoint", "DC5", "ComputeNode", "hostedBy"),
("minio_2", "ServiceFunctionInstance", "minio_2_ep1", "Endpoint", "realisedBy"), ("minio_2", "ServiceFunction", "minio_2_ep1", "Endpoint", "realisedBy"),
("apache_1", "ServiceFunctionInstance", "apache_1_ep1", "Endpoint", "realisedBy"), ("apache_1", "ServiceFunction", "apache_1_ep1", "Endpoint", "realisedBy"),
("minio_2", "ServiceFunctionInstance", "minio", "ServiceFunction", "instanceOf"), ("minio_2", "ServiceFunction", "minio", "ServiceFunctionPackage", "instanceOf"),
("apache_1", "ServiceFunctionInstance", "apache", "ServiceFunction", "instanceOf"), ("apache_1", "ServiceFunction", "apache", "ServiceFunctionPackage", "instanceOf"),
("minio_2", "ServiceFunctionInstance", "test_sfc_non_premium", "ServiceFunctionChainInstance", "utilizedBy"), ("minio_2", "ServiceFunction", "test_sfc_non_premium", "ServiceFunctionChainInstance", "utilizedBy"),
("apache_1", "ServiceFunctionInstance", "test_sfc_non_premium", "ServiceFunctionChainInstance", "utilizedBy"), ("apache_1", "ServiceFunction", "test_sfc_non_premium", "ServiceFunctionChainInstance", "utilizedBy"),
("minio", "ServiceFunction", "test_sfc", "ServiceFunctionChain", "utilizedBy"), ("minio", "ServiceFunctionPackage", "test_sfc", "ServiceFunctionChain", "utilizedBy"),
("apache", "ServiceFunction", "test_sfc", "ServiceFunctionChain", "utilizedBy"), ("apache", "ServiceFunctionPackage", "test_sfc", "ServiceFunctionChain", "utilizedBy"),
("test_sfc_non_premium", "ServiceFunctionChainInstance", "test_sfc", "ServiceFunctionChain", "instanceOf") ("test_sfc_non_premium", "ServiceFunctionChainInstance", "test_sfc", "ServiceFunctionChain", "instanceOf")
), graph_db, request_id ), graph_db, request_id
) )
...@@ -279,8 +279,8 @@ class TestGraphAPI(object): ...@@ -279,8 +279,8 @@ class TestGraphAPI(object):
assert len(graph_db.nodes.match("Endpoint")) == 0, "All endpoint nodes should have been deleted" 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("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_1", "apache_1", "minio_1", "minio_2"}, "Service functions 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("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("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" assert set([node["name"] for node in graph_db.nodes.match("ServiceFunctionChain")]) == {"test_sfc"}, "Service function chains must not be deleted"
......
...@@ -229,9 +229,9 @@ def build_temporal_graph(request_id, from_timestamp, to_timestamp, json_queries, ...@@ -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) 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 # 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 # 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)) log.info("Executing query: {0}".format(query_to_execute))
result = influx_client.query(query_to_execute) # execute the query 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, ...@@ -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 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 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) # create a ServiceFunction node from the tag value (if it is not already created)
service_function_instance_node = find_or_create_node(graph, "ServiceFunctionInstance", name=tags["sf"]) service_function_node = find_or_create_node(graph, "ServiceFunction", name=tags["sf"])
# create an edge between the instance and the service function (if it is not already created) # 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_instance_node, service_function_node) find_or_create_edge(graph, "instanceOf", service_function_node, service_function_package_node)
# crate a utilizedBy edge between the service function instance and the service function chain instance # crate a utilizedBy edge between the service function and the service function chain instance
find_or_create_edge(graph, "utilizedBy", service_function_instance_node, service_function_chain_instance_node) 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) # 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) 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) # create an edge between the service function and the endpoint (if it is not already created)
find_or_create_edge(graph, "realisedBy", service_function_instance_node, ipendpoint_node) 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) # 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"]) compute_node = find_or_create_node(graph, "ComputeNode", name=tags["location"])
......
include MANIFEST.in include MANIFEST.in
recursive-include clmctest _version.py *.yml *.sh *.json *.conf recursive-include clmctest _version.py *.yml *.yaml *.sh *.json *.conf
\ No newline at end of file \ No newline at end of file
#!/usr/bin/python3
...@@ -51,7 +51,7 @@ setup( ...@@ -51,7 +51,7 @@ setup(
url='https://gitlab.it-innovation.soton.ac.uk/FLAME/flame-clmc', url='https://gitlab.it-innovation.soton.ac.uk/FLAME/flame-clmc',
packages=find_packages(exclude=["services"]), packages=find_packages(exclude=["services"]),
include_package_data=True, 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", long_description="FLAME CLMC",
classifiers=[ classifiers=[
"Development Status :: Alpha", "Development Status :: Alpha",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment