summaryrefslogtreecommitdiffstats
path: root/conductor
diff options
context:
space:
mode:
authorkrishnaa96 <krishna.moorthy6@wipro.com>2020-10-23 13:33:29 +0530
committerkrishnaa96 <krishna.moorthy6@wipro.com>2020-10-23 13:37:45 +0530
commit1b5963e491b665ecb99b8e42a116df4f452be50f (patch)
tree0fe3ccb05133b11d3ea6717db3744047dc304bec /conductor
parentb8ce22681bdff529644bbfaa40ed8c18370d685d (diff)
Run AAISIM using mountebank
Mountebank is an over the wire test double. (http://www.mbtest.org/) The AAI api for NSI and NSSI are the same. This makes it difficult to create stub using exisiting web server(web.py). So, lets move aaisim to more flexible mock server Issue-ID: OPTFRA-865 Signed-off-by: krishnaa96 <krishna.moorthy6@wipro.com> Change-Id: I77c48fa3e491b3f73d1d5454625ffa27200f4751
Diffstat (limited to 'conductor')
-rw-r--r--conductor/conductor/tests/functional/simulators/aaisim/aai_imposter.jsont156
-rw-r--r--conductor/conductor/tests/functional/simulators/aaisim/responses/get_nsi_response.json84
-rw-r--r--conductor/conductor/tests/functional/simulators/aaisim/responses/get_nssi_response.json5
-rw-r--r--conductor/conductor/tests/functional/simulators/imposter.py24
-rwxr-xr-xconductor/conductor/tests/functional/simulators/run_aaisim.sh12
5 files changed, 278 insertions, 3 deletions
diff --git a/conductor/conductor/tests/functional/simulators/aaisim/aai_imposter.jsont b/conductor/conductor/tests/functional/simulators/aaisim/aai_imposter.jsont
new file mode 100644
index 0000000..93799cd
--- /dev/null
+++ b/conductor/conductor/tests/functional/simulators/aaisim/aai_imposter.jsont
@@ -0,0 +1,156 @@
+{
+ "port": 8081,
+ "protocol": "http",
+ "stubs": [{
+ "responses": [
+ { "is": {
+ "statusCode": 200,
+ "body": {{ get_nsi_response }}
+ }
+ }
+ ],
+ "predicates": [{
+ "and": [
+ {
+ "equals": {
+ "path": "/aai/v14/nodes/service-instances",
+ "method": "GET",
+ "query": {
+ "model-version-id": "bfba363e-e39c-4bd9-a9d5-1371c28f4d22",
+ "model-invariant-id": "21d57d4b-52ad-4d3c-a798-248b5bb9124a",
+ "depth": 2
+ }
+ }
+ }
+ ]
+ }]
+ },
+ {
+ "responses": [
+ { "is": {
+ "statusCode": 200,
+ "body": {{ get_nssi_response }}
+ }
+ }
+ ],
+ "predicates": [{
+ "and": [
+ {
+ "equals": {
+ "path": "/aai/v14/nodes/service-instances",
+ "method": "GET",
+ "query": {
+ "model-version-id": "8d770214-d3e7-43ea-b7a6-9b235dcbcd34",
+ "model-invariant-id": "c343a533-c045-4ec0-bbb6-f30eb8eb5a41",
+ "depth": 2
+ }
+ }
+ }
+ ]
+ }]
+ },
+ {
+ "responses": [
+ { "is": {
+ "statusCode": 200,
+ "body": {{ healthcheck }}
+ }
+ }
+ ],
+ "predicates": [{
+ "and": [
+ {
+ "equals": {
+ "path": "/healthcheck",
+ "method": "GET"
+ }
+ }
+ ]
+ }]
+ },
+ {
+ "responses": [
+ { "is": {
+ "statusCode": 200,
+ "body": {{ get_onap_regions }}
+ }
+ }
+ ],
+ "predicates": [{
+ "and": [
+ {
+ "equals": {
+ "path": "/aai/v14/cloud-infrastructure/cloud-regions/",
+ "method": "GET"
+ }
+ }
+ ]
+ }]
+ },
+ {
+ "responses": [
+ { "is": {
+ "statusCode": 200,
+ "body": {{ get_onap_complex_DLLSTX233 }}
+ }
+ }
+ ],
+ "predicates": [{
+ "and": [
+ {
+ "equals": {
+ "path": "/aai/v14/cloud-infrastructure/complexes/complex/DLLSTX233",
+ "method": "GET"
+ }
+ }
+ ]
+ }]
+ },
+ {
+ "responses": [
+ { "is": {
+ "statusCode": 200,
+ "body": {{ get_flavors_cloud_region_1 }}
+ }
+ }
+ ],
+ "predicates": [{
+ "and": [
+ {
+ "equals": {
+ "path": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/HPA-cloud/cloud-region-1/flavors/",
+ "method": "GET"
+ }
+ }
+ ]
+ }]
+ },
+ {
+ "responses": [
+ { "is": {
+ "statusCode": 200,
+ "body": {{ get_flavors_cloud_region_2 }}
+ }
+ }
+ ],
+ "predicates": [{
+ "and": [
+ {
+ "equals": {
+ "path": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/HPA-cloud/cloud-region-2/flavors/",
+ "method": "GET"
+ }
+ }
+ ]
+ }]
+ },
+ {
+ "responses": [
+ { "is": {
+ "statusCode": 404,
+ "body": "Not found"
+ }
+ }
+ ]
+ }]
+}
diff --git a/conductor/conductor/tests/functional/simulators/aaisim/responses/get_nsi_response.json b/conductor/conductor/tests/functional/simulators/aaisim/responses/get_nsi_response.json
new file mode 100644
index 0000000..3d3f080
--- /dev/null
+++ b/conductor/conductor/tests/functional/simulators/aaisim/responses/get_nsi_response.json
@@ -0,0 +1,84 @@
+{"service-instance": [{
+ "service-instance-id": "1a636c4d-5e76-427e-bfd6-241a947224b0",
+ "service-instance-name": "nsi_test_0211",
+ "service-type": "embb",
+ "service-role": "nsi",
+ "service-function": "shared",
+ "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": "csi_test_0211"
+ }
+ ]
+ }
+ ]
+ },
+ "service-profiles": {
+ "service-profile": [
+ {
+ "profile-id": "cdad9f49-4201-4e3a-aac1-b0f27902c299",
+ "latency": 20,
+ "max-number-of-UEs": 0,
+ "coverage-area-TA-list": "Chennai",
+ "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": "fe579f49-4201-4e3a-aac1-b0f27902c276",
+ "latency": 17,
+ "max-number-of-UEs": 0,
+ "coverage-area-TA-list": "Chennai",
+ "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/conductor/conductor/tests/functional/simulators/aaisim/responses/get_nssi_response.json b/conductor/conductor/tests/functional/simulators/aaisim/responses/get_nssi_response.json
index b7ef43b..0e00ca3 100644
--- a/conductor/conductor/tests/functional/simulators/aaisim/responses/get_nssi_response.json
+++ b/conductor/conductor/tests/functional/simulators/aaisim/responses/get_nssi_response.json
@@ -3,7 +3,8 @@
"service-instance-name": "nssi_test_0211",
"service-type": "embb",
"service-role": "nssi",
- "environment-context": "cn",
+ "service-function": "shared",
+ "workload-context": "cn",
"model-invariant-id": "21d57d4b-52ad-4d3c-a798-248b5bb9124a",
"model-version-id": "bfba363e-e39c-4bd9-a9d5-1371c28f4d22",
"resource-version": "1581418601616",
@@ -43,7 +44,7 @@
"profile-id": "cdad9f49-4201-4e3a-aac1-b0f27902c299",
"latency": 20,
"max-number-of-UEs": 0,
- "coverage-area-TA-list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "coverage-area-TA-list": "Chennai",
"ue-mobility-level": "stationary",
"resource-sharing-level": "0",
"exp-data-rate-UL": 100,
diff --git a/conductor/conductor/tests/functional/simulators/imposter.py b/conductor/conductor/tests/functional/simulators/imposter.py
new file mode 100644
index 0000000..50da73f
--- /dev/null
+++ b/conductor/conductor/tests/functional/simulators/imposter.py
@@ -0,0 +1,24 @@
+from jinja2 import Template
+import json
+import os
+import re
+import sys
+
+imposter_template = sys.argv[1]
+responses_dir = sys.argv[2]
+imposter_json = sys.argv[3]
+
+with open(imposter_template, 'r') as imposter_file:
+ tm = Template(imposter_file.read())
+
+responses = {}
+
+for filename in os.listdir(responses_dir):
+ if filename.endswith('.json'):
+ with open(os.path.join(responses_dir, filename), 'r') as response_file:
+ responses[re.sub('\.json$', '', filename)] = response_file.read()
+
+imposter = tm.render(responses)
+
+with open(imposter_json, 'w') as imposter_file:
+ imposter_file.write(imposter)
diff --git a/conductor/conductor/tests/functional/simulators/run_aaisim.sh b/conductor/conductor/tests/functional/simulators/run_aaisim.sh
index 203de16..288049d 100755
--- a/conductor/conductor/tests/functional/simulators/run_aaisim.sh
+++ b/conductor/conductor/tests/functional/simulators/run_aaisim.sh
@@ -17,5 +17,15 @@
#
# -------------------------------------------------------------------------
#
-docker run -d --name aaisim -p 8081:8081 aaisim
+#docker run -d --name aaisim -p 8081:8081 aaisim
+docker run --name aaisim -p 2525:2525 -p 8081:8081 -d andyrbell/mountebank:2.3.2
+sleep 10
+
+#generate imposter data
+python3 imposter.py aaisim/aai_imposter.jsont aaisim/responses aai_imposter.json
+
+#Add imposter at 8081
+curl -i -X POST -H 'Content-Type: application/json' http://localhost:2525/imposters --data @aai_imposter.json
+
+rm -rf aai_imposter.json