summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorkrishnaa96 <krishna.moorthy6@wipro.com>2021-04-08 14:14:48 +0530
committerkrishnaa96 <krishna.moorthy6@wipro.com>2021-04-08 14:14:48 +0530
commit7ef613de6d9cd794fd10ae43d98ffa9312418e68 (patch)
tree7fb698b06166d0227b6dc8c04347df4c5a11ed18 /test
parentaafb48a95fe5ace431ebe607cab660fddde8c2cc (diff)
Update AAI query to DSL query - Slice termination
Issue-ID: OPTFRA-936 Signed-off-by: krishnaa96 <krishna.moorthy6@wipro.com> Change-Id: I7a2bba7d23645c8bff9f503361a93fd3ac3ebc3a
Diffstat (limited to 'test')
-rw-r--r--test/apps/nxi_termination/nssi_failure_output.json2
-rw-r--r--test/apps/nxi_termination/nxi_failure_output1.json2
-rw-r--r--test/apps/nxi_termination/nxi_failure_output2.json2
-rw-r--r--test/apps/nxi_termination/test_remote_opt_processor_termination.py49
-rw-r--r--test/functest/simulators/oof_dependencies_simulators.py42
5 files changed, 69 insertions, 28 deletions
diff --git a/test/apps/nxi_termination/nssi_failure_output.json b/test/apps/nxi_termination/nssi_failure_output.json
index 5ada892..f300c53 100644
--- a/test/apps/nxi_termination/nssi_failure_output.json
+++ b/test/apps/nxi_termination/nssi_failure_output.json
@@ -3,6 +3,6 @@
"transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"requestStatus": "success",
"terminateResponse": false,
- "reason": "4115d3c8-dd59-45d6-b09d-e756dee9b518 is not available in AAI"
+ "reason": ""
} \ No newline at end of file
diff --git a/test/apps/nxi_termination/nxi_failure_output1.json b/test/apps/nxi_termination/nxi_failure_output1.json
index b363e86..4cce5eb 100644
--- a/test/apps/nxi_termination/nxi_failure_output1.json
+++ b/test/apps/nxi_termination/nxi_failure_output1.json
@@ -3,7 +3,7 @@
"transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"requestStatus": "success",
"terminateResponse": false,
- "reason": "cdad9f49-4201-4e3a-aac1-b0f27902c299 is not available in AAI"
+ "reason": ""
}
diff --git a/test/apps/nxi_termination/nxi_failure_output2.json b/test/apps/nxi_termination/nxi_failure_output2.json
index 5d430bc..f18b73c 100644
--- a/test/apps/nxi_termination/nxi_failure_output2.json
+++ b/test/apps/nxi_termination/nxi_failure_output2.json
@@ -3,5 +3,5 @@
"transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"requestStatus": "success",
"terminateResponse": false,
- "reason": "Associated to more than one"
+ "reason": ""
} \ No newline at end of file
diff --git a/test/apps/nxi_termination/test_remote_opt_processor_termination.py b/test/apps/nxi_termination/test_remote_opt_processor_termination.py
index 4fa8170..9fbc27b 100644
--- a/test/apps/nxi_termination/test_remote_opt_processor_termination.py
+++ b/test/apps/nxi_termination/test_remote_opt_processor_termination.py
@@ -69,73 +69,74 @@ class TestRemoteOptProcessor(unittest.TestCase):
exception_response_json1 = json_from_file(exception_response_file1)
#nsi success scenario
- self.patcher_req=patch('apps.nxi_termination.optimizers.remote_opt_processor.get_service_profiles',return_value=service_profile_json)
+ self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count', return_value=1)
self.Mock_req = self.patcher_req.start()
- self.assertEquals(success_output_json, process_nxi_termination_opt(request_json,osdf_config))
+ self.assertEquals(success_output_json, process_nxi_termination_opt(request_json, osdf_config))
self.patcher_req.stop()
#nsi failure scenario
- self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_service_profiles', return_value=failure_service_profile_json)
+ self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count', return_value=3)
self.Mock_req = self.patcher_req.start()
self.assertEquals(nxi_failure_output_json1, process_nxi_termination_opt(request_json, osdf_config))
self.patcher_req.stop()
+ request_json["requestInfo"]["addtnlArgs"] = {}
+
#nsi success scenario
- self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_service_profiles',
- return_value=[])
+ self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count',
+ return_value=0)
self.Mock_req = self.patcher_req.start()
self.assertEquals(success_output_json, process_nxi_termination_opt(request_json, osdf_config))
self.patcher_req.stop()
# nsi failure scenario
- self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_service_profiles',
- return_value=failure_service_profile_json2)
+ self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count',
+ return_value=1)
self.Mock_req = self.patcher_req.start()
self.assertEquals(nxi_failure_output_json2, process_nxi_termination_opt(request_json, osdf_config))
self.patcher_req.stop()
# #
# nssi success scenario
- self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_relationshiplist', return_value=success_rel_json)
+ self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count', return_value=1)
self.Mock_req = self.patcher_req.start()
self.assertEquals(success_output_json, process_nxi_termination_opt(nssi_request_json, osdf_config))
self.patcher_req.stop()
- # nssi success scenario
- self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_relationshiplist',
- return_value=[])
+ # nssi failure scenario
+ self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count',
+ return_value=2)
self.Mock_req = self.patcher_req.start()
- self.assertEquals(success_output_json, process_nxi_termination_opt(nssi_request_json, osdf_config))
+ self.assertEquals(nssi_failure_output_json, process_nxi_termination_opt(nssi_request_json, osdf_config))
self.patcher_req.stop()
- # nssi failure scenario
- self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_relationshiplist',
- return_value=failure_rel_json)
+ nssi_request_json["requestInfo"]["addtnlArgs"] = {}
+
+ # nssi success scenario
+ self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count',
+ return_value=0)
self.Mock_req = self.patcher_req.start()
- self.assertEquals(nssi_failure_output_json, process_nxi_termination_opt(nssi_request_json, osdf_config))
+ self.assertEquals(success_output_json, process_nxi_termination_opt(nssi_request_json, osdf_config))
self.patcher_req.stop()
# nssi failure scenario
- self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_relationshiplist',
- return_value=failure_rel_json2)
+ self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count',
+ return_value=1)
self.Mock_req = self.patcher_req.start()
self.assertEquals(nxi_failure_output_json2, process_nxi_termination_opt(nssi_request_json, osdf_config))
self.patcher_req.stop()
- self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_relationshiplist',
+ self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count',
side_effect=AAIException("Error response recieved from AAI for the request"))
self.Mock_req = self.patcher_req.start()
- self.assertEquals(exception_response_json1, process_nxi_termination_opt(nssi_request_json, osdf_config))
+ self.assertEquals("failure", process_nxi_termination_opt(nssi_request_json, osdf_config).get('requestStatus'))
self.patcher_req.stop()
-
- self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_relationshiplist',
+ self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count',
side_effect=AAIException("Request exception was encountered"))
self.Mock_req = self.patcher_req.start()
self.assertEquals("failure", process_nxi_termination_opt(nssi_request_json, osdf_config).get('requestStatus'))
self.patcher_req.stop()
-
-
if __name__ == "__main__":
unittest.main() \ No newline at end of file
diff --git a/test/functest/simulators/oof_dependencies_simulators.py b/test/functest/simulators/oof_dependencies_simulators.py
index b0b7b32..53cc74e 100644
--- a/test/functest/simulators/oof_dependencies_simulators.py
+++ b/test/functest/simulators/oof_dependencies_simulators.py
@@ -23,7 +23,7 @@ import glob
import json
import os
-from flask import Flask, jsonify
+from flask import Flask, jsonify, request
from osdf.utils.interfaces import json_from_file
@@ -119,5 +119,45 @@ def get_nbr_list(cell_id, ts):
return jsonify(data), 503
+@app.route("/simulated/aai/v23/dsl", methods=["PUT"])
+def dsl_query():
+
+ nsi_query = {"dsl": "service-instance*('service-instance-id','9629e36c-a3d9-4aed-8368-f72b8be1cd34') > "
+ "service-instance*('service-role','e2eserviceprofile-service')"}
+
+ nssi_query = {"dsl": "service-instance*('service-instance-id','9629e36c-a3d9-4aed-8368-f72b8be1cd34') > "
+ "service-instance*('service-role','nsi')"}
+
+ nsi_with_sp_query = {"dsl": "service-instance*('service-instance-id','9629e36c-a3d9-4aed-8368-f72b8be1cd34') > "
+ "service-instance*('service-role','e2eserviceprofile-service')("
+ "'service-instance-id',"
+ "'660ca85c-1a0f-4521-a559-65f23e794699660ca85c-1a0f-4521-a559-65f23e794699')"}
+
+ nssi_with_nsi_query = {"dsl": "service-instance*('service-instance-id','9629e36c-a3d9-4aed-8368-f72b8be1cd34') > "
+ "service-instance*('service-role','nsi')('service-instance-id',"
+ "'660ca85c-1a0f-4521-a559-65f23e794699')"}
+
+ queries = {
+ "nsi": nsi_query,
+ "nssi_query": nssi_query,
+ "nsi_with_sp": nsi_with_sp_query,
+ "nssi_with_nsi": nssi_with_nsi_query
+ }
+
+ count = {
+ "nsi": 1,
+ "nssi_query": 1,
+ "nsi_with_sp": 2,
+ "nssi_with_nsi": 2
+ }
+
+ request_body = request.get_json()
+ service_count = 0
+ for query_type, query in queries.items():
+ if request_body == query:
+ service_count = count[query_type]
+ return {'results': [{'service-instance': service_count}]}
+
+
if __name__ == "__main__":
app.run(debug=True, host='0.0.0.0')