"Adding Sdc-simulator for Nst selection " 71/117771/2
authorhariharan97 <rh20085046@wipro.com>
Fri, 12 Feb 2021 05:04:26 +0000 (10:34 +0530)
committerhariharan97 <rh20085046@wipro.com>
Fri, 12 Feb 2021 08:06:55 +0000 (13:36 +0530)
Issue-ID: OPTFRA-764
Signed-off-by: hariharan97 <rh20085046@wipro.com>
Change-Id: I59e7f539d0c3bd9fe301e3a7bd151a36c71343d9

conductor/conductor/tests/functional/simulators/aaisim/aai_imposter.jsont
conductor/conductor/tests/functional/simulators/aaisim/responses/get_nst_response.json [new file with mode: 0644]
conductor/conductor/tests/functional/simulators/build_sdcsim.sh [new file with mode: 0644]
conductor/conductor/tests/functional/simulators/run_sdcsim.sh [new file with mode: 0644]
conductor/conductor/tests/functional/simulators/sdcsim/Dockerfile [new file with mode: 0644]
conductor/conductor/tests/functional/simulators/sdcsim/newembbnst.csar [new file with mode: 0644]
conductor/conductor/tests/functional/simulators/sdcsim/sdcsim.py [new file with mode: 0644]

index 93799cd..777bcb2 100644 (file)
       ]
     }]
   },
+  {
+    "responses": [
+      { "is": {
+           "statusCode": 200,
+           "body": {{ get_nst_response }}
+         }
+      }
+    ],
+    "predicates": [{
+      "and": [
+        {
+          "equals": {
+            "path": "/aai/v14/service-design-and-creation/models",
+            "method": "GET",
+            "query": {
+               "model-role": "NST",
+               "depth": 2
+            }
+          }
+        }
+      ]
+    }]
+  },
   {
     "responses": [
       { "is": { 
diff --git a/conductor/conductor/tests/functional/simulators/aaisim/responses/get_nst_response.json b/conductor/conductor/tests/functional/simulators/aaisim/responses/get_nst_response.json
new file mode 100644 (file)
index 0000000..2c075e3
--- /dev/null
@@ -0,0 +1,59 @@
+{
+   "model":[
+      {
+         "model-invariant-id":"f0aa2f5c-a022-4947-80bf-fc05a1502d82",
+         "model-type":"service",
+         "model-role":"NST",
+         "resource-version":"1609762578458",
+         "model-vers":{
+            "model-ver":[
+               {
+                  "model-version-id":"5d345ca8-1f8e-4f1e-aac7-6c8b33cc33e7",
+                  "model-name":"EmbbNst",
+                  "model-version":"1.0",
+                  "distribution-status":"DISTRIBUTION_COMPLETE_OK",
+                  "model-description":"EmbbNst",
+                  "resource-version":"1609762782080",
+                  "model-elements":{
+                     "model-element":[
+                        {
+                           "model-element-uuid":"5c7f04ca-a3b6-4ef9-9b9e-f887121276b0",
+                           "new-data-del-flag":"T",
+                           "cardinality":"unbounded",
+                           "resource-version":"1609762578458",
+                           "relationship-list":{
+                              "relationship":[
+                                 {
+                                    "related-to":"model-ver",
+                                    "relationship-label":"org.onap.relationships.inventory.IsA",
+                                    "related-link":"/aai/v21/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9",
+                                    "relationship-data":[
+                                       {
+                                          "relationship-key":"model.model-invariant-id",
+                                          "relationship-value":"82194af1-3c2c-485a-8f44-420e22a9eaa4"
+                                       },
+                                       {
+                                          "relationship-key":"model-ver.model-version-id",
+                                          "relationship-value":"46b92144-923a-4d20-b85a-3cbd847668a9"
+                                       }
+                                    ],
+                                    "related-to-property":[
+                                       {
+                                          "property-key":"model-ver.model-name",
+                                          "property-value":"service-instance"
+                                       }
+                                    ]
+                                 }
+                              ]
+                           }
+                        }
+                     ]
+                  }
+               }
+            ]
+         }
+      }
+
+
+   ]
+}
\ No newline at end of file
diff --git a/conductor/conductor/tests/functional/simulators/build_sdcsim.sh b/conductor/conductor/tests/functional/simulators/build_sdcsim.sh
new file mode 100644 (file)
index 0000000..50cfa06
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# -------------------------------------------------------------------------
+#   Copyright (C) 2021 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.
+#
+# -------------------------------------------------------------------------
+#
+cd ./sdcsim
+docker build -t sdcsim .
\ No newline at end of file
diff --git a/conductor/conductor/tests/functional/simulators/run_sdcsim.sh b/conductor/conductor/tests/functional/simulators/run_sdcsim.sh
new file mode 100644 (file)
index 0000000..8ba9f9d
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# -------------------------------------------------------------------------
+#   Copyright (C) 2021 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.
+#
+# -------------------------------------------------------------------------
+#
+docker run --name sdcsimulator   -p 9595:9595 -d sdcsim
+
+sleep 10
\ No newline at end of file
diff --git a/conductor/conductor/tests/functional/simulators/sdcsim/Dockerfile b/conductor/conductor/tests/functional/simulators/sdcsim/Dockerfile
new file mode 100644 (file)
index 0000000..e7d6d0a
--- /dev/null
@@ -0,0 +1,41 @@
+#
+# -------------------------------------------------------------------------
+#   Copyright (C) 2021 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.
+#
+# -------------------------------------------------------------------------
+#
+# Use an official Python runtime as a parent image
+FROM python:3
+
+# Set the working directory to /su/python/webpy-rest-dockerized
+WORKDIR /opt/sdcsim
+
+
+
+# Copy the current directory contents into the container at /app
+ADD ./ .
+
+# Install any needed packages specified in requirements.txt
+#RUN pip install --no-cache-dir web.py
+RUN pip install requests httpserver
+# Make port 80 available to the world outside this container
+EXPOSE 9595
+
+# Define environment variable
+#ENV NAME sdcsim
+
+# Run aaisim.py when the container launches
+#CMD ["/bin/sh", "-c", "python3 -u sdcsim.py 9595 > /tmp/sdcsim.log 2>&1"]
+CMD ["python", "./sdcsim.py"]
\ No newline at end of file
diff --git a/conductor/conductor/tests/functional/simulators/sdcsim/newembbnst.csar b/conductor/conductor/tests/functional/simulators/sdcsim/newembbnst.csar
new file mode 100644 (file)
index 0000000..d5c4270
Binary files /dev/null and b/conductor/conductor/tests/functional/simulators/sdcsim/newembbnst.csar differ
diff --git a/conductor/conductor/tests/functional/simulators/sdcsim/sdcsim.py b/conductor/conductor/tests/functional/simulators/sdcsim/sdcsim.py
new file mode 100644 (file)
index 0000000..723e0be
--- /dev/null
@@ -0,0 +1,55 @@
+#
+# -------------------------------------------------------------------------
+#   Copyright (C) 2021 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.
+#
+# -------------------------------------------------------------------------
+#
+
+from http.server import BaseHTTPRequestHandler, HTTPServer
+import socketserver
+import requests
+
+
+PORT = 9595
+
+
+
+
+
+class MockServerRequestHandler(BaseHTTPRequestHandler):
+    def do_GET(self):
+
+        # Process an HTTP GET request and return a response with an HTTP 200 status.
+                    # Add response status code.
+            if self.path=="/sdc/v1/catalog/services/5d345ca8-1f8e-4f1e-aac7-6c8b33cc33e7/toscaModel":
+                self.send_response(requests.codes.ok)
+
+                # Add response headers.
+                self.send_header('Content-Type', 'application/octet-stream; charset=utf-8')
+                self.end_headers()
+
+                # Add response content.
+                fileres=open("newembbnst.csar",'rb')
+                response_content = fileres.read()
+                self.wfile.write(response_content)
+                return
+            else:
+                self.wfile.write("incorrect url".encode())
+                return
+
+handlerobj = MockServerRequestHandler
+
+myserver = socketserver.TCPServer(('', PORT), handlerobj)
+myserver.serve_forever()