diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1c9ae7583d7964c9265a7536352ea8e9348535ad..c79aaa55d9708c7d8a447de7165b90a7fb4740a4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,8 +35,8 @@ build:tests: - python setup.py sdist --dist-dir=$CI_PROJECT_DIR/build artifacts: paths: - - build/clmctest-2.0.3.tar.gz - - build/clmcservice-2.0.3.tar.gz + - build/clmctest-2.0.4.tar.gz + - build/clmcservice-2.0.4.tar.gz expire_in: 1 day test:all: @@ -50,8 +50,8 @@ test:all: - echo "REPO_PASS=${REPO_PASS}" >> $CI_PROJECT_DIR/reporc - sudo scripts/test/fixture.sh create -f src/test/clmctest/rspec.json -r $CI_PROJECT_DIR -c all - sudo mkdir /var/lib/lxd/containers/test-runner/rootfs/opt/clmc/build - - sudo cp build/clmctest-2.0.3.tar.gz /var/lib/lxd/containers/test-runner/rootfs/opt/clmc/build - - sudo lxc exec test-runner -- pip3 install /opt/clmc/build/clmctest-2.0.3.tar.gz + - sudo cp build/clmctest-2.0.4.tar.gz /var/lib/lxd/containers/test-runner/rootfs/opt/clmc/build + - sudo lxc exec test-runner -- pip3 install /opt/clmc/build/clmctest-2.0.4.tar.gz - sudo lxc exec test-runner -- pytest -s --tb=short -rfp --pyargs clmctest when: on_success diff --git a/scripts/clmc-service/install-clmc-service.sh b/scripts/clmc-service/install-clmc-service.sh index 581a17a511bd7287723be8a5529affb5be00b7d6..27f60ebc1320272526b62575f0cafe28d62ab427 100755 --- a/scripts/clmc-service/install-clmc-service.sh +++ b/scripts/clmc-service/install-clmc-service.sh @@ -163,4 +163,5 @@ cp ${REPO_ROOT}/scripts/clmc-service/nginx.conf /etc/nginx/nginx.conf systemctl restart nginx # nginx is already started on installation, to read the new conf it needs to be restarted # move the graph pipeline script -cp ${REPO_ROOT}/scripts/clmc-service/graph-pipeline.sh /usr/local/bin/ \ No newline at end of file +cp ${REPO_ROOT}/scripts/clmc-service/graph-pipeline.sh /usr/local/bin/ +chmod u+x /usr/local/bin/graph-pipeline.sh \ No newline at end of file diff --git a/src/service/VERSION b/src/service/VERSION index 966cd76e5fb78bf3f154ef049c8de0476ed86910..9790358565b1ca694d3f9a6f7e2f59f2d512b9aa 100644 --- a/src/service/VERSION +++ b/src/service/VERSION @@ -1 +1 @@ -__version__ = "2.0.3" \ No newline at end of file +__version__ = "2.0.4" \ No newline at end of file diff --git a/src/service/clmcservice/graphapi/conftest.py b/src/service/clmcservice/graphapi/conftest.py index 8adc2834e4866ef818ceeddbda4c64eadb81214b..ed2d62e7bbd9570383084a611f0411e11d6e1af8 100644 --- a/src/service/clmcservice/graphapi/conftest.py +++ b/src/service/clmcservice/graphapi/conftest.py @@ -203,6 +203,9 @@ def graph_network_topology(): global links, switches, clusters graph = Graph(host="localhost", password="admin") + graph.node_cache.clear() + graph.relationship_cache.clear() + build_network_graph(graph, switches, links, clusters, ues) yield diff --git a/src/service/clmcservice/graphapi/views.py b/src/service/clmcservice/graphapi/views.py index 323b78ac2836b86a53b8d8a7f46db4788f1b0882..e89f32e9376f2b979116f86f8e1f8ca1f21949cd 100644 --- a/src/service/clmcservice/graphapi/views.py +++ b/src/service/clmcservice/graphapi/views.py @@ -73,7 +73,7 @@ class GraphAPI(object): except AssertionError as e: raise HTTPBadRequest("Bad request content: {0}".format(e.args)) - graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) + graph = self.get_graph_reference() influx_client = InfluxDBClient(host=self.request.registry.settings['influx_host'], port=self.request.registry.settings['influx_port'], timeout=10) database_name = json_queries["service_function_chain"] @@ -102,7 +102,7 @@ class GraphAPI(object): """ graph_id = self.request.matchdict['graph_id'] # get the UUID of the subgraph from the URL - graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) # connect to the neo4j graph db + graph = self.get_graph_reference() if graph.nodes.match("Reference", uuid=graph_id).first() is None: raise HTTPNotFound("No subgraph found associated with the request ID {0}".format(graph_id)) @@ -121,7 +121,7 @@ class GraphAPI(object): """ sfc_id = self.request.matchdict['sfc_id'] # get the SFC identifier from the URL - graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) # connect to the neo4j graph db + graph = self.get_graph_reference() # check if this SFC node exists sfc_node = graph.nodes.match("ServiceFunctionChain", name=sfc_id).first() @@ -162,7 +162,7 @@ class GraphAPI(object): startpoint_node_label = params["startpoint"] endpoint_node_label = params["endpoint"] - graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) # connect to the neo4j graph db + graph = self.get_graph_reference() all_nodes = graph.nodes @@ -260,7 +260,7 @@ class GraphAPI(object): :return: A JSON response with the number of switches, clusters and ues that were built. """ - graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) # connect to the neo4j graph db + graph = self.get_graph_reference() sdn_controller_ip = self.request.registry.settings['sdn_controller_ip'] sdn_controller_port = self.request.registry.settings['sdn_controller_port'] @@ -360,7 +360,7 @@ class GraphAPI(object): :return: A JSON response with the number of switches, clusters and ues that were deleted. """ - graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) # connect to the neo4j graph db + graph = self.get_graph_reference() deleted_switches, deleted_clusters, deleted_ues = delete_network_graph(graph) @@ -388,7 +388,8 @@ class GraphAPI(object): raise HTTPBadRequest("Database for service function chain {0} not found.".format(database_name)) # get the list of UEs from the Neo4j graph - if no UEs are found, the network topology has not been built yet, so return bad request - graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) + graph = self.get_graph_reference() + ue_nodes = graph.nodes.match("UserEquipment") ues_list = [ue_node["name"] for ue_node in ue_nodes] # return bad request for empty list of UEs @@ -440,3 +441,19 @@ class GraphAPI(object): MonitoringProcess.delete(request_id) return response + + def get_graph_reference(self): + """ + A utility function to get a Graph DB object reference and clear the cache of py2neo since it might lead to erroneous behaviour + + :return: reference to the graph DB object + """ + + graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) + + # TODO we probably need to remove the caching functionality of py2neo and maintain our own version + # NOTE: make sure Py2neo caching is disabled! + graph.node_cache.clear() + graph.relationship_cache.clear() + + return graph diff --git a/src/test/VERSION b/src/test/VERSION index 966cd76e5fb78bf3f154ef049c8de0476ed86910..9790358565b1ca694d3f9a6f7e2f59f2d512b9aa 100644 --- a/src/test/VERSION +++ b/src/test/VERSION @@ -1 +1 @@ -__version__ = "2.0.3" \ No newline at end of file +__version__ = "2.0.4" \ No newline at end of file