aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAleksandr Taranov <aleksandr.taranov@telekom.com>2023-05-25 17:21:34 +0300
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2023-05-31 11:18:21 +0000
commit8f3c1e06049f242849af74b99fb60b41cebdc578 (patch)
tree8bba93e7ad367780097de046050cfe9043905d2c /src
parentea72aa01e864b6ddf3145d51d060077da00526d3 (diff)
Create SDNC Sanity test
Issue-ID: TEST-395 Signed-off-by: Aleksandr Taranov <aleksandr.taranov@telekom.com> Signed-off-by: Lukasz Rajewski <lukasz.rajewski@t-mobile.pl> Change-Id: I2a035beb74510013eb8e04aecd90c648af77fe28
Diffstat (limited to 'src')
-rw-r--r--src/onaptests/configuration/basic_sdnc_settings.py69
-rw-r--r--src/onaptests/scenario/basic_sdnc.py45
-rw-r--r--src/onaptests/steps/instantiate/sdnc_service.py104
3 files changed, 218 insertions, 0 deletions
diff --git a/src/onaptests/configuration/basic_sdnc_settings.py b/src/onaptests/configuration/basic_sdnc_settings.py
new file mode 100644
index 0000000..e6bbdcc
--- /dev/null
+++ b/src/onaptests/configuration/basic_sdnc_settings.py
@@ -0,0 +1,69 @@
+from .settings import *
+
+CLEANUP_FLAG = True
+
+SERVICE_NAME = "Basic SDNC test"
+
+SERVICE_COMPONENTS = "SDNC"
+
+SERVICE_ID = "pythonsdk-tests-service-01"
+
+SERVICE_STATUS = {
+ "rpc-action": "activate",
+ "response-message": "test-message-1",
+ "response-timestamp": "2023-05-09T13:14:30.540Z",
+ "request-status": "synccomplete",
+ "final-indicator": "Y",
+ "action": "CreateVnfInstance",
+ "rpc-name": "vnf-topology-operation",
+ "response-code": "200"
+}
+
+SERVICE_CHANGED_STATUS = {
+ "rpc-action": "activate",
+ "response-message": "changed-test-message-1",
+ "response-timestamp": "2023-05-09T13:14:30.540Z",
+ "request-status": "synccomplete",
+ "final-indicator": "Y",
+ "action": "CreateVnfInstance",
+ "rpc-name": "vnf-topology-operation",
+ "response-code": "200"
+}
+
+SERVICE_DATA = {
+ "service-level-oper-status": {
+ "last-rpc-action": "assign",
+ "last-action": "CreateServiceInstance",
+ "order-status": "Created"
+ },
+ "service-request-input": {
+ "service-input-parameters": {
+ "param": [
+ {
+ "name": "orchestrator",
+ "value": "multicloud"
+ }
+ ]
+ },
+ "service-instance-name": "gnb-93100001"
+ }
+}
+
+SERVICE_CHANGED_DATA = {
+ "service-level-oper-status": {
+ "last-rpc-action": "assign",
+ "last-action": "CreateServiceInstance",
+ "order-status": "Created"
+ },
+ "service-request-input": {
+ "service-input-parameters": {
+ "param": [
+ {
+ "name": "orchestrator",
+ "value": "multicloud"
+ }
+ ]
+ },
+ "service-instance-name": "gnb-93100002"
+ }
+}
diff --git a/src/onaptests/scenario/basic_sdnc.py b/src/onaptests/scenario/basic_sdnc.py
new file mode 100644
index 0000000..d791080
--- /dev/null
+++ b/src/onaptests/scenario/basic_sdnc.py
@@ -0,0 +1,45 @@
+import logging
+import time
+from xtesting.core import testcase
+
+from onapsdk.configuration import settings
+from onapsdk.exceptions import SDKException
+
+from onaptests.steps.instantiate.sdnc_service import UpdateSdncService
+from onaptests.utils.exceptions import OnapTestException
+
+
+class BasicSdnc(testcase.TestCase):
+ """Create SDNC service.
+ Check and delete the service.
+ """
+
+ __logger = logging.getLogger()
+
+ def __init__(self, **kwargs):
+ """Init Basic SDNC use case."""
+ if "case_name" not in kwargs:
+ kwargs["case_name"] = 'basic_SDNC'
+ super().__init__(**kwargs)
+ self.__logger.debug("Basic SDNC init started")
+ self.test = UpdateSdncService(cleanup=settings.CLEANUP_FLAG)
+
+ def run(self):
+ """Run basic SDNC test."""
+ self.start_time = time.time()
+ try:
+ self.test.execute()
+ self.test.cleanup()
+ self.result = 100
+ except OnapTestException as exc:
+ self.result = 0
+ self.__logger.exception(exc.error_message)
+ except SDKException:
+ self.result = 0
+ self.__logger.exception("SDK Exception")
+ finally:
+ self.stop_time = time.time()
+
+ def clean(self):
+ """Generate report."""
+ self.test.reports_collection.generate_report()
diff --git a/src/onaptests/steps/instantiate/sdnc_service.py b/src/onaptests/steps/instantiate/sdnc_service.py
new file mode 100644
index 0000000..c5308d6
--- /dev/null
+++ b/src/onaptests/steps/instantiate/sdnc_service.py
@@ -0,0 +1,104 @@
+from onapsdk.sdnc.services import Service
+from onapsdk.configuration import settings
+from onapsdk.exceptions import APIError
+
+from ..base import BaseStep
+
+from onaptests.utils.exceptions import OnapTestException
+
+
+class ServiceCreateStep(BaseStep):
+ """Service creation step."""
+
+ def __init__(self, service: Service = None, cleanup: bool = False):
+ """Initialize step."""
+ super().__init__(cleanup=cleanup)
+ self.service = service
+
+ @property
+ def description(self) -> str:
+ """Step description."""
+ return "Create SDNC service."
+
+ @property
+ def component(self) -> str:
+ """Component name."""
+ return "SDNC"
+
+ @BaseStep.store_state
+ def execute(self):
+ """Create service at SDNC."""
+ self._logger.info("Create new service instance in SDNC by GR-API")
+ super().execute()
+ try:
+ self.service = Service(
+ service_instance_id=settings.SERVICE_ID,
+ service_status=settings.SERVICE_STATUS,
+ service_data=settings.SERVICE_DATA
+ )
+ self.service.create()
+ self._logger.info("SDNC service is created.")
+ except APIError:
+ raise OnapTestException("SDNC service creation failed.")
+
+ @BaseStep.store_state()
+ def cleanup(self) -> None:
+ """Cleanup Service."""
+ if self.service is not None:
+ self.service.delete()
+ self._logger.info("SDNC service is deleted.")
+ super().cleanup()
+
+
+class UpdateSdncService(BaseStep):
+ """Service update step.
+
+ The step needs in an existing SDNC service as a prerequisite.
+ """
+
+ def __init__(self, cleanup=False):
+ """Initialize step.
+
+ Sub steps:
+ - ServiceCreateStep.
+ """
+ super().__init__(cleanup=cleanup)
+ self.add_step(ServiceCreateStep(cleanup=cleanup))
+
+ @property
+ def description(self) -> str:
+ """Step description.
+
+ Used for reports
+
+ Returns:
+ str: Step description
+
+ """
+ return "Update SDNC service"
+
+ @property
+ def component(self) -> str:
+ """Component name.
+
+ Name of component which step is related with.
+ Most is the name of ONAP component.
+
+ Returns:
+ str: Component name
+
+ """
+ return "SDNC"
+
+ @BaseStep.store_state
+ def execute(self):
+ self._logger.info("Get existing SDNC service instance and update it over GR-API")
+ super().execute()
+ try:
+ service = Service.get(settings.SERVICE_ID)
+ service.service_status = settings.SERVICE_CHANGED_STATUS
+ service.service_data = settings.SERVICE_CHANGED_DATA
+ service.update()
+ self._logger.info("SDNC service update is checked.")
+ except APIError:
+ raise OnapTestException("SDNC service update is failed.")