diff --git a/scripts/test/pipeline.sh b/scripts/clmc-service/graph-pipeline.sh similarity index 98% rename from scripts/test/pipeline.sh rename to scripts/clmc-service/graph-pipeline.sh index 6042ce8b917d5c3a75268593b20e2b60a96c1934..1f031505700f56995b066c87a0582fa9ba23275e 100644 --- a/scripts/test/pipeline.sh +++ b/scripts/clmc-service/graph-pipeline.sh @@ -37,6 +37,7 @@ read query_period db_name results_measurement <<< ${fields} JSON_CONFIG=$(echo ${JSON_CONFIG} | jq 'del(.query_period, .results_measurement_name)') +# TODO this shouldn't be in the script maybe move it to the clmc isntall script echo "Building network subgraph..." response=$(curl -s -X POST http://${CLMC_IP}/clmc-service/graph/network) echo ${response} diff --git a/scripts/clmc-service/install-clmc-service.sh b/scripts/clmc-service/install-clmc-service.sh index a815007293e409e745f9538b394b2f52b6c6d276..83cefd1fc069ccbcd0ec0f4c47a7501ff1bb22e2 100755 --- a/scripts/clmc-service/install-clmc-service.sh +++ b/scripts/clmc-service/install-clmc-service.sh @@ -35,7 +35,7 @@ sudo -u postgres bash -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE \"whoamidb\ # install virtualenvwrapper to manage python environments - and check echo "----> Installing Python3, Pip3 and curl" -apt-get install -y python3 python3-pip curl +apt-get install -y python3 python3-pip curl jq update-alternatives --install /usr/bin/python python /usr/bin/python3 10 echo "----> Installing virtualenv and wrapper" @@ -161,3 +161,6 @@ done apt-get install nginx -y 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 diff --git a/src/service/clmcservice/graphapi/tests.py b/src/service/clmcservice/graphapi/tests.py index 70e046456c0a76eb316c5670b53baf2e46f8f1e5..78ec6b50e4198d38d6da1622fb260b4f795d6673 100644 --- a/src/service/clmcservice/graphapi/tests.py +++ b/src/service/clmcservice/graphapi/tests.py @@ -529,7 +529,7 @@ class TestGraphAPI(object): response = GraphAPI(request).execute_graph_pipeline() assert response == {"uuid": uuid_mock.return_value, "database": "test_sfc"} - popen_mock.assert_called_once_with(["./graph_pipeline.sh", body]) # assert that the graph pipeline script is ran with the JSON config that was received in the request + popen_mock.assert_called_once_with(["graph-pipeline.sh", body]) # assert that the graph pipeline script is ran with the JSON config that was received in the request pid_property_mock.assert_called_once_with() # assert that the process ID attribute was called and saved returncode_property_mock.assert_called_once_with() # assert that the process return code attribute was called to check if the process has started successfully @@ -544,7 +544,7 @@ class TestGraphAPI(object): error_raised = True assert error_raised, "Expecting a 500 HTTP error if the process terminated immediately after it was started" - popen_mock.assert_called_with(["./graph_pipeline.sh", body]) # assert that the graph pipeline script is ran with the JSON config that was received in the request + popen_mock.assert_called_with(["graph-pipeline.sh", body]) # assert that the graph pipeline script is ran with the JSON config that was received in the request pid_property_mock.assert_called_with() # assert that the process ID attribute was called and saved returncode_property_mock.assert_called_with() # assert that the process return code attribute was called to check if the process has started successfully diff --git a/src/service/clmcservice/graphapi/views.py b/src/service/clmcservice/graphapi/views.py index 041232dc51d3ddce892f0a532956e13deef47263..e562bdff8ccff5b847d8347afb7c83a2d9bed3ee 100644 --- a/src/service/clmcservice/graphapi/views.py +++ b/src/service/clmcservice/graphapi/views.py @@ -154,7 +154,11 @@ class GraphAPI(object): query_to_execute = RTT_CYPHER_QUERY_TEMPLATE.format(startpoint_node_type, startpoint_node_label, endpoint_node_label, graph_id) log.info("Executing cypher query: {0}".format(query_to_execute)) data = graph.run(query_to_execute).data() # returns a list of dictionaries, each dictionary represents a row in the result - result = data[0] + try: + result = data[0] + except Exception as e: + log.error("Unexpected error occurred while executing RTT cypher query for graph with UUID {0} - {1}".format(graph_id, e)) + raise HTTPBadRequest("The Neo4j cypher query didn't return a valid result for the temporal graph with ID {0}".format(graph_id)) sf_node = graph.match(nodes=(None, endpoint_node), r_type="realisedBy").first().start_node if sf_node is None: @@ -362,7 +366,7 @@ class GraphAPI(object): request_uuid = str(uuid4()) sfc = json_queries["service_function_chain"] - process = Popen(["./graph_pipeline.sh", body]) + process = Popen(["graph-pipeline.sh", body]) process_pid = process.pid process_return_code = process.returncode