aboutsummaryrefslogtreecommitdiffstats
path: root/test/apps
diff options
context:
space:
mode:
Diffstat (limited to 'test/apps')
-rw-r--r--test/apps/nxi_termination/_init_.py0
-rw-r--r--test/apps/nxi_termination/aai_exception_response.json4
-rw-r--r--test/apps/nxi_termination/aai_response.json64
-rw-r--r--test/apps/nxi_termination/exception_response1.json7
-rw-r--r--test/apps/nxi_termination/failure_relationship_list.json66
-rw-r--r--test/apps/nxi_termination/failure_relationship_list2.json52
-rw-r--r--test/apps/nxi_termination/failure_service_profiles.json24
-rw-r--r--test/apps/nxi_termination/failure_service_profiles2.json42
-rw-r--r--test/apps/nxi_termination/invalid_request.json17
-rw-r--r--test/apps/nxi_termination/nsi_success_output.json7
-rw-r--r--test/apps/nxi_termination/nssi_failure_output.json8
-rw-r--r--test/apps/nxi_termination/nssi_termination.json17
-rw-r--r--test/apps/nxi_termination/nxi_failure_output1.json10
-rw-r--r--test/apps/nxi_termination/nxi_failure_output2.json7
-rw-r--r--test/apps/nxi_termination/nxi_termination.json17
-rw-r--r--test/apps/nxi_termination/service_profiles.json23
-rw-r--r--test/apps/nxi_termination/success_relationship_list.json34
-rw-r--r--test/apps/nxi_termination/test_fetch_aai_data.py70
-rw-r--r--test/apps/nxi_termination/test_remote_opt_processor_termination.py136
-rw-r--r--test/apps/pci_optimization/des_result.json18
-rw-r--r--test/apps/pci_optimization/test_ml_model.py87
-rw-r--r--test/apps/slice_selection/conductor_error_response.json18
-rw-r--r--test/apps/slice_selection/new_solution_conductor_response.json47
-rw-r--r--test/apps/slice_selection/new_solution_nsi_response.json35
-rw-r--r--test/apps/slice_selection/no_rec.json18
-rw-r--r--test/apps/slice_selection/no_recomm_conductor_response.json18
-rw-r--r--test/apps/slice_selection/no_recomm_nsi_response.json7
-rw-r--r--test/apps/slice_selection/nsi_error_response.json6
-rw-r--r--test/apps/slice_selection/nsi_request.json31
-rw-r--r--test/apps/slice_selection/nsi_selection_invalid_request.json80
-rw-r--r--test/apps/slice_selection/nsi_selection_request.json84
-rw-r--r--test/apps/slice_selection/nssi_conductor_response.json53
-rw-r--r--test/apps/slice_selection/nssi_error_response.json7
-rw-r--r--test/apps/slice_selection/nssi_selection_invalid_request.json23
-rw-r--r--test/apps/slice_selection/nssi_selection_request.json27
-rw-r--r--test/apps/slice_selection/shared_solution_conductor_response.json53
-rw-r--r--test/apps/slice_selection/shared_solution_nsi_response.json17
-rw-r--r--test/apps/slice_selection/shared_solution_nssi_response.json15
-rw-r--r--test/apps/slice_selection/slice_policies.txt5
-rw-r--r--test/apps/slice_selection/subnet_policies.txt5
-rw-r--r--test/apps/slice_selection/test_remote_opt_processor.py165
41 files changed, 1424 insertions, 0 deletions
diff --git a/test/apps/nxi_termination/_init_.py b/test/apps/nxi_termination/_init_.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/apps/nxi_termination/_init_.py
diff --git a/test/apps/nxi_termination/aai_exception_response.json b/test/apps/nxi_termination/aai_exception_response.json
new file mode 100644
index 0000000..56f61df
--- /dev/null
+++ b/test/apps/nxi_termination/aai_exception_response.json
@@ -0,0 +1,4 @@
+{
+ "status-code": 404,
+ "status-response": "NOT FOUND"
+} \ No newline at end of file
diff --git a/test/apps/nxi_termination/aai_response.json b/test/apps/nxi_termination/aai_response.json
new file mode 100644
index 0000000..b7ef43b
--- /dev/null
+++ b/test/apps/nxi_termination/aai_response.json
@@ -0,0 +1,64 @@
+{"service-instance": [{
+ "service-instance-id": "1a636c4d-5e76-427e-bfd6-241a947224b0",
+ "service-instance-name": "nssi_test_0211",
+ "service-type": "embb",
+ "service-role": "nssi",
+ "environment-context": "cn",
+ "model-invariant-id": "21d57d4b-52ad-4d3c-a798-248b5bb9124a",
+ "model-version-id": "bfba363e-e39c-4bd9-a9d5-1371c28f4d22",
+ "resource-version": "1581418601616",
+ "orchestration-status": "active",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4115d3c8-dd59-45d6-b09d-e756dee9b518",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "4115d3c8-dd59-45d6-b09d-e756dee9b518"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "nsi_test_0211"
+ }
+ ]
+ }
+ ]
+ },
+ "slice-profiles": {
+ "slice-profile": [
+ {
+ "profile-id": "cdad9f49-4201-4e3a-aac1-b0f27902c299",
+ "latency": 20,
+ "max-number-of-UEs": 0,
+ "coverage-area-TA-list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "ue-mobility-level": "stationary",
+ "resource-sharing-level": "0",
+ "exp-data-rate-UL": 100,
+ "exp-data-rate-DL": 100,
+ "activity-factor": 0,
+ "e2e-latency": 0,
+ "jitter": 0,
+ "survival-time": 0,
+ "exp-data-rate": 0,
+ "payload-size": 0,
+ "traffic-density": 0,
+ "conn-density": 0,
+ "reliability": 99.999,
+ "resource-version": "1581418602494"
+ }
+ ]
+ }
+}]}
diff --git a/test/apps/nxi_termination/exception_response1.json b/test/apps/nxi_termination/exception_response1.json
new file mode 100644
index 0000000..cde603f
--- /dev/null
+++ b/test/apps/nxi_termination/exception_response1.json
@@ -0,0 +1,7 @@
+{
+ "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus": "failure",
+ "reason": "Error response recieved from AAI for the request"
+
+} \ No newline at end of file
diff --git a/test/apps/nxi_termination/failure_relationship_list.json b/test/apps/nxi_termination/failure_relationship_list.json
new file mode 100644
index 0000000..392f4db
--- /dev/null
+++ b/test/apps/nxi_termination/failure_relationship_list.json
@@ -0,0 +1,66 @@
+[
+ {
+ "related-to": "allotted-resource",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v23/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/d88b6ce6-19be-439d-8553-4f9d6cce0494/allotted-resources/allotted-resource/07138106-f535-413b-b002-40ba24f95937",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "07138106-f535-413b-b002-40ba24f95937"
+ },
+ {
+ "relationship-key": "allotted-resource.id",
+ "relationship-value": "07138106-f535-413b-b002-40ba24f95937"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "allotted-resource.description"
+ },
+ {
+ "property-key": "allotted-resource.allotted-resource-name",
+ "property-value": "Allotted_coe"
+ }
+ ]
+ },
+ {
+ "related-to": "allotted-resource",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v23/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/d88b6ce6-19be-439d-8553-4f9d6cce0494/allotted-resources/allotted-resource/07138106-f535-413b-b002-40ba24f95937",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "d290f1ee-6c54-4b01-90e6-d701748f0851"
+ },
+ {
+ "relationship-key": "allotted-resource.id",
+ "relationship-value": "d290f1ee-6c54-4b01-90e6-d701748f0851"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "allotted-resource.description"
+ },
+ {
+ "property-key": "allotted-resource.allotted-resource-name",
+ "property-value": "Allotted_terminate"
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/test/apps/nxi_termination/failure_relationship_list2.json b/test/apps/nxi_termination/failure_relationship_list2.json
new file mode 100644
index 0000000..624448a
--- /dev/null
+++ b/test/apps/nxi_termination/failure_relationship_list2.json
@@ -0,0 +1,52 @@
+[
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4115d3c8-dd59-45d6-b09d-e756dee9b518",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "4115d3c8-dd59-45d6-b09d-e756dee9b567"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "nsi_test_0211"
+ }
+ ]
+ },
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4115d3c8-dd59-45d6-b09d-e756dee9b518",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "4115d3c8-dd59-45d6-b09d-e756dee9b567"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "nsi_test_0211"
+ }
+ ]
+ }
+ ] \ No newline at end of file
diff --git a/test/apps/nxi_termination/failure_service_profiles.json b/test/apps/nxi_termination/failure_service_profiles.json
new file mode 100644
index 0000000..d10a818
--- /dev/null
+++ b/test/apps/nxi_termination/failure_service_profiles.json
@@ -0,0 +1,24 @@
+[
+ {
+ "profile-id": "cdad9f49-4201-4e3a-aac1-b0f27902c29",
+ "latency": 20,
+ "max-number-of-UEs": 0,
+ "coverage-area-TA-list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "ue-mobility-level": "stationary",
+ "resource-sharing-level": "0",
+ "exp-data-rate-UL": 100,
+ "exp-data-rate-DL": 100,
+ "activity-factor": 0,
+ "e2e-latency": 0,
+ "jitter": 0,
+ "survival-time": 0,
+ "exp-data-rate": 0,
+ "payload-size": 0,
+ "traffic-density": 0,
+ "conn-density": 0,
+ "reliability": 99.999,
+ "resource-version": "1581418602494"
+ }
+]
+
+
diff --git a/test/apps/nxi_termination/failure_service_profiles2.json b/test/apps/nxi_termination/failure_service_profiles2.json
new file mode 100644
index 0000000..1740758
--- /dev/null
+++ b/test/apps/nxi_termination/failure_service_profiles2.json
@@ -0,0 +1,42 @@
+[
+ {
+ "profile-id": "cdad9f49-4201-4e3a-aac1-b0f27902c299",
+ "latency": 20,
+ "max-number-of-UEs": 0,
+ "coverage-area-TA-list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "ue-mobility-level": "stationary",
+ "resource-sharing-level": "0",
+ "exp-data-rate-UL": 100,
+ "exp-data-rate-DL": 100,
+ "activity-factor": 0,
+ "e2e-latency": 0,
+ "jitter": 0,
+ "survival-time": 0,
+ "exp-data-rate": 0,
+ "payload-size": 0,
+ "traffic-density": 0,
+ "conn-density": 0,
+ "reliability": 99.999,
+ "resource-version": "1581418602494"
+ },
+ {
+ "profile-id": "abcd9f49-4201-4e3a-aac1-b0f27902c299",
+ "latency": 20,
+ "max-number-of-UEs": 0,
+ "coverage-area-TA-list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "ue-mobility-level": "stationary",
+ "resource-sharing-level": "0",
+ "exp-data-rate-UL": 100,
+ "exp-data-rate-DL": 100,
+ "activity-factor": 0,
+ "e2e-latency": 0,
+ "jitter": 0,
+ "survival-time": 0,
+ "exp-data-rate": 0,
+ "payload-size": 0,
+ "traffic-density": 0,
+ "conn-density": 0,
+ "reliability": 99.999,
+ "resource-version": "1581418602494"
+ }
+]
diff --git a/test/apps/nxi_termination/invalid_request.json b/test/apps/nxi_termination/invalid_request.json
new file mode 100644
index 0000000..72eafd7
--- /dev/null
+++ b/test/apps/nxi_termination/invalid_request.json
@@ -0,0 +1,17 @@
+{
+ "requestInfo": {
+ "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "callbackUrl": "http://0.0.0.0:9000/osdfCallback/",
+ "sourceId": "SO",
+ "timeout": 5,
+ "addtnlArgs": {
+ "serviceInstanceId":"cdad9f49-4201-4e3a-aac1-b0f27902c299"
+ }
+ },
+ "type":"NST",
+ "NxIId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "UUID":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "invariantUUID":"d290f1ee-6c54-4b01-90e6-d701748f0851"
+
+}
diff --git a/test/apps/nxi_termination/nsi_success_output.json b/test/apps/nxi_termination/nsi_success_output.json
new file mode 100644
index 0000000..e25a272
--- /dev/null
+++ b/test/apps/nxi_termination/nsi_success_output.json
@@ -0,0 +1,7 @@
+{
+ "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus": "success",
+ "terminateResponse": true,
+ "reason": ""
+} \ No newline at end of file
diff --git a/test/apps/nxi_termination/nssi_failure_output.json b/test/apps/nxi_termination/nssi_failure_output.json
new file mode 100644
index 0000000..f300c53
--- /dev/null
+++ b/test/apps/nxi_termination/nssi_failure_output.json
@@ -0,0 +1,8 @@
+{
+ "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus": "success",
+ "terminateResponse": false,
+ "reason": ""
+
+} \ No newline at end of file
diff --git a/test/apps/nxi_termination/nssi_termination.json b/test/apps/nxi_termination/nssi_termination.json
new file mode 100644
index 0000000..b4e3711
--- /dev/null
+++ b/test/apps/nxi_termination/nssi_termination.json
@@ -0,0 +1,17 @@
+{
+ "requestInfo": {
+ "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "callbackUrl": "http://0.0.0.0:9000/osdfCallback/",
+ "sourceId": "SO",
+ "timeout": 5,
+ "addtnlArgs": {
+ "serviceInstanceId":"4115d3c8-dd59-45d6-b09d-e756dee9b518"
+ }
+ },
+ "type":"NSSI",
+ "NxIId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "UUID":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "invariantUUID":"d290f1ee-6c54-4b01-90e6-d701748f0851"
+
+} \ 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
new file mode 100644
index 0000000..4cce5eb
--- /dev/null
+++ b/test/apps/nxi_termination/nxi_failure_output1.json
@@ -0,0 +1,10 @@
+{
+ "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus": "success",
+ "terminateResponse": false,
+ "reason": ""
+
+}
+
+
diff --git a/test/apps/nxi_termination/nxi_failure_output2.json b/test/apps/nxi_termination/nxi_failure_output2.json
new file mode 100644
index 0000000..f18b73c
--- /dev/null
+++ b/test/apps/nxi_termination/nxi_failure_output2.json
@@ -0,0 +1,7 @@
+{
+ "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus": "success",
+ "terminateResponse": false,
+ "reason": ""
+} \ No newline at end of file
diff --git a/test/apps/nxi_termination/nxi_termination.json b/test/apps/nxi_termination/nxi_termination.json
new file mode 100644
index 0000000..1e25f2e
--- /dev/null
+++ b/test/apps/nxi_termination/nxi_termination.json
@@ -0,0 +1,17 @@
+{
+ "requestInfo": {
+ "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "callbackUrl": "http://0.0.0.0:9000/osdfCallback/",
+ "sourceId": "SO",
+ "timeout": 5,
+ "addtnlArgs": {
+ "serviceInstanceId":"cdad9f49-4201-4e3a-aac1-b0f27902c299"
+ }
+ },
+ "type":"NSI",
+ "NxIId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "UUID":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "invariantUUID":"d290f1ee-6c54-4b01-90e6-d701748f0851"
+
+}
diff --git a/test/apps/nxi_termination/service_profiles.json b/test/apps/nxi_termination/service_profiles.json
new file mode 100644
index 0000000..899acb4
--- /dev/null
+++ b/test/apps/nxi_termination/service_profiles.json
@@ -0,0 +1,23 @@
+[
+ {
+ "profile-id": "cdad9f49-4201-4e3a-aac1-b0f27902c299",
+ "latency": 20,
+ "max-number-of-UEs": 0,
+ "coverage-area-TA-list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "ue-mobility-level": "stationary",
+ "resource-sharing-level": "0",
+ "exp-data-rate-UL": 100,
+ "exp-data-rate-DL": 100,
+ "activity-factor": 0,
+ "e2e-latency": 0,
+ "jitter": 0,
+ "survival-time": 0,
+ "exp-data-rate": 0,
+ "payload-size": 0,
+ "traffic-density": 0,
+ "conn-density": 0,
+ "reliability": 99.999,
+ "resource-version": "1581418602494"
+ }
+]
+
diff --git a/test/apps/nxi_termination/success_relationship_list.json b/test/apps/nxi_termination/success_relationship_list.json
new file mode 100644
index 0000000..608418d
--- /dev/null
+++ b/test/apps/nxi_termination/success_relationship_list.json
@@ -0,0 +1,34 @@
+[
+ {
+ "related-to": "allotted-resource",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v23/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/d88b6ce6-19be-439d-8553-4f9d6cce0494/allotted-resources/allotted-resource/07138106-f535-413b-b002-40ba24f95937",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "cdad9f49-4201-4e3a-aac1-b0f27902c299"
+ },
+ {
+ "relationship-key": "allotted-resource.id",
+ "relationship-value": "07138106-f535-413b-b002-40ba24f95937"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "allotted-resource.description"
+ },
+ {
+ "property-key": "allotted-resource.allotted-resource-name",
+ "property-value": "Allotted_coe"
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/test/apps/nxi_termination/test_fetch_aai_data.py b/test/apps/nxi_termination/test_fetch_aai_data.py
new file mode 100644
index 0000000..241b24b
--- /dev/null
+++ b/test/apps/nxi_termination/test_fetch_aai_data.py
@@ -0,0 +1,70 @@
+# -------------------------------------------------------------------------
+# Copyright (C) 2020 Wipro Limited.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# -------------------------------------------------------------------------
+#
+
+import unittest
+import mock
+from unittest.mock import patch
+from osdf.config.base import osdf_config
+import osdf.config.loader as config_loader
+from osdf.utils.programming_utils import DotDict
+from osdf.utils.interfaces import json_from_file
+from osdf.adapters.aai.fetch_aai_data import get_aai_data,AAIException
+
+class TestRemoteOptProcessor(unittest.TestCase):
+ def setUp(self):
+ self.config_spec = {
+ "deployment": "config/osdf_config.yaml",
+ "core": "config/common_config.yaml"
+ }
+ self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec))
+
+ def tearDown(self):
+
+ patch.stopall()
+
+
+ def test_get_aai_data(self):
+ main_dir = ""
+ response_file = main_dir + 'test/apps/nxi_termination/aai_response.json'
+ exception_response_file = main_dir + 'test/apps/nxi_termination/aai_exception_response.json'
+ request_file = main_dir + 'test/apps/nxi_termination/nxi_termination.json'
+ response_json = json_from_file(response_file)
+ request_json = json_from_file(request_file)
+ exception_json = json_from_file(exception_response_file)
+ response = mock.MagicMock()
+ response.status_code = 200
+ response.ok = True
+ response.json.return_value = response_json
+ self.patcher_req = patch('requests.get',
+ return_value = response)
+ self.Mock_req = self.patcher_req.start()
+ self.assertEquals(response_json, get_aai_data(request_json,osdf_config))
+ self.patcher_req.stop()
+
+ responsenew=mock.MagicMock()
+ responsenew.status_code=404
+ responsenew.json.return_value = exception_json
+ self.patcher_req = patch('requests.get',
+ return_value=responsenew)
+ self.Mock_req = self.patcher_req.start()
+ self.assertRaises( AAIException,get_aai_data,request_json,osdf_config)
+ self.patcher_req.stop()
+
+
+if __name__ == "__main__":
+ unittest.main() \ 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
new file mode 100644
index 0000000..555f2e8
--- /dev/null
+++ b/test/apps/nxi_termination/test_remote_opt_processor_termination.py
@@ -0,0 +1,136 @@
+# -------------------------------------------------------------------------
+# Copyright (C) 2020 Wipro Limited.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# -------------------------------------------------------------------------
+#
+
+import unittest
+from unittest.mock import patch
+import osdf.config.loader as config_loader
+import pytest
+from apps.nxi_termination.optimizers.remote_opt_processor import process_nxi_termination_opt
+from osdf.adapters.aai.fetch_aai_data import AAIException
+
+from osdf.config.base import osdf_config
+from osdf.utils.programming_utils import DotDict
+from osdf.utils.interfaces import json_from_file
+
+class TestRemoteOptProcessor(unittest.TestCase):
+ def setUp(self):
+ self.config_spec = {
+ "deployment": "config/osdf_config.yaml",
+ "core": "config/common_config.yaml"
+ }
+ self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec))
+
+ def tearDown(self):
+
+ patch.stopall()
+
+ def test_process_nxi_termination_opt(self):
+ main_dir = ""
+ request_file = main_dir + 'test/apps/nxi_termination/nxi_termination.json'
+ nssi_request_file=main_dir + 'test/apps/nxi_termination/nssi_termination.json'
+ service_file = main_dir + 'test/apps/nxi_termination/service_profiles.json'
+ failure_service_file = main_dir + 'test/apps/nxi_termination/failure_service_profiles.json'
+ failure_service_file2 = main_dir + 'test/apps/nxi_termination/failure_service_profiles2.json'
+ nsi_success=main_dir + 'test/apps/nxi_termination/nsi_success_output.json'
+ nxi_failure1 = main_dir + 'test/apps/nxi_termination/nxi_failure_output1.json'
+ nxi_failure2 = main_dir + 'test/apps/nxi_termination/nxi_failure_output2.json'
+ nssi_failure = main_dir + 'test/apps/nxi_termination/nssi_failure_output.json'
+ success_rel_file = main_dir + 'test/apps/nxi_termination/success_relationship_list.json'
+ failure_rel_file1 = main_dir + 'test/apps/nxi_termination/failure_relationship_list.json'
+ failure_rel_file2 = main_dir + 'test/apps/nxi_termination/failure_relationship_list2.json'
+ exception_response_file1 = main_dir + 'test/apps/nxi_termination/exception_response1.json'
+ request_json=json_from_file(request_file)
+ nssi_request_json = json_from_file(nssi_request_file)
+ service_profile_json = json_from_file(service_file)
+ failure_service_profile_json = json_from_file(failure_service_file)
+ failure_service_profile_json2 = json_from_file(failure_service_file2)
+ success_rel_json=json_from_file(success_rel_file)
+ failure_rel_json = json_from_file(failure_rel_file1)
+ failure_rel_json2 = json_from_file(failure_rel_file2)
+ success_output_json=json_from_file(nsi_success)
+ nxi_failure_output_json1 = json_from_file(nxi_failure1)
+ nxi_failure_output_json2 = json_from_file(nxi_failure2)
+ nssi_failure_output_json = json_from_file(nssi_failure)
+ exception_response_json1 = json_from_file(exception_response_file1)
+
+ #nsi success scenario
+ self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_allotted_resources', return_value=success_rel_json)
+ 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_allotted_resources', return_value=failure_rel_json)
+ 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_allotted_resources',
+ return_value=[])
+ self.Mock_req = self.patcher_req.start()
+ self.assertEquals(success_output_json, 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_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 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(nssi_failure_output_json, process_nxi_termination_opt(nssi_request_json, osdf_config))
+ self.patcher_req.stop()
+
+ 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(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_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_resource_count',
+ side_effect=AAIException("Error response recieved from AAI for the request"))
+ 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()
+
+ 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/apps/pci_optimization/des_result.json b/test/apps/pci_optimization/des_result.json
new file mode 100644
index 0000000..9209acf
--- /dev/null
+++ b/test/apps/pci_optimization/des_result.json
@@ -0,0 +1,18 @@
+[
+ [
+ {
+ "overallHoAtt": 1300
+ },
+ {
+ "overallHoAtt": 550
+ }
+ ],
+ [
+ {
+ "overallHoAtt": 450
+ },
+ {
+ "overallHoAtt": 400
+ }
+ ]
+]
diff --git a/test/apps/pci_optimization/test_ml_model.py b/test/apps/pci_optimization/test_ml_model.py
new file mode 100644
index 0000000..cf0dee5
--- /dev/null
+++ b/test/apps/pci_optimization/test_ml_model.py
@@ -0,0 +1,87 @@
+# -------------------------------------------------------------------------
+# Copyright (C) 2020 Wipro Limited.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# -------------------------------------------------------------------------
+#
+
+import copy
+from mock import patch
+import unittest
+from apps.pci.optimizers.solver.ml_model import MlModel
+from osdf.adapters.dcae.des import DESException
+import osdf.config.loader as config_loader
+from osdf.utils.interfaces import json_from_file
+from osdf.utils.programming_utils import DotDict
+
+
+class TestMlModel(unittest.TestCase):
+ def setUp(self):
+ self.config_spec = {
+ "deployment": "config/osdf_config.yaml",
+ "core": "config/common_config.yaml"
+ }
+ self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec))
+
+ def tearDown(self):
+ pass
+
+ def test_ml_model(self):
+ des_result_file = 'test/apps/pci_optimization/des_result.json'
+ results = json_from_file(des_result_file)
+
+ dzn_data = {
+ 'NUM_NODES': 4,
+ 'NUM_PCIS': 4,
+ 'NUM_NEIGHBORS': 4,
+ 'NEIGHBORS': [],
+ 'NUM_SECOND_LEVEL_NEIGHBORS': 1,
+ 'SECOND_LEVEL_NEIGHBORS': [],
+ 'PCI_UNCHANGEABLE_CELLS': {},
+ 'ORIGINAL_PCIS': []
+ }
+
+ network_cell_info = {
+ 'cell_list': [
+ {
+ 'cell_id': 'Chn0001',
+ 'id': 1,
+ 'nbr_list': []
+ },
+ {
+ 'cell_id': 'Chn0002',
+ 'id': 2,
+ 'nbr_list': []
+ }
+ ]
+ }
+ self.patcher_req = patch('osdf.adapters.dcae.des.extract_data', side_effect=results)
+ self.Mock_req = self.patcher_req.start()
+ mlmodel = MlModel()
+ mlmodel.get_additional_inputs(dzn_data, network_cell_info)
+ self.assertEqual({1}, dzn_data['PCI_UNCHANGEABLE_CELLS'])
+ self.patcher_req.stop()
+
+ dzn_data['PCI_UNCHANGEABLE_CELLS'] = []
+ self.patcher_req = patch('osdf.adapters.dcae.des.extract_data', side_effect=DESException('error'))
+ self.Mock_req = self.patcher_req.start()
+ mlmodel.get_additional_inputs(dzn_data, network_cell_info)
+ self.assertEqual(set() , dzn_data['PCI_UNCHANGEABLE_CELLS'])
+ self.patcher_req.stop()
+
+ self.patcher_req = patch('osdf.adapters.dcae.des.extract_data', return_value=[])
+ self.Mock_req = self.patcher_req.start()
+ mlmodel.get_additional_inputs(dzn_data, network_cell_info)
+ self.assertEqual(set() , dzn_data['PCI_UNCHANGEABLE_CELLS'])
+ self.patcher_req.stop()
diff --git a/test/apps/slice_selection/conductor_error_response.json b/test/apps/slice_selection/conductor_error_response.json
new file mode 100644
index 0000000..95a9750
--- /dev/null
+++ b/test/apps/slice_selection/conductor_error_response.json
@@ -0,0 +1,18 @@
+{
+ "plans": [
+ {
+ "status": "error",
+ "message": "Some error message",
+ "name": "Plan Name 1",
+ "links": [
+ [
+ {
+ "href": "http://conductor:8091/v1/plans/plan_id",
+ "rel": "self"
+ }
+ ]
+ ],
+ "id": "plan_id"
+ }
+ ]
+}
diff --git a/test/apps/slice_selection/new_solution_conductor_response.json b/test/apps/slice_selection/new_solution_conductor_response.json
new file mode 100644
index 0000000..897aa2b
--- /dev/null
+++ b/test/apps/slice_selection/new_solution_conductor_response.json
@@ -0,0 +1,47 @@
+{
+ "plans":[
+ {
+ "status":"done",
+ "id":"plan_id",
+ "name":"Plan Name 1",
+ "links":[
+ [
+ {
+ "href":"http://conductor:8091/v1/plans/plan_id",
+ "rel":"self"
+ }
+ ]
+ ],
+ "recommendations":[
+ {
+ "embb-nst":{
+ "inventory_provider":"generator",
+ "candidate": {
+ "candidate_id":"1a636c4d-5e76-427e-bfd6-241a947224b0",
+ "latency":20,
+ "inventory_provider":"generator",
+ "max_number_of_ues":100,
+ "ue_mobility_level":"stationary",
+ "candidate_type":"slice_profiles",
+ "resource_sharing_level":"shared",
+ "inventory_type":"slice_profiles",
+ "reliability": 99.99,
+ "AN_latency": 10,
+ "AN_ue_mobility_level": "stationary",
+ "AN_max_number_of_ues": 100,
+ "AN_reliability": 99.99,
+ "AN_resource_sharing_level":"shared",
+ "CN_latency": 5,
+ "CN_reliability": 99.99,
+ "CN_resource_sharing_level":"shared",
+ "TN-BH_reliability": 99.99,
+ "TN-BH_latency": 5,
+ "TN-BH_resource_sharing_level":"shared",
+ "cost":1.0
+ }
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/test/apps/slice_selection/new_solution_nsi_response.json b/test/apps/slice_selection/new_solution_nsi_response.json
new file mode 100644
index 0000000..52624b6
--- /dev/null
+++ b/test/apps/slice_selection/new_solution_nsi_response.json
@@ -0,0 +1,35 @@
+{
+ "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus": "completed",
+ "statusMessage": "",
+ "solutions": [
+ {
+ "existingNSI": false,
+ "newNSISolution": {
+ "sliceProfiles": [
+ {
+ "domainType": "AN",
+ "resourceSharingLevel": "shared",
+ "latency": 10,
+ "reliability": 99.99,
+ "uEMobilityLevel": "stationary",
+ "maxNumberofUEs": 100
+ },
+ {
+ "domainType": "CN",
+ "resourceSharingLevel": "shared",
+ "latency": 5,
+ "reliability": 99.99
+ },
+ {
+ "domainType": "TN-BH",
+ "resourceSharingLevel": "shared",
+ "latency": 5,
+ "reliability": 99.99
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/test/apps/slice_selection/no_rec.json b/test/apps/slice_selection/no_rec.json
new file mode 100644
index 0000000..855afac
--- /dev/null
+++ b/test/apps/slice_selection/no_rec.json
@@ -0,0 +1,18 @@
+{
+ "plans": [
+ {
+ "id": "d8c07237-5f66-4aa6-871c-a04221d99458",
+ "links": [
+ [
+ {
+ "href": "https://oof-has-api:8091/v1/plans/d8c07237-5f66-4aa6-871c-a04221d99458",
+ "rel": "self"
+ }
+ ]
+ ],
+ "message": "Plan d8c07237-5f66-4aa6-871c-a04221d99458 search failed, no recommendations found by machine dev-oof-has-solver-65d478b6d-ql5fp",
+ "name": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "status": "not found"
+ }
+ ]
+}
diff --git a/test/apps/slice_selection/no_recomm_conductor_response.json b/test/apps/slice_selection/no_recomm_conductor_response.json
new file mode 100644
index 0000000..f23af87
--- /dev/null
+++ b/test/apps/slice_selection/no_recomm_conductor_response.json
@@ -0,0 +1,18 @@
+{
+ "plans":[
+ {
+ "status":"done",
+ "id":"plan_id",
+ "name":"Plan Name 1",
+ "links":[
+ [
+ {
+ "href":"http://conductor:8091/v1/plans/plan_id",
+ "rel":"self"
+ }
+ ]
+ ],
+ "recommendations": []
+ }
+ ]
+}
diff --git a/test/apps/slice_selection/no_recomm_nsi_response.json b/test/apps/slice_selection/no_recomm_nsi_response.json
new file mode 100644
index 0000000..e36a243
--- /dev/null
+++ b/test/apps/slice_selection/no_recomm_nsi_response.json
@@ -0,0 +1,7 @@
+{
+ "requestId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus":"completed",
+ "statusMessage":"",
+ "solutions": []
+}
diff --git a/test/apps/slice_selection/nsi_error_response.json b/test/apps/slice_selection/nsi_error_response.json
new file mode 100644
index 0000000..9dc5300
--- /dev/null
+++ b/test/apps/slice_selection/nsi_error_response.json
@@ -0,0 +1,6 @@
+{
+ "requestId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus":"error",
+ "statusMessage":"Some error message"
+}
diff --git a/test/apps/slice_selection/nsi_request.json b/test/apps/slice_selection/nsi_request.json
new file mode 100644
index 0000000..72b2c8b
--- /dev/null
+++ b/test/apps/slice_selection/nsi_request.json
@@ -0,0 +1,31 @@
+{
+ "serviceProfile": {
+ "latency": 2,
+ "security": "High",
+ "reliability": 99.9999,
+ "trafficDensity": 1,
+ "connDensity": 100000,
+ "expDataRate": 50,
+ "jitter": 1,
+ "survivalTime": 0,
+ "resourceSharingLevel":"shared"
+ },
+ "serviceInfo":{
+ "serviceInstanceId": "209fb01e-60ca-4325-b074-c5ad4e0499f8",
+ "serviceName": ""
+ },
+ "requestInfo": {
+ "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "callbackUrl": "http://0.0.0.0:9000/osdfCallback/",
+ "sourceId": "SO",
+ "timeout": 5
+ },
+ "NSTInfoList": [
+ {
+ "modelInvariantId": "fda3c1e8-7653-4acd-80ef-f5755c1d3859",
+ "modelVersionId": "a6906768-1cae-4e78-acd1-d753ac61f3e8",
+ "modelName": "URLLC_1"
+ }
+ ]
+}
diff --git a/test/apps/slice_selection/nsi_selection_invalid_request.json b/test/apps/slice_selection/nsi_selection_invalid_request.json
new file mode 100644
index 0000000..3ecd1e3
--- /dev/null
+++ b/test/apps/slice_selection/nsi_selection_invalid_request.json
@@ -0,0 +1,80 @@
+{
+ "serviceProfile": {
+ "latency": 2,
+ "security": "High",
+ "reliability": 99.9999,
+ "trafficDensity": 1,
+ "connDensity": 100000,
+ "expDataRate": 50,
+ "jitter": 1,
+ "survivalTime": 0,
+ "resourceSharingLevel":"shared"
+ },
+ "requestInfo": {
+ "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "callbackUrl": "http://0.0.0.0:9000/osdfCallback/",
+ "sourceId": "SO",
+ "timeout": 5
+ },
+ "NSSTInfo":[
+ {
+ "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa2",
+ "invariantUUID":"2fa85f64-5717-4562-b3fc-2c963f66afa6",
+ "name":"embb-an-nf"
+ },
+ {
+ "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa3",
+ "invariantUUID":"4fa85f64-5717-4562-b3fc-2c963f66afa6",
+ "name":"embb-cn"
+ },
+ {
+ "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa4",
+ "invariantUUID":"5ta85f64-5717-4562-b3fc-2c963f66afa6",
+ "name":"embb-tn-fh"
+ },
+ {
+ "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa5",
+ "invariantUUID":"6ya85f64-5717-4562-b3fc-2c963f66afa6",
+ "name":"embb-tn-mh"
+ },
+ {
+ "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa7",
+ "invariantUUID":"7ua85f64-5717-4562-b3fc-2c963f66afa6",
+ "name":"embb-tn-bh"
+ }
+ ],
+ "preferReuse":true,
+ "subnetCapabilities":[
+ {
+ "domainType":"AN-NF",
+ "capabilityDetails":{
+ "blob":"content"
+ }
+ },
+ {
+ "domainType":"CN",
+ "capabilityDetails":{
+ "blob":"content"
+ }
+ },
+ {
+ "domainType":"TN-FH",
+ "capabilityDetails":{
+ "blob":"content"
+ }
+ },
+ {
+ "domainType":"TN-MH",
+ "capabilityDetails":{
+ "blob":"content"
+ }
+ },
+ {
+ "domainType":"TN-BH",
+ "capabilityDetails":{
+ "blob":"content"
+ }
+ }
+ ]
+}
diff --git a/test/apps/slice_selection/nsi_selection_request.json b/test/apps/slice_selection/nsi_selection_request.json
new file mode 100644
index 0000000..39fb925
--- /dev/null
+++ b/test/apps/slice_selection/nsi_selection_request.json
@@ -0,0 +1,84 @@
+{
+ "serviceProfile":{
+ "latency":5,
+ "security":"High",
+ "reliability":99.999,
+ "resourceSharingLevel":"shared"
+ },
+ "requestInfo":{
+ "transactionId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "callbackUrl": "http://0.0.0.0:9000/osdfCallback/",
+ "callbackHeader":{
+ "blob":"content"
+ },
+ "sourceId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "timeout":5,
+ "numSolutions":1
+ },
+ "NSTInfo":{
+ "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa1",
+ "invariantUUID":"7ua85f64-5717-4562-b3fc-2c963f66afa6",
+ "name":"embb-nst"
+ },
+ "NSSTInfo":[
+ {
+ "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa2",
+ "invariantUUID":"2fa85f64-5717-4562-b3fc-2c963f66afa6",
+ "name":"embb-an-nf"
+ },
+ {
+ "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa3",
+ "invariantUUID":"4fa85f64-5717-4562-b3fc-2c963f66afa6",
+ "name":"embb-cn"
+ },
+ {
+ "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa4",
+ "invariantUUID":"5ta85f64-5717-4562-b3fc-2c963f66afa6",
+ "name":"embb-tn-fh"
+ },
+ {
+ "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa5",
+ "invariantUUID":"6ya85f64-5717-4562-b3fc-2c963f66afa6",
+ "name":"embb-tn-mh"
+ },
+ {
+ "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa7",
+ "invariantUUID":"7ua85f64-5717-4562-b3fc-2c963f66afa6",
+ "name":"embb-tn-bh"
+ }
+ ],
+ "preferReuse":false,
+ "subnetCapabilities":[
+ {
+ "domainType":"AN",
+ "capabilityDetails":{
+ "latency": "4",
+ "reliability": "99.9",
+ "maxNumberofUEs": "10",
+ "maxThroughput": "50",
+ "termDensity": "60"
+ }
+ },
+ {
+ "domainType":"CN",
+ "capabilityDetails":{
+ "latency": "3",
+ "reliability": "99.9",
+ "maxNumberofUEs": "10",
+ "maxThroughput": "50",
+ "termDensity": "60"
+ }
+ },
+ {
+ "domainType":"TN-BH",
+ "capabilityDetails":{
+ "latency": "2",
+ "reliability": "99.9",
+ "maxNumberofUEs": "10",
+ "maxThroughput": "50",
+ "termDensity": "60"
+ }
+ }
+ ]
+}
diff --git a/test/apps/slice_selection/nssi_conductor_response.json b/test/apps/slice_selection/nssi_conductor_response.json
new file mode 100644
index 0000000..d2edcf5
--- /dev/null
+++ b/test/apps/slice_selection/nssi_conductor_response.json
@@ -0,0 +1,53 @@
+{
+ "plans":[
+ {
+ "status":"done",
+ "id":"plan_id",
+ "name":"Plan Name 1",
+ "links":[
+ [
+ {
+ "href":"http://conductor:8091/v1/plans/plan_id",
+ "rel":"self"
+ }
+ ]
+ ],
+ "recommendations":[
+ {
+ "embb-cn": {
+ "inventory_provider": "aai",
+ "candidate": {
+ "exp_data_rate": 0,
+ "conn_density": 0,
+ "coverage_area_ta_list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "activity_factor": 0,
+ "cs_availability": null,
+ "candidate_id": "1a636c4d-5e76-427e-bfd6-241a947224b0",
+ "area_traffic_cap_dl": null,
+ "latency": 20,
+ "service_area_dimension": null,
+ "e2e_latency": 0,
+ "area_traffic_cap_ul": null,
+ "inventory_provider": "aai",
+ "exp_data_rate_ul": 100,
+ "max_number_of_ues": 0,
+ "ue_mobility_level": "stationary",
+ "candidate_type": "nssi",
+ "traffic_density": 0,
+ "payload_size": 0,
+ "exp_data_rate_dl": 100,
+ "jitter": 0,
+ "survival_time": 0,
+ "resource_sharing_level": "shared",
+ "inventory_type": "nssi",
+ "reliability": null,
+ "cost": 1.0,
+ "instance_id": "e1041cdc-12da-4f36-b84e-68c380e9cd47",
+ "instance_name": "nssi_test_0211"
+ }
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/test/apps/slice_selection/nssi_error_response.json b/test/apps/slice_selection/nssi_error_response.json
new file mode 100644
index 0000000..70e0596
--- /dev/null
+++ b/test/apps/slice_selection/nssi_error_response.json
@@ -0,0 +1,7 @@
+{
+ "requestId":"r450f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId":"t670f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus":"completed",
+ "statusMessage":"",
+ "solutions": []
+}
diff --git a/test/apps/slice_selection/nssi_selection_invalid_request.json b/test/apps/slice_selection/nssi_selection_invalid_request.json
new file mode 100644
index 0000000..57e0184
--- /dev/null
+++ b/test/apps/slice_selection/nssi_selection_invalid_request.json
@@ -0,0 +1,23 @@
+{
+ "sliceProfile": {
+ "blob": "content"
+ },
+ "requestInfo": {
+ "transactionId": "t670f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestId": "r450f1ee-6c54-4b01-90e6-d701748f0851",
+ "callbackUrl": "http://0.0.0.0:9000/osdfCallback/",
+ "callbackHeader": {
+ "blob": "content"
+ },
+ "sourceId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "timeout": 5,
+ "numSolutions": 1,
+ "addtnlArgs": {
+ "blob": "content"
+ }
+ },
+ "NSSTInfo": {
+ "UUID": "y7785f64-5717-4562-b3fc-2c963f66afa6",
+ "name": "embb-cn"
+ }
+}
diff --git a/test/apps/slice_selection/nssi_selection_request.json b/test/apps/slice_selection/nssi_selection_request.json
new file mode 100644
index 0000000..61ee563
--- /dev/null
+++ b/test/apps/slice_selection/nssi_selection_request.json
@@ -0,0 +1,27 @@
+{
+ "sliceProfile": {
+ "latency":5,
+ "security":"High",
+ "reliability":99.999,
+ "resourceSharingLevel":"shared"
+ },
+ "requestInfo": {
+ "transactionId": "t670f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestId": "r450f1ee-6c54-4b01-90e6-d701748f0851",
+ "callbackUrl": "http://0.0.0.0:9000/osdfCallback/",
+ "callbackHeader": {
+ "blob": "content"
+ },
+ "sourceId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "timeout": 5,
+ "numSolutions": 1,
+ "addtnlArgs": {
+ "blob": "content"
+ }
+ },
+ "NSSTInfo": {
+ "UUID": "a7785f64-5717-4562-b3fc-2c963f66afa6",
+ "invariantUUID": "9fh85f64-5717-4562-b3fc-2c963f66afa6",
+ "name": "embb-cn"
+ }
+}
diff --git a/test/apps/slice_selection/shared_solution_conductor_response.json b/test/apps/slice_selection/shared_solution_conductor_response.json
new file mode 100644
index 0000000..a187fef
--- /dev/null
+++ b/test/apps/slice_selection/shared_solution_conductor_response.json
@@ -0,0 +1,53 @@
+{
+ "plans":[
+ {
+ "status":"done",
+ "id":"plan_id",
+ "name":"Plan Name 1",
+ "links":[
+ [
+ {
+ "href":"http://conductor:8091/v1/plans/plan_id",
+ "rel":"self"
+ }
+ ]
+ ],
+ "recommendations":[
+ {
+ "embb-nst": {
+ "inventory_provider": "aai",
+ "candidate": {
+ "exp_data_rate": 0,
+ "conn_density": 0,
+ "coverage_area_ta_list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "activity_factor": 0,
+ "cs_availability": null,
+ "candidate_id": "1a636c4d-5e76-427e-bfd6-241a947224b0",
+ "area_traffic_cap_dl": null,
+ "latency": 20,
+ "service_area_dimension": null,
+ "e2e_latency": 0,
+ "area_traffic_cap_ul": null,
+ "inventory_provider": "aai",
+ "exp_data_rate_ul": 100,
+ "max_number_of_ues": 0,
+ "ue_mobility_level": "stationary",
+ "candidate_type": "nsi",
+ "traffic_density": 0,
+ "payload_size": 0,
+ "exp_data_rate_dl": 100,
+ "jitter": 0,
+ "survival_time": 0,
+ "resource_sharing_level": "shared",
+ "inventory_type": "nsi",
+ "reliability": null,
+ "cost": 1.0,
+ "instance_id": "f1041cdc-12da-4f36-b84e-68c380e9cd47",
+ "instance_name": "nsi_test_0211"
+ }
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/test/apps/slice_selection/shared_solution_nsi_response.json b/test/apps/slice_selection/shared_solution_nsi_response.json
new file mode 100644
index 0000000..ff83dfc
--- /dev/null
+++ b/test/apps/slice_selection/shared_solution_nsi_response.json
@@ -0,0 +1,17 @@
+{
+ "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus": "completed",
+ "solutions": [
+ {
+ "existingNSI": true,
+ "sharedNSISolution": {
+ "UUID": "3fa85f64-5717-4562-b3fc-2c963f66afa1",
+ "invariantUUID": "7ua85f64-5717-4562-b3fc-2c963f66afa6",
+ "NSIName": "nsi_test_0211",
+ "NSIId": "f1041cdc-12da-4f36-b84e-68c380e9cd47"
+ }
+ }
+ ],
+ "statusMessage": "",
+ "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851"
+}
diff --git a/test/apps/slice_selection/shared_solution_nssi_response.json b/test/apps/slice_selection/shared_solution_nssi_response.json
new file mode 100644
index 0000000..f3468a4
--- /dev/null
+++ b/test/apps/slice_selection/shared_solution_nssi_response.json
@@ -0,0 +1,15 @@
+{
+ "requestId": "r450f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus": "completed",
+ "solutions": [
+ {
+ "UUID": "a7785f64-5717-4562-b3fc-2c963f66afa6",
+ "invariantUUID": "9fh85f64-5717-4562-b3fc-2c963f66afa6",
+ "NSSIName": "nssi_test_0211",
+ "NSSIId": "e1041cdc-12da-4f36-b84e-68c380e9cd47"
+
+ }
+ ],
+ "statusMessage": "",
+ "transactionId": "t670f1ee-6c54-4b01-90e6-d701748f0851"
+}
diff --git a/test/apps/slice_selection/slice_policies.txt b/test/apps/slice_selection/slice_policies.txt
new file mode 100644
index 0000000..7eb55de
--- /dev/null
+++ b/test/apps/slice_selection/slice_policies.txt
@@ -0,0 +1,5 @@
+query_policy_nsi.json
+threshold_policy_nsi.json
+vnf_policy_nsi_shared_case.json
+opt_policy_nsi_reuse.json
+
diff --git a/test/apps/slice_selection/subnet_policies.txt b/test/apps/slice_selection/subnet_policies.txt
new file mode 100644
index 0000000..649672d
--- /dev/null
+++ b/test/apps/slice_selection/subnet_policies.txt
@@ -0,0 +1,5 @@
+query_policy_nsi.json
+threshold_policy_nsi.json
+vnf_policy_nssi_shared.json
+opt_policy_nssi.json
+
diff --git a/test/apps/slice_selection/test_remote_opt_processor.py b/test/apps/slice_selection/test_remote_opt_processor.py
new file mode 100644
index 0000000..7c2d191
--- /dev/null
+++ b/test/apps/slice_selection/test_remote_opt_processor.py
@@ -0,0 +1,165 @@
+# -------------------------------------------------------------------------
+# Copyright (C) 2020 Wipro Limited.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# -------------------------------------------------------------------------
+#
+
+import json
+import unittest
+from requests import RequestException, Response
+
+from apps.slice_selection.optimizers.conductor.remote_opt_processor import SliceSelectionOptimizer
+from osdf.adapters.local_data import local_policies
+from osdf.utils.interfaces import json_from_file, yaml_from_file
+from osdf.utils.programming_utils import DotDict
+import osdf.config.loader as config_loader
+from mock import patch, MagicMock
+import json
+from osdf.logging.osdf_logging import error_log, debug_log
+from osdf.adapters.policy.interface import get_policies
+
+
+class TestRemoteOptProcessor(unittest.TestCase):
+ def setUp(self):
+ self.config_spec = {
+ "deployment": "config/osdf_config.yaml",
+ "core": "config/common_config.yaml"
+ }
+ slice_spec = "config/slicing_config.yaml"
+ self.slice_config = config_loader.load_config_file(slice_spec)
+ self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec))
+ self.patcher_RestClient = patch(
+ 'osdf.utils.interfaces.RestClient.request', return_value=MagicMock())
+ self.mock_rc = self.patcher_RestClient.start()
+
+ def tearDown(self):
+ patch.stopall()
+
+ def test_process_nsi_selection_opt(self):
+ main_dir = ""
+ request_file = main_dir + 'test/apps/slice_selection/nsi_selection_request.json'
+ not_shared_request_file = main_dir + 'test/apps/slice_selection/not_shared_nsi_request.json'
+ #response files
+ new_solution_response_file = main_dir + 'test/apps/slice_selection/new_solution_nsi_response.json'
+ shared_solution_response_file = main_dir + 'test/apps/slice_selection/shared_solution_nsi_response.json'
+ no_solution_response_file = main_dir + 'test/apps/slice_selection/no_recomm_nsi_response.json'
+ error_response_file = main_dir + 'test/apps/slice_selection/nsi_error_response.json'
+
+ request_json = json_from_file(request_file)
+ new_solution_response_json = json_from_file(new_solution_response_file)
+ shared_solution_response_json = json_from_file(shared_solution_response_file)
+ no_solution_response_json = json_from_file(no_solution_response_file)
+ error_response_json = json_from_file(error_response_file)
+
+ policies_path = main_dir + 'test/policy-local-files/slice-selection-files'
+ slice_policies_file = main_dir + 'test/apps/slice_selection/slice_policies.txt'
+
+ valid_policies_files = local_policies.get_policy_names_from_file(slice_policies_file)
+ policies = [json_from_file(policies_path + '/' + name) for name in valid_policies_files]
+ self.patcher_get_policies = patch('osdf.adapters.policy.interface.remote_api',
+ return_value=policies)
+ self.Mock_get_policies = self.patcher_get_policies.start()
+
+ # new solution
+ new_solution_conductor_response_file = 'test/apps/slice_selection/new_solution_conductor_response.json'
+ new_solution_conductor_response = json_from_file(new_solution_conductor_response_file)
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ return_value=new_solution_conductor_response)
+ self.Mock_req = self.patcher_req.start()
+ slice_select_opt = SliceSelectionOptimizer(self.osdf_config, self.slice_config, request_json, 'NSI')
+ slice_select_opt.process_slice_selection_opt()
+ self.mock_rc.assert_called_with(json=new_solution_response_json, noresponse=True)
+ self.patcher_req.stop()
+
+ # shared solution
+ request_json['preferReuse'] = True
+ shared_solution_conductor_response_file = 'test/apps/slice_selection/shared_solution_conductor_response.json'
+ shared_solution_conductor_response = json_from_file(shared_solution_conductor_response_file)
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ return_value=shared_solution_conductor_response)
+ self.Mock_req = self.patcher_req.start()
+ slice_select_opt = SliceSelectionOptimizer(self.osdf_config, self.slice_config, request_json, 'NSI')
+ slice_select_opt.process_slice_selection_opt()
+ self.mock_rc.assert_called_with(json=shared_solution_response_json, noresponse=True)
+ self.patcher_req.stop()
+
+ # no recommendation
+ no_solution_conductor_response_file = 'test/apps/slice_selection/no_rec.json'
+ no_solution_conductor_response = json_from_file(no_solution_conductor_response_file)
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ return_value=no_solution_conductor_response)
+ self.Mock_req = self.patcher_req.start()
+ slice_select_opt.process_slice_selection_opt()
+ self.mock_rc.assert_called_with(json=no_solution_response_json, noresponse=True)
+ self.patcher_req.stop()
+
+ # Exception
+ conductor_error_response_file = 'test/apps/slice_selection/conductor_error_response.json'
+ conductor_error_response = json_from_file(conductor_error_response_file)
+
+ response = Response()
+ response._content = json.dumps(conductor_error_response).encode()
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ side_effect=RequestException(response=response))
+ self.Mock_req = self.patcher_req.start()
+ slice_select_opt.process_slice_selection_opt()
+ self.mock_rc.assert_called_with(json=error_response_json, noresponse=True)
+ self.patcher_req.stop()
+
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ side_effect=Exception("Some error message"))
+ self.Mock_req = self.patcher_req.start()
+ slice_select_opt.process_slice_selection_opt()
+ self.mock_rc.assert_called_with(json=error_response_json, noresponse=True)
+ self.patcher_req.stop()
+
+ def test_process_nssi_selection_opt(self):
+ main_dir = ""
+ request_file = main_dir + 'test/apps/slice_selection/nssi_selection_request.json'
+ # response files
+ shared_solution_response_file = main_dir + 'test/apps/slice_selection/shared_solution_nssi_response.json'
+ error_response_file = main_dir + 'test/apps/slice_selection/nssi_error_response.json'
+
+ request_json = json_from_file(request_file)
+ shared_solution_response_json = json_from_file(shared_solution_response_file)
+ error_response_json = json_from_file(error_response_file)
+
+ policies_path = main_dir + 'test/policy-local-files/slice-selection-files'
+ slice_policies_file = main_dir + 'test/apps/slice_selection/subnet_policies.txt'
+
+ valid_policies_files = local_policies.get_policy_names_from_file(slice_policies_file)
+ policies = [json_from_file(policies_path + '/' + name) for name in valid_policies_files]
+ self.patcher_get_policies = patch('osdf.adapters.policy.interface.remote_api',
+ return_value=policies)
+ self.Mock_get_policies = self.patcher_get_policies.start()
+
+ shared_solution_conductor_response_file = 'test/apps/slice_selection/nssi_conductor_response.json'
+ shared_solution_conductor_response = json_from_file(shared_solution_conductor_response_file)
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ return_value=shared_solution_conductor_response)
+ self.Mock_req = self.patcher_req.start()
+ slice_select_opt = SliceSelectionOptimizer(self.osdf_config, self.slice_config, request_json, 'NSSI')
+ slice_select_opt.process_slice_selection_opt()
+ self.mock_rc.assert_called_with(json=shared_solution_response_json, noresponse=True)
+ self.patcher_req.stop()
+
+ request_json['sliceProfile']['resourceSharingLevel'] = "not-shared"
+ slice_select_opt = SliceSelectionOptimizer(self.osdf_config, self.slice_config, request_json, 'NSSI')
+ slice_select_opt.process_slice_selection_opt()
+ self.mock_rc.assert_called_with(json=error_response_json, noresponse=True)
+
+
+if __name__ == "__main__":
+ unittest.main()