aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps
diff options
context:
space:
mode:
Diffstat (limited to 'src/onaptests/steps')
-rw-r--r--src/onaptests/steps/base.py291
-rw-r--r--src/onaptests/steps/cloud/check_status.py79
-rw-r--r--src/onaptests/steps/cloud/cloud_region_create.py4
-rw-r--r--src/onaptests/steps/cloud/complex_create.py4
-rw-r--r--src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py12
-rw-r--r--src/onaptests/steps/cloud/customer_create.py4
-rw-r--r--src/onaptests/steps/cloud/customer_service_subscription_create.py6
-rw-r--r--src/onaptests/steps/cloud/k8s_connectivity_info_create.py4
-rw-r--r--src/onaptests/steps/cloud/link_cloud_to_complex.py6
-rw-r--r--src/onaptests/steps/cloud/register_cloud.py6
-rw-r--r--src/onaptests/steps/instantiate/k8s_profile_create.py6
-rw-r--r--src/onaptests/steps/instantiate/msb_k8s.py6
-rw-r--r--src/onaptests/steps/instantiate/sdnc_service.py56
-rw-r--r--src/onaptests/steps/instantiate/service_ala_carte.py8
-rw-r--r--src/onaptests/steps/instantiate/service_macro.py10
-rw-r--r--src/onaptests/steps/instantiate/vf_module_ala_carte.py8
-rw-r--r--src/onaptests/steps/instantiate/vl_ala_carte.py6
-rw-r--r--src/onaptests/steps/instantiate/vnf_ala_carte.py6
-rw-r--r--src/onaptests/steps/loop/clamp.py6
-rw-r--r--src/onaptests/steps/onboard/cds.py38
-rw-r--r--src/onaptests/steps/onboard/clamp.py8
-rw-r--r--src/onaptests/steps/onboard/cps.py22
-rw-r--r--src/onaptests/steps/onboard/msb_k8s.py14
-rw-r--r--src/onaptests/steps/onboard/pnf.py26
-rw-r--r--src/onaptests/steps/onboard/service.py43
-rw-r--r--src/onaptests/steps/onboard/vendor.py11
-rw-r--r--src/onaptests/steps/onboard/vf.py26
-rw-r--r--src/onaptests/steps/onboard/vsp.py26
-rw-r--r--src/onaptests/steps/simulator/cds_mockserver.py6
-rw-r--r--src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py6
30 files changed, 478 insertions, 276 deletions
diff --git a/src/onaptests/steps/base.py b/src/onaptests/steps/base.py
index 2c5fb29..8737ac1 100644
--- a/src/onaptests/steps/base.py
+++ b/src/onaptests/steps/base.py
@@ -2,21 +2,123 @@ import functools
import itertools
import logging
import logging.config
+import os
import time
-
from abc import ABC, abstractmethod
from typing import Iterator, List, Optional
+
from onapsdk.aai.business import Customer
from onapsdk.configuration import settings
from onapsdk.exceptions import SDKException, SettingsError
+from onaptests.steps.reports_collection import (Report, ReportsCollection,
+ ReportStepStatus)
+from onaptests.utils.exceptions import (OnapTestException,
+ OnapTestExceptionGroup,
+ SkipExecutionException,
+ SubstepExecutionException,
+ SubstepExecutionExceptionGroup)
+
+
+IF_VALIDATION = "PYTHON_SDK_TESTS_VALIDATION"
-from onaptests.steps.reports_collection import Report, ReportsCollection, ReportStepStatus
-from onaptests.utils.exceptions import OnapTestException, SubstepExecutionException
+class StoreStateHandler(ABC):
+
+ @classmethod
+ def store_state(cls, fun=None, *, cleanup=False):
+ if fun is None:
+ return functools.partial(cls.store_state, cleanup=cleanup)
-class BaseStep(ABC):
+ @functools.wraps(fun)
+ def wrapper(self, *args, **kwargs):
+ if (cleanup and self._state_clean) or (not cleanup and self._state_execute):
+ raise RuntimeError(f"Sate of {self._step_title(cleanup)} already stored")
+ if cleanup:
+ self._state_clean = True
+ else:
+ self._state_execute = True
+ initial_exception = None
+ try:
+ execution_status: Optional[ReportStepStatus] = ReportStepStatus.FAIL
+ if cleanup:
+ self._start_cleanup_time = time.time()
+ try:
+ if (self._executed and self._cleanup and
+ (self._is_validation_only or
+ self.check_preconditions(cleanup=True))):
+ self._log_execution_state("START", cleanup)
+ if not self._is_validation_only:
+ fun(self, *args, **kwargs)
+ self._cleaned_up = True
+ execution_status = ReportStepStatus.PASS
+ else:
+ execution_status = ReportStepStatus.NOT_EXECUTED
+ except (OnapTestException, SDKException) as test_exc:
+ initial_exception = test_exc
+ finally:
+ self._log_execution_state(execution_status.name, cleanup)
+ self._cleanup_substeps()
+ if initial_exception:
+ new_exception = initial_exception
+ initial_exception = None
+ raise new_exception
+ else:
+ if self._is_validation_only or self.check_preconditions():
+ self._log_execution_state("START", cleanup)
+ fun(self, *args, **kwargs)
+ execution_status = ReportStepStatus.PASS
+ self._executed = True
+ else:
+ execution_status = ReportStepStatus.NOT_EXECUTED
+ except SkipExecutionException:
+ execution_status = ReportStepStatus.PASS
+ self._executed = True
+ except SubstepExecutionException as substep_exc:
+ if not cleanup:
+ execution_status = ReportStepStatus.NOT_EXECUTED
+ if initial_exception:
+ substep_exc = OnapTestExceptionGroup("Cleanup Exceptions",
+ [initial_exception, substep_exc])
+ raise substep_exc
+ except (OnapTestException, SDKException) as test_exc:
+ if initial_exception:
+ test_exc = OnapTestExceptionGroup("Cleanup Exceptions",
+ [initial_exception, test_exc])
+ raise test_exc
+ finally:
+ if not cleanup:
+ self._log_execution_state(execution_status.name, cleanup)
+ if cleanup:
+ self._cleanup_report = Report(
+ step_description=self._step_title(cleanup),
+ step_execution_status=execution_status,
+ step_execution_duration=time.time() - self._start_cleanup_time,
+ step_component=self.component
+ )
+ else:
+ if not self._start_execution_time:
+ if execution_status != ReportStepStatus.NOT_EXECUTED:
+ self._logger.error("No execution start time saved for %s step. "
+ "Fix it by call `super.execute()` "
+ "in step class `execute()` method definition",
+ self.name)
+ self._start_execution_time = time.time()
+ self._execution_report = Report(
+ step_description=self._step_title(cleanup),
+ step_execution_status=(execution_status if execution_status else
+ ReportStepStatus.FAIL),
+ step_execution_duration=time.time() - self._start_execution_time,
+ step_component=self.component
+ )
+ return wrapper
+
+
+class BaseStep(StoreStateHandler, ABC):
"""Base step class."""
+ """Indicates that Step has no dedicated cleanup method"""
+ HAS_NO_CLEANUP = False
+
_logger: logging.Logger = logging.getLogger("")
def __init_subclass__(cls):
@@ -33,11 +135,13 @@ class BaseStep(ABC):
except SettingsError:
pass
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self, cleanup: bool = False, break_on_error=True) -> None:
"""Step initialization.
Args:
cleanup(bool, optional): Determines if cleanup action should be called.
+ break_on_error(bool, optional): Determines if fail on execution should
+ result with continuation of further steps
"""
self._steps: List["BaseStep"] = []
@@ -48,6 +152,13 @@ class BaseStep(ABC):
self._start_cleanup_time: float = None
self._execution_report: ReportStepStatus = None
self._cleanup_report: ReportStepStatus = None
+ self._executed: bool = False
+ self._cleaned_up: bool = False
+ self._state_execute: bool = False
+ self._state_clean: bool = False
+ self._nesting_level: int = 0
+ self._break_on_error: bool = break_on_error
+ self._is_validation_only = os.environ.get(IF_VALIDATION) is not None
def add_step(self, step: "BaseStep") -> None:
"""Add substep.
@@ -59,6 +170,16 @@ class BaseStep(ABC):
"""
self._steps.append(step)
step._parent: "BaseStep" = self
+ step._update_nesting_level()
+
+ def _update_nesting_level(self) -> None:
+ """Update step nesting level.
+
+ Step nesting level allows to display relatino of steps during validation
+ """
+ self._nesting_level = 1 + self._parent._nesting_level
+ for step in self._steps:
+ step._update_nesting_level()
@property
def parent(self) -> "BaseStep":
@@ -69,6 +190,18 @@ class BaseStep(ABC):
return self._parent
@property
+ def is_executed(self) -> bool:
+ """Is step executed.
+
+ Step is executed if execute() method was completed without errors
+
+ Returns:
+ bool: True if step is executed, False otherwise
+
+ """
+ return self._executed
+
+ @property
def is_root(self) -> bool:
"""Is a root step.
@@ -126,8 +259,8 @@ class BaseStep(ABC):
if self._cleanup:
if self._cleanup_report:
yield self._cleanup_report
- for step in self._steps:
- yield from step.cleanup_reports
+ for step in reversed(self._steps):
+ yield from step.cleanup_reports
@property
def name(self) -> str:
@@ -159,67 +292,28 @@ class BaseStep(ABC):
"""
- @classmethod
- def store_state(cls, fun=None, *, cleanup=False):
- if fun is None:
- return functools.partial(cls.store_state, cleanup=cleanup)
+ def _step_title(self, cleanup=False):
+ cleanup_label = " Cleanup:" if cleanup else ":"
+ return f"[{self.component}] {self.name}{cleanup_label} {self.description}"
- @functools.wraps(fun)
- def wrapper(self, *args, **kwargs):
- try:
- if cleanup:
- self._start_cleanup_time = time.time()
- self._logger.info("*****************************************************")
- self._logger.info(f"START [{self.component}] {self.name} cleanup: "
- f"{self.description}")
- self._logger.info("*****************************************************")
- else:
- self._logger.info("*****************************************************")
- self._logger.info(f"START [{self.component}] {self.name}: {self.description}")
- self._logger.info("*****************************************************")
- execution_status: Optional[ReportStepStatus] = None
- ret = fun(self, *args, **kwargs)
- execution_status = ReportStepStatus.PASS
- return ret
- except SubstepExecutionException:
- execution_status = (ReportStepStatus.PASS if cleanup else
- ReportStepStatus.NOT_EXECUTED)
- raise
- except (OnapTestException, SDKException):
- execution_status = ReportStepStatus.FAIL
- raise
- finally:
- if cleanup:
- self._logger.info("*****************************************************")
- self._logger.info(f"STOP [{self.component}] {self.name} cleanup: "
- f"{self.description}")
- self._logger.info("*****************************************************")
- self._cleanup_report = Report(
- step_description=(f"[{self.component}] {self.name} cleanup: "
- f"{self.description}"),
- step_execution_status=execution_status,
- step_execution_duration=time.time() - self._start_cleanup_time,
- step_component=self.component
- )
- else:
- self._logger.info("*****************************************************")
- self._logger.info(f"STOP [{self.component}] {self.name}: {self.description}")
- self._logger.info("*****************************************************")
- if not self._start_execution_time:
- if execution_status != ReportStepStatus.NOT_EXECUTED:
- self._logger.error("No execution start time saved for %s step. "
- "Fix it by call `super.execute()` "
- "in step class `execute()` method definition",
- self.name)
- self._start_execution_time = time.time()
- self._execution_report = Report(
- step_description=f"[{self.component}] {self.name}: {self.description}",
- step_execution_status=(execution_status if execution_status else
- ReportStepStatus.FAIL),
- step_execution_duration=time.time() - self._start_execution_time,
- step_component=self.component
- )
- return wrapper
+ def _log_execution_state(self, state: str, cleanup=False):
+ nesting_label = "" + " " * self._nesting_level
+ description = f"| {state} {self._step_title(cleanup)} |"
+ self._logger.info(nesting_label + "*" * len(description))
+ self._logger.info(nesting_label + description)
+ self._logger.info(nesting_label + "*" * len(description))
+
+ def check_preconditions(self, cleanup=False) -> bool:
+ """Check preconditions.
+
+ Check if step preconditions are satisfied. If not, step is skipped
+ without further consequences. If yes, execution is initiated
+
+ Returns:
+ bool: True if preconditions are satisfied, False otherwise
+
+ """
+ return True
def execute(self) -> None:
"""Step's action execution.
@@ -228,16 +322,48 @@ class BaseStep(ABC):
Override this method and remember to call `super().execute()` before.
"""
+ substep_error = False
for step in self._steps:
try:
step.execute()
except (OnapTestException, SDKException) as substep_err:
- raise SubstepExecutionException from substep_err
+ substep_error = True
+ if step._break_on_error:
+ raise SubstepExecutionException from substep_err
+ else:
+ self._logger.exception(substep_err)
if self._steps:
- self._logger.info("*****************************************************")
- self._logger.info(f"CONTINUE [{self.component}] {self.name}: {self.description}")
- self._logger.info("*****************************************************")
+ if substep_error and self._break_on_error:
+ raise SubstepExecutionException("Cannot continue due to failed substeps")
+ self._log_execution_state("CONTINUE")
self._start_execution_time = time.time()
+ if self._is_validation_only:
+ raise SkipExecutionException()
+
+ def _cleanup_substeps(self) -> None:
+ """Substeps' cleanup.
+
+ Substeps are cleaned-up in reversed order.
+ We also try to cleanup steps if others failed
+
+ """
+ exceptions_to_raise = []
+ for step in reversed(self._steps):
+ try:
+ if step._cleanup:
+ step.cleanup()
+ else:
+ step._default_cleanup_handler()
+ except (OnapTestException, SDKException) as substep_err:
+ try:
+ raise SubstepExecutionException from substep_err
+ except Exception as e:
+ exceptions_to_raise.append(e)
+ if len(exceptions_to_raise) > 0:
+ if len(exceptions_to_raise) == 1:
+ raise exceptions_to_raise[0]
+ else:
+ raise SubstepExecutionExceptionGroup("Substep Exceptions", exceptions_to_raise)
def cleanup(self) -> None:
"""Step's cleanup.
@@ -245,12 +371,14 @@ class BaseStep(ABC):
Not all steps has to have cleanup method
"""
- if self._cleanup:
- for step in self._steps:
- try:
- step.cleanup()
- except (OnapTestException, SDKException) as substep_err:
- raise SubstepExecutionException from substep_err
+ # Step itself was cleaned-up, now time for children
+ if not self._cleanup:
+ # in this case we just make sure that store_state is run
+ self._default_cleanup_handler()
+
+ @StoreStateHandler.store_state(cleanup=True)
+ def _default_cleanup_handler(self):
+ pass
@classmethod
def set_proxy(cls, sock_http):
@@ -260,6 +388,15 @@ class BaseStep(ABC):
onap_proxy['https'] = sock_http
Customer.set_proxy(onap_proxy)
+ def validate_execution(self):
+ if self._is_validation_only:
+ self._log_execution_state(f"VALIDATE [{self._executed}, {self._cleanup}]")
+ if self._executed and self._cleanup and not self._cleaned_up:
+ self._logger.error(f"{self._step_title()} Cleanup Not Executed")
+ assert self._cleaned_up
+ for step in reversed(self._steps):
+ step.validate_execution()
+
class YamlTemplateBaseStep(BaseStep, ABC):
"""Base YAML template step."""
diff --git a/src/onaptests/steps/cloud/check_status.py b/src/onaptests/steps/cloud/check_status.py
index 168c212..5b572f1 100644
--- a/src/onaptests/steps/cloud/check_status.py
+++ b/src/onaptests/steps/cloud/check_status.py
@@ -29,9 +29,9 @@ class CheckK8sResourcesStep(BaseStep):
__logger = logging.getLogger(__name__)
- def __init__(self, resource_type: str, **kwargs):
+ def __init__(self, resource_type: str, break_on_error=False):
"""Init CheckK8sResourcesStep."""
- super().__init__(cleanup=False)
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP, break_on_error=break_on_error)
self.core = client.CoreV1Api()
self.batch = client.BatchV1Api()
self.app = client.AppsV1Api()
@@ -61,7 +61,9 @@ class CheckK8sResourcesStep(BaseStep):
return f"Check status of all k8s {self.resource_type}s in the {NAMESPACE} namespace."
def _init_resources(self):
- self.__logger.debug(f"Loading all k8s {self.resource_type}s in the {NAMESPACE} namespace")
+ if self.resource_type != "":
+ self.__logger.debug(f"Loading all k8s {self.resource_type}s"
+ " in the {NAMESPACE} namespace")
def _parse_resources(self):
"""Parse the resources."""
@@ -92,16 +94,17 @@ class CheckK8sResourcesStep(BaseStep):
len(self.all_resources),
self.resource_type,
len(self.failing_resources))
- except (ConnectionRefusedError, MaxRetryError, NewConnectionError):
+ if self.failing:
+ raise StatusCheckException(f"{self.resource_type} test failed")
+ except (ConnectionRefusedError, MaxRetryError, NewConnectionError) as e:
self.__logger.error("Test of k8s %ss failed.", self.resource_type)
self.__logger.error("Cannot connect to Kubernetes.")
+ raise StatusCheckException from e
class CheckBasicK8sResourcesStep(CheckK8sResourcesStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, resource_type: str, k8s_res_class, cleanup: bool = False, **kwargs):
+ def __init__(self, resource_type: str, k8s_res_class):
"""Init CheckBasicK8sResourcesStep."""
super().__init__(resource_type)
self.k8s_res_class = k8s_res_class
@@ -120,9 +123,7 @@ class CheckBasicK8sResourcesStep(CheckK8sResourcesStep):
class CheckK8sConfigMapsStep(CheckBasicK8sResourcesStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, cleanup: bool = False, **kwargs):
+ def __init__(self):
"""Init CheckK8sConfigMapsStep."""
super().__init__("configmap", ConfigMap)
@@ -133,9 +134,7 @@ class CheckK8sConfigMapsStep(CheckBasicK8sResourcesStep):
class CheckK8sSecretsStep(CheckBasicK8sResourcesStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, cleanup: bool = False, **kwargs):
+ def __init__(self):
"""Init CheckK8sSecretsStep."""
super().__init__("secret", Secret)
@@ -146,9 +145,7 @@ class CheckK8sSecretsStep(CheckBasicK8sResourcesStep):
class CheckK8sIngressesStep(CheckBasicK8sResourcesStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, cleanup: bool = False, **kwargs):
+ def __init__(self):
"""Init CheckK8sIngressesStep."""
super().__init__("ingress", Ingress)
@@ -159,9 +156,7 @@ class CheckK8sIngressesStep(CheckBasicK8sResourcesStep):
class CheckK8sPvcsStep(CheckK8sResourcesStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, cleanup: bool = False, **kwargs):
+ def __init__(self):
"""Init CheckK8sPvcsStep."""
super().__init__("pvc")
@@ -193,9 +188,7 @@ class CheckK8sPvcsStep(CheckK8sResourcesStep):
class CheckK8sResourcesUsingPodsStep(CheckK8sResourcesStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, resource_type: str, pods_source, cleanup: bool = False, **kwargs):
+ def __init__(self, resource_type: str, pods_source):
"""Init CheckK8sResourcesUsingPodsStep."""
super().__init__(resource_type)
self.pods_source = pods_source
@@ -232,9 +225,7 @@ class CheckK8sResourcesUsingPodsStep(CheckK8sResourcesStep):
class CheckK8sJobsStep(CheckK8sResourcesUsingPodsStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, cleanup: bool = False, **kwargs):
+ def __init__(self):
"""Init CheckK8sJobsStep."""
super().__init__("job", None)
@@ -279,7 +270,7 @@ class CheckK8sPodsStep(CheckK8sResourcesUsingPodsStep):
__logger = logging.getLogger(__name__)
- def __init__(self, pods, cleanup: bool = False, **kwargs):
+ def __init__(self, pods):
"""Init CheckK8sPodsStep."""
super().__init__("pod", pods)
@@ -516,9 +507,7 @@ class CheckK8sPodsStep(CheckK8sResourcesUsingPodsStep):
class CheckK8sServicesStep(CheckK8sResourcesUsingPodsStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, pods, cleanup: bool = False, **kwargs):
+ def __init__(self, pods):
"""Init CheckK8sServicesStep."""
super().__init__("service", pods)
@@ -543,9 +532,7 @@ class CheckK8sServicesStep(CheckK8sResourcesUsingPodsStep):
class CheckK8sDeploymentsStep(CheckK8sResourcesUsingPodsStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, pods, cleanup: bool = False, **kwargs):
+ def __init__(self, pods):
"""Init CheckK8sDeploymentsStep."""
super().__init__("deployment", pods)
@@ -581,12 +568,10 @@ class CheckK8sDeploymentsStep(CheckK8sResourcesUsingPodsStep):
self.all_resources.append(deployment)
-class CheckK8sResplicaSetsStep(CheckK8sResourcesUsingPodsStep):
-
- __logger = logging.getLogger(__name__)
+class CheckK8sReplicaSetsStep(CheckK8sResourcesUsingPodsStep):
- def __init__(self, pods, cleanup: bool = False, **kwargs):
- """Init CheckK8sResplicaSetsStep."""
+ def __init__(self, pods):
+ """Init CheckK8sReplicaSetsStep."""
super().__init__("replicaset", pods)
def _init_resources(self):
@@ -625,9 +610,7 @@ class CheckK8sResplicaSetsStep(CheckK8sResourcesUsingPodsStep):
class CheckK8sStatefulSetsStep(CheckK8sResourcesUsingPodsStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, pods, cleanup: bool = False, **kwargs):
+ def __init__(self, pods):
"""Init CheckK8sStatefulSetsStep."""
super().__init__("statefulset", pods)
@@ -667,9 +650,7 @@ class CheckK8sStatefulSetsStep(CheckK8sResourcesUsingPodsStep):
class CheckK8sDaemonSetsStep(CheckK8sResourcesUsingPodsStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, pods, cleanup: bool = False, **kwargs):
+ def __init__(self, pods):
"""Init CheckK8sDaemonSetsStep."""
super().__init__("daemonset", pods)
@@ -711,9 +692,9 @@ class CheckNamespaceStatusStep(CheckK8sResourcesStep):
__logger = logging.getLogger(__name__)
- def __init__(self, cleanup: bool = False, **kwargs):
+ def __init__(self):
"""Init CheckNamespaceStatusStep."""
- super().__init__("")
+ super().__init__(resource_type="")
self.__logger.debug("%s namespace status test init started", NAMESPACE)
if settings.IN_CLUSTER:
config.load_incluster_config()
@@ -724,7 +705,7 @@ class CheckNamespaceStatusStep(CheckK8sResourcesStep):
self.pod_list_step = CheckK8sPodsStep(self.job_list_step)
self.service_list_step = CheckK8sServicesStep(self.pod_list_step)
self.deployment_list_step = CheckK8sDeploymentsStep(self.pod_list_step)
- self.replicaset_list_step = CheckK8sResplicaSetsStep(self.pod_list_step)
+ self.replicaset_list_step = CheckK8sReplicaSetsStep(self.pod_list_step)
self.statefulset_list_step = CheckK8sStatefulSetsStep(self.pod_list_step)
self.daemonset_list_step = CheckK8sDaemonSetsStep(self.pod_list_step)
self.configmap_list_step = CheckK8sConfigMapsStep()
@@ -799,11 +780,13 @@ class CheckNamespaceStatusStep(CheckK8sResourcesStep):
step.resource_type,
len(step.failing_resources))
details[step.resource_type] = {
- 'number_all': len(step.all_resources),
'number_failing': len(step.failing_resources),
- 'all': self.map_by_name(step.all_resources),
'failing': self.map_by_name(step.failing_resources)
}
+ if settings.INCLUDE_ALL_RES_IN_DETAILS:
+ details[step.resource_type]['all'] = self.map_by_name(step.all_resources)
+ details[step.resource_type]['number_all'] = len(step.all_resources)
+
with (Path(self.res_dir).joinpath(settings.STATUS_DETAILS_JSON)).open('w') as file:
json.dump(details, file, indent=4)
if self.failing:
diff --git a/src/onaptests/steps/cloud/cloud_region_create.py b/src/onaptests/steps/cloud/cloud_region_create.py
index 21c846f..fcda251 100644
--- a/src/onaptests/steps/cloud/cloud_region_create.py
+++ b/src/onaptests/steps/cloud/cloud_region_create.py
@@ -9,6 +9,10 @@ from ..base import BaseStep
class CloudRegionCreateStep(BaseStep):
"""Cloud region creation step."""
+ def __init__(self):
+ """Initialize step."""
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+
@property
def description(self) -> str:
"""Step description."""
diff --git a/src/onaptests/steps/cloud/complex_create.py b/src/onaptests/steps/cloud/complex_create.py
index 60565f4..96d8e7f 100644
--- a/src/onaptests/steps/cloud/complex_create.py
+++ b/src/onaptests/steps/cloud/complex_create.py
@@ -8,6 +8,10 @@ from ..base import BaseStep
class ComplexCreateStep(BaseStep):
"""Complex creation step."""
+ def __init__(self):
+ """Initialize step."""
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+
@property
def description(self) -> str:
"""Step description."""
diff --git a/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py b/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py
index 3bb08c7..8307b45 100644
--- a/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py
+++ b/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py
@@ -12,7 +12,7 @@ from .k8s_connectivity_info_create import K8SConnectivityInfoStep
class ConnectServiceSubToCloudRegionStep(BaseStep):
"""Connect service subscription to cloud region step."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
@@ -21,12 +21,12 @@ class ConnectServiceSubToCloudRegionStep(BaseStep):
- CustomerServiceSubscriptionCreateStep.
"""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
if settings.CLOUD_REGION_TYPE == settings.K8S_REGION_TYPE:
- self.add_step(K8SConnectivityInfoStep(cleanup=cleanup))
- self.add_step(RegisterCloudRegionStep(cleanup=cleanup))
- self.add_step(LinkCloudRegionToComplexStep(cleanup=cleanup))
- self.add_step(CustomerServiceSubscriptionCreateStep(cleanup=cleanup))
+ self.add_step(K8SConnectivityInfoStep())
+ self.add_step(RegisterCloudRegionStep())
+ self.add_step(LinkCloudRegionToComplexStep())
+ self.add_step(CustomerServiceSubscriptionCreateStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/cloud/customer_create.py b/src/onaptests/steps/cloud/customer_create.py
index 1cc0879..96d192a 100644
--- a/src/onaptests/steps/cloud/customer_create.py
+++ b/src/onaptests/steps/cloud/customer_create.py
@@ -8,6 +8,10 @@ from ..base import BaseStep
class CustomerCreateStep(BaseStep):
"""Customer creation step."""
+ def __init__(self):
+ """Initialize step."""
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+
@property
def description(self) -> str:
"""Step description."""
diff --git a/src/onaptests/steps/cloud/customer_service_subscription_create.py b/src/onaptests/steps/cloud/customer_service_subscription_create.py
index 67de141..533b2b8 100644
--- a/src/onaptests/steps/cloud/customer_service_subscription_create.py
+++ b/src/onaptests/steps/cloud/customer_service_subscription_create.py
@@ -9,14 +9,14 @@ from .customer_create import CustomerCreateStep
class CustomerServiceSubscriptionCreateStep(BaseStep):
"""Cutomer service subsription creation step"""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- CustomerCreateStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(CustomerCreateStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(CustomerCreateStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/cloud/k8s_connectivity_info_create.py b/src/onaptests/steps/cloud/k8s_connectivity_info_create.py
index adcf862..c22df47 100644
--- a/src/onaptests/steps/cloud/k8s_connectivity_info_create.py
+++ b/src/onaptests/steps/cloud/k8s_connectivity_info_create.py
@@ -10,6 +10,10 @@ from onaptests.steps.base import BaseStep
class K8SConnectivityInfoStep(BaseStep):
"""CreateConnnectivityInfoStep."""
+ def __init__(self):
+ """Initialize step."""
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+
@property
def description(self) -> str:
"""Step description."""
diff --git a/src/onaptests/steps/cloud/link_cloud_to_complex.py b/src/onaptests/steps/cloud/link_cloud_to_complex.py
index fcfa711..8f5dad6 100644
--- a/src/onaptests/steps/cloud/link_cloud_to_complex.py
+++ b/src/onaptests/steps/cloud/link_cloud_to_complex.py
@@ -8,15 +8,15 @@ from .complex_create import ComplexCreateStep
class LinkCloudRegionToComplexStep(BaseStep):
"""Link cloud region to complex step"""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- ComplexCreateStep,
- CloudRegionCreateStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(ComplexCreateStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(ComplexCreateStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/cloud/register_cloud.py b/src/onaptests/steps/cloud/register_cloud.py
index c6b440f..fbfb6f3 100644
--- a/src/onaptests/steps/cloud/register_cloud.py
+++ b/src/onaptests/steps/cloud/register_cloud.py
@@ -13,14 +13,14 @@ from onaptests.steps.cloud.cloud_region_create import CloudRegionCreateStep
class RegisterCloudRegionStep(BaseStep):
"""Cloud region registration step."""
- def __init__(self, cleanup: bool) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CloudRegionCreateStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(CloudRegionCreateStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(CloudRegionCreateStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/instantiate/k8s_profile_create.py b/src/onaptests/steps/instantiate/k8s_profile_create.py
index 27831c5..d3798e2 100644
--- a/src/onaptests/steps/instantiate/k8s_profile_create.py
+++ b/src/onaptests/steps/instantiate/k8s_profile_create.py
@@ -16,15 +16,15 @@ from .vnf_ala_carte import YamlTemplateVnfAlaCarteInstantiateStep
class K8SProfileStep(BaseStep):
"""CreateK8sProfileStep."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
"""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
self._yaml_template: dict = None
self._service_instance_name: str = None
self._service_instance: ServiceInstance = None
- self.add_step(YamlTemplateVnfAlaCarteInstantiateStep(cleanup))
+ self.add_step(YamlTemplateVnfAlaCarteInstantiateStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/instantiate/msb_k8s.py b/src/onaptests/steps/instantiate/msb_k8s.py
index 724549c..9189282 100644
--- a/src/onaptests/steps/instantiate/msb_k8s.py
+++ b/src/onaptests/steps/instantiate/msb_k8s.py
@@ -9,14 +9,14 @@ from onaptests.steps.onboard.msb_k8s import CreateProfileStep
class CreateInstanceStep(BaseStep):
"""Create MSB k8s instance step."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CreateProfileStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(CreateProfileStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(CreateProfileStep())
self.instance: Instance = None
@property
diff --git a/src/onaptests/steps/instantiate/sdnc_service.py b/src/onaptests/steps/instantiate/sdnc_service.py
index 7b6be14..1c2437f 100644
--- a/src/onaptests/steps/instantiate/sdnc_service.py
+++ b/src/onaptests/steps/instantiate/sdnc_service.py
@@ -3,10 +3,10 @@ from onapsdk.exceptions import APIError
from onapsdk.sdnc import VfModulePreload
from onapsdk.sdnc.preload import PreloadInformation
from onapsdk.sdnc.services import Service
+from onaptests.scenario.scenario_base import BaseScenarioStep
+from onaptests.steps.base import BaseStep
from onaptests.utils.exceptions import OnapTestException
-from ..base import BaseStep
-
class BaseSdncStep(BaseStep):
"""Basic SDNC step."""
@@ -32,9 +32,9 @@ class BaseSdncStep(BaseStep):
class ServiceCreateStep(BaseSdncStep):
"""Service creation step."""
- def __init__(self, service: Service = None, cleanup: bool = False):
+ def __init__(self, service: Service = None):
"""Initialize step."""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
self.service = service
@property
@@ -43,7 +43,7 @@ class ServiceCreateStep(BaseSdncStep):
return "Create SDNC service."
@BaseStep.store_state
- def execute(self):
+ def execute(self) -> None:
"""Create service at SDNC."""
super().execute()
self._logger.info("Create new service instance in SDNC by GR-API")
@@ -61,7 +61,7 @@ class ServiceCreateStep(BaseSdncStep):
else:
raise OnapTestException("SDNC service creation failed.")
- @BaseStep.store_state()
+ @BaseStep.store_state(cleanup=True)
def cleanup(self) -> None:
"""Cleanup Service."""
if self.service is not None:
@@ -76,14 +76,14 @@ class UpdateSdncService(BaseSdncStep):
The step needs in an existing SDNC service as a prerequisite.
"""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Sub steps:
- ServiceCreateStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(ServiceCreateStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(ServiceCreateStep())
@property
def description(self) -> str:
@@ -97,8 +97,8 @@ class UpdateSdncService(BaseSdncStep):
"""
return "Update SDNC service"
- @BaseStep.store_state
- def execute(self):
+ @BaseSdncStep.store_state
+ def execute(self) -> None:
super().execute()
self._logger.info("Get existing SDNC service instance and update it over GR-API")
try:
@@ -117,9 +117,9 @@ class UploadVfModulePreloadStep(BaseSdncStep):
Upload preload information for VfModule over GR-API.
"""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step."""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
@property
def description(self) -> str:
@@ -133,8 +133,8 @@ class UploadVfModulePreloadStep(BaseSdncStep):
"""
return "Upload Preload information for VfModule"
- @BaseStep.store_state
- def execute(self):
+ @BaseSdncStep.store_state
+ def execute(self) -> None:
super().execute()
self._logger.info("Upload VfModule preload information over GR-API")
VfModulePreload.upload_vf_module_preload(
@@ -153,14 +153,14 @@ class GetSdncPreloadStep(BaseSdncStep):
Get preload information from SDNC over GR-API.
"""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Sub steps:
- UploadVfModulePreloadStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(UploadVfModulePreloadStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(UploadVfModulePreloadStep())
@property
def description(self) -> str:
@@ -174,8 +174,8 @@ class GetSdncPreloadStep(BaseSdncStep):
"""
return "Get Preload information"
- @BaseStep.store_state
- def execute(self):
+ @BaseSdncStep.store_state
+ def execute(self) -> None:
super().execute()
self._logger.info("Get existing SDNC service instance and update it over GR-API")
preloads = PreloadInformation.get_all()
@@ -183,22 +183,18 @@ class GetSdncPreloadStep(BaseSdncStep):
print(preload_information)
-class TestSdncStep(BaseStep):
+class TestSdncStep(BaseScenarioStep):
"""Top level step for SDNC tests."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Sub steps:
- UpdateSdncService.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(
- UpdateSdncService(cleanup=cleanup)
- )
- self.add_step(
- GetSdncPreloadStep(cleanup=cleanup)
- )
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(UpdateSdncService())
+ self.add_step(GetSdncPreloadStep())
@property
def description(self) -> str:
@@ -223,4 +219,4 @@ class TestSdncStep(BaseStep):
str: Component name
"""
- return "PythonSDK-tests"
+ return "TEST"
diff --git a/src/onaptests/steps/instantiate/service_ala_carte.py b/src/onaptests/steps/instantiate/service_ala_carte.py
index 9908b6d..1773aa4 100644
--- a/src/onaptests/steps/instantiate/service_ala_carte.py
+++ b/src/onaptests/steps/instantiate/service_ala_carte.py
@@ -92,20 +92,20 @@ class ServiceAlaCarteInstantiateStep(BaseStep):
class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
"""Instantiate service a'la carte using YAML template."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- YamlTemplateServiceOnboardStep,
- ConnectServiceSubToCloudRegionStep.
"""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
self._yaml_template: dict = None
self._service_instance_name: str = None
self._service_instance: str = None
if not settings.ONLY_INSTANTIATE:
- self.add_step(YamlTemplateServiceOnboardStep(cleanup))
- self.add_step(ConnectServiceSubToCloudRegionStep(cleanup))
+ self.add_step(YamlTemplateServiceOnboardStep())
+ self.add_step(ConnectServiceSubToCloudRegionStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/instantiate/service_macro.py b/src/onaptests/steps/instantiate/service_macro.py
index d97a109..88eef4d 100644
--- a/src/onaptests/steps/instantiate/service_macro.py
+++ b/src/onaptests/steps/instantiate/service_macro.py
@@ -34,7 +34,7 @@ from onaptests.steps.cloud.connect_service_subscription_to_cloud_region import (
class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
"""Instantiate service a'la carte using YAML template."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
@@ -42,21 +42,21 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
- ConnectServiceSubToCloudRegionStep,
- CustomerServiceSubscriptionCreateStep.
"""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
self._yaml_template: dict = None
self._model_yaml_template: dict = None
self._service_instance_name: str = None
self._service_instance: str = None
if not settings.ONLY_INSTANTIATE:
- self.add_step(YamlTemplateServiceOnboardStep(cleanup))
+ self.add_step(YamlTemplateServiceOnboardStep())
if any(
filter(lambda x: x in self.yaml_template[self.service_name].keys(),
["vnfs", "networks"])):
# can additionally contain "pnfs", no difference
- self.add_step(ConnectServiceSubToCloudRegionStep(cleanup))
+ self.add_step(ConnectServiceSubToCloudRegionStep())
else: # only pnfs
- self.add_step(CustomerServiceSubscriptionCreateStep(cleanup))
+ self.add_step(CustomerServiceSubscriptionCreateStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/instantiate/vf_module_ala_carte.py b/src/onaptests/steps/instantiate/vf_module_ala_carte.py
index b4a7c77..015e479 100644
--- a/src/onaptests/steps/instantiate/vf_module_ala_carte.py
+++ b/src/onaptests/steps/instantiate/vf_module_ala_carte.py
@@ -16,13 +16,13 @@ from .k8s_profile_create import K8SProfileStep
class YamlTemplateVfModuleAlaCarteInstantiateStep(YamlTemplateBaseStep):
"""Instantiate vf module a'la carte using YAML template."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- YamlTemplateVnfAlaCarteInstantiateStep.
"""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
self._yaml_template: dict = None
self._service_instance_name: str = None
@@ -30,9 +30,9 @@ class YamlTemplateVfModuleAlaCarteInstantiateStep(YamlTemplateBaseStep):
if settings.CLOUD_REGION_TYPE == settings.K8S_REGION_TYPE:
# K8SProfileStep creates the requested profile and then calls
# YamlTemplateVnfAlaCarteInstantiateStep step
- self.add_step(K8SProfileStep(cleanup))
+ self.add_step(K8SProfileStep())
else:
- self.add_step(YamlTemplateVnfAlaCarteInstantiateStep(cleanup))
+ self.add_step(YamlTemplateVnfAlaCarteInstantiateStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/instantiate/vl_ala_carte.py b/src/onaptests/steps/instantiate/vl_ala_carte.py
index 022a8b2..414615a 100644
--- a/src/onaptests/steps/instantiate/vl_ala_carte.py
+++ b/src/onaptests/steps/instantiate/vl_ala_carte.py
@@ -16,17 +16,17 @@ from .service_ala_carte import YamlTemplateServiceAlaCarteInstantiateStep
class YamlTemplateVlAlaCarteInstantiateStep(YamlTemplateBaseStep):
"""Instantiate vl a'la carte using YAML template."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- YamlTemplateServiceAlaCarteInstantiateStep.
"""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
self._yaml_template: dict = None
self._service_instance_name: str = None
self._service_instance: ServiceInstance = None
- self.add_step(YamlTemplateServiceAlaCarteInstantiateStep(cleanup))
+ self.add_step(YamlTemplateServiceAlaCarteInstantiateStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/instantiate/vnf_ala_carte.py b/src/onaptests/steps/instantiate/vnf_ala_carte.py
index 379e285..a7ac5c3 100644
--- a/src/onaptests/steps/instantiate/vnf_ala_carte.py
+++ b/src/onaptests/steps/instantiate/vnf_ala_carte.py
@@ -14,17 +14,17 @@ from .service_ala_carte import YamlTemplateServiceAlaCarteInstantiateStep
class YamlTemplateVnfAlaCarteInstantiateStep(YamlTemplateBaseStep):
"""Instantiate vnf a'la carte using YAML template."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- YamlTemplateServiceAlaCarteInstantiateStep.
"""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
self._yaml_template: dict = None
self._service_instance_name: str = None
self._service_instance: ServiceInstance = None
- self.add_step(YamlTemplateServiceAlaCarteInstantiateStep(cleanup))
+ self.add_step(YamlTemplateServiceAlaCarteInstantiateStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/loop/clamp.py b/src/onaptests/steps/loop/clamp.py
index 502a7f0..245abc6 100644
--- a/src/onaptests/steps/loop/clamp.py
+++ b/src/onaptests/steps/loop/clamp.py
@@ -27,10 +27,10 @@ class ClampStep(YamlTemplateBaseStep):
count: int = 0
- def __init__(self, cleanup=False):
- super().__init__(cleanup=cleanup)
+ def __init__(self):
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
self._yaml_template: dict = None
- self.add_step(OnboardClampStep(cleanup=cleanup))
+ self.add_step(OnboardClampStep())
Clamp()
self.loop_instance = None
diff --git a/src/onaptests/steps/onboard/cds.py b/src/onaptests/steps/onboard/cds.py
index 5256eac..2074296 100644
--- a/src/onaptests/steps/onboard/cds.py
+++ b/src/onaptests/steps/onboard/cds.py
@@ -14,7 +14,6 @@ from onapsdk.configuration import settings
import urllib3
from onaptests.steps.base import BaseStep
-
from onaptests.utils.exceptions import OnapTestException
@@ -30,9 +29,9 @@ class CDSBaseStep(BaseStep, ABC):
class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep):
"""Expose CDS blueprintsprocessor port."""
- def __init__(self, cleanup: bool) -> None:
+ def __init__(self) -> None:
"""Initialize step."""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
self.service_name: str = "cds-blueprints-processor-http"
if settings.IN_CLUSTER:
config.load_incluster_config()
@@ -92,6 +91,7 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep):
else:
self._logger.debug("Service already patched, skip")
+ @BaseStep.store_state(cleanup=True)
def cleanup(self) -> None:
"""Step cleanup.
@@ -129,15 +129,15 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep):
class BootstrapBlueprintprocessor(CDSBaseStep):
"""Bootstrap blueprintsprocessor."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- ExposeCDSBlueprintprocessorNodePortStep.
"""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
if settings.EXPOSE_SERVICES_NODE_PORTS:
- self.add_step(ExposeCDSBlueprintprocessorNodePortStep(cleanup=cleanup))
+ self.add_step(ExposeCDSBlueprintprocessorNodePortStep())
@property
def description(self) -> str:
@@ -154,10 +154,10 @@ class BootstrapBlueprintprocessor(CDSBaseStep):
class DataDictionaryUploadStep(CDSBaseStep):
"""Upload data dictionaries to CDS step."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize data dictionary upload step."""
- super().__init__(cleanup=cleanup)
- self.add_step(BootstrapBlueprintprocessor(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(BootstrapBlueprintprocessor())
@property
def description(self) -> str:
@@ -180,10 +180,10 @@ class DataDictionaryUploadStep(CDSBaseStep):
class CbaEnrichStep(CDSBaseStep):
"""Enrich CBA file step."""
- def __init__(self, cleanup=False) -> None:
+ def __init__(self) -> None:
"""Initialize CBA enrichment step."""
- super().__init__(cleanup=cleanup)
- self.add_step(DataDictionaryUploadStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(DataDictionaryUploadStep())
@property
def description(self) -> str:
@@ -217,14 +217,14 @@ class CbaEnrichStep(CDSBaseStep):
class CbaPublishStep(CDSBaseStep):
"""Publish CBA file step."""
- def __init__(self, cleanup=False) -> None:
+ def __init__(self) -> None:
"""Initialize CBA publish step."""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
"""Let's skip enrichment if enriched CBA is already present"""
if Path.is_file(settings.CDS_CBA_UNENRICHED):
- self.add_step(CbaEnrichStep(cleanup=cleanup))
+ self.add_step(CbaEnrichStep())
elif settings.EXPOSE_SERVICES_NODE_PORTS:
- self.add_step(ExposeCDSBlueprintprocessorNodePortStep(cleanup=cleanup))
+ self.add_step(ExposeCDSBlueprintprocessorNodePortStep())
@property
def description(self) -> str:
@@ -247,10 +247,10 @@ class CbaPublishStep(CDSBaseStep):
class CbaProcessStep(CDSBaseStep):
"""Process CBA step."""
- def __init__(self, cleanup=False) -> None:
+ def __init__(self) -> None:
"""Initialize CBA process step."""
- super().__init__(cleanup=cleanup)
- self.add_step(CbaPublishStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(CbaPublishStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/onboard/clamp.py b/src/onaptests/steps/onboard/clamp.py
index c8984ba..7cb20ff 100644
--- a/src/onaptests/steps/onboard/clamp.py
+++ b/src/onaptests/steps/onboard/clamp.py
@@ -7,18 +7,18 @@ from onapsdk.sdc.vf import Vf
from onapsdk.configuration import settings
-from ..base import YamlTemplateBaseStep
+from ..base import BaseStep, YamlTemplateBaseStep
from .service import YamlTemplateVfOnboardStep
class OnboardClampStep(YamlTemplateBaseStep):
"""Onboard class to create CLAMP templates."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize Clamp Onboard object."""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
self._yaml_template: dict = None
- self.add_step(YamlTemplateVfOnboardStep(cleanup=cleanup))
+ self.add_step(YamlTemplateVfOnboardStep())
# if "service_name" in kwargs:
# self.service_name = kwargs['service_name']
# else:
diff --git a/src/onaptests/steps/onboard/cps.py b/src/onaptests/steps/onboard/cps.py
index e582489..55598bf 100644
--- a/src/onaptests/steps/onboard/cps.py
+++ b/src/onaptests/steps/onboard/cps.py
@@ -20,6 +20,10 @@ class CpsBaseStep(BaseStep, ABC):
class CreateCpsDataspaceStep(CpsBaseStep):
"""Step to create a dataspace."""
+ def __init__(self) -> None:
+ """Initialize step."""
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+
@property
def description(self) -> str:
"""Step description."""
@@ -47,14 +51,14 @@ class CreateCpsDataspaceStep(CpsBaseStep):
class CreateCpsSchemaSetStep(CpsBaseStep):
"""Step to check schema-set creation."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CreateCpsDataspaceStep.
"""
- super().__init__(cleanup)
- self.add_step(CreateCpsDataspaceStep(cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(CreateCpsDataspaceStep())
@property
def description(self) -> str:
@@ -87,14 +91,14 @@ class CreateCpsSchemaSetStep(CpsBaseStep):
class CreateCpsAnchorStep(CpsBaseStep):
"""Step to create an anchor."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CreateCpsSchemaSetStep.
"""
- super().__init__(cleanup)
- self.add_step(CreateCpsSchemaSetStep(cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(CreateCpsSchemaSetStep())
@property
def description(self) -> str:
@@ -130,14 +134,14 @@ class CreateCpsAnchorStep(CpsBaseStep):
class CreateCpsAnchorNodeStep(CpsBaseStep):
"""Step to check node on anchor creation."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CreateCpsAnchorStep.
"""
- super().__init__(cleanup)
- self.add_step(CreateCpsAnchorStep(cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(CreateCpsAnchorStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/onboard/msb_k8s.py b/src/onaptests/steps/onboard/msb_k8s.py
index 666de33..db8d934 100644
--- a/src/onaptests/steps/onboard/msb_k8s.py
+++ b/src/onaptests/steps/onboard/msb_k8s.py
@@ -10,16 +10,16 @@ from onaptests.steps.cloud.k8s_connectivity_info_create import K8SConnectivityIn
class CreateDefinitionStep(BaseStep):
"""Create definition step initialization."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CloudRegionCreateStep,
- K8SConnectivityInfoStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(CloudRegionCreateStep(cleanup=cleanup))
- self.add_step(K8SConnectivityInfoStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(CloudRegionCreateStep())
+ self.add_step(K8SConnectivityInfoStep())
self.definition: Definition = None
@property
@@ -45,14 +45,14 @@ class CreateDefinitionStep(BaseStep):
class CreateProfileStep(BaseStep):
"""Create profile step."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CreateDefinitionStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(CreateDefinitionStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(CreateDefinitionStep())
self.profile: Profile = None
@property
diff --git a/src/onaptests/steps/onboard/pnf.py b/src/onaptests/steps/onboard/pnf.py
index 1c76202..8e0cd12 100644
--- a/src/onaptests/steps/onboard/pnf.py
+++ b/src/onaptests/steps/onboard/pnf.py
@@ -11,7 +11,7 @@ from .vsp import VspOnboardStep, YamlTemplateVspOnboardStep
class PnfOnboardStep(BaseStep):
"""PNF onboard step."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Step initialization.
Substeps:
@@ -21,8 +21,8 @@ class PnfOnboardStep(BaseStep):
cleanup(bool, optional): Determines if cleanup action should be called.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(VspOnboardStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(VspOnboardStep())
@property
def description(self) -> str:
@@ -34,6 +34,13 @@ class PnfOnboardStep(BaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@BaseStep.store_state
def execute(self) -> None:
"""Onboard PNF in SDC.
@@ -72,7 +79,7 @@ class PnfOnboardStep(BaseStep):
class YamlTemplatePnfOnboardStep(YamlTemplateBaseStep):
"""PNF onboard using YAML template step."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Step initialization.
Substeps:
@@ -82,8 +89,8 @@ class YamlTemplatePnfOnboardStep(YamlTemplateBaseStep):
cleanup(bool, optional): Determines if cleanup action should be called.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(YamlTemplateVspOnboardStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(YamlTemplateVspOnboardStep())
@property
def description(self) -> str:
@@ -95,6 +102,13 @@ class YamlTemplatePnfOnboardStep(YamlTemplateBaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@property
def yaml_template(self) -> dict:
"""YAML template.
diff --git a/src/onaptests/steps/onboard/service.py b/src/onaptests/steps/onboard/service.py
index c0bec0d..be0f6fd 100644
--- a/src/onaptests/steps/onboard/service.py
+++ b/src/onaptests/steps/onboard/service.py
@@ -20,17 +20,17 @@ from .vf import VfOnboardStep, YamlTemplateVfOnboardStep
class ServiceOnboardStep(BaseStep):
"""Service onboard step."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- VfOnboardStep.
"""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
if settings.VF_NAME != "":
- self.add_step(VfOnboardStep(cleanup=cleanup))
+ self.add_step(VfOnboardStep())
if settings.PNF_NAME != "":
- self.add_step(PnfOnboardStep(cleanup=cleanup))
+ self.add_step(PnfOnboardStep())
@property
def description(self) -> str:
@@ -42,6 +42,13 @@ class ServiceOnboardStep(BaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@BaseStep.store_state
def execute(self):
"""Onboard service.
@@ -97,19 +104,19 @@ class ServiceOnboardStep(BaseStep):
class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
"""Service onboard using YAML template step."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- YamlTemplateVfOnboardStep.
"""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
self._yaml_template: dict = None
self._model_yaml_template: dict = None
if "vnfs" in self.yaml_template[self.service_name]:
- self.add_step(YamlTemplateVfOnboardStep(cleanup=cleanup))
+ self.add_step(YamlTemplateVfOnboardStep())
if "pnfs" in self.yaml_template[self.service_name]:
- self.add_step(YamlTemplatePnfOnboardStep(cleanup=cleanup))
+ self.add_step(YamlTemplatePnfOnboardStep())
@property
def description(self) -> str:
@@ -121,6 +128,13 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@property
def yaml_template(self) -> dict:
"""Step YAML template.
@@ -153,7 +167,7 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
if self.is_root:
if not self._model_yaml_template:
with open(settings.MODEL_YAML_TEMPLATE, "r") as model_yaml_template:
- self._model_yaml_template: dict = load(model_yaml_template)
+ self._model_yaml_template: dict = load(model_yaml_template, SafeLoader)
return self._model_yaml_template
return self.parent.model_yaml_template
@@ -269,9 +283,8 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
@YamlTemplateBaseStep.store_state(cleanup=True)
def cleanup(self) -> None:
"""Cleanup service onboard step."""
- if settings.SDC_CLEANUP:
- service: Service = Service(name=self.service_name)
- if service.exists():
- service.archive()
- service.delete()
- super().cleanup()
+ service: Service = Service(name=self.service_name)
+ if service.exists():
+ service.archive()
+ service.delete()
+ super().cleanup()
diff --git a/src/onaptests/steps/onboard/vendor.py b/src/onaptests/steps/onboard/vendor.py
index b3761d2..ae93738 100644
--- a/src/onaptests/steps/onboard/vendor.py
+++ b/src/onaptests/steps/onboard/vendor.py
@@ -7,6 +7,10 @@ from ..base import BaseStep
class VendorOnboardStep(BaseStep):
"""Vendor onboard step."""
+ def __init__(self):
+ """Initialize step."""
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+
@property
def description(self) -> str:
"""Step description."""
@@ -17,6 +21,13 @@ class VendorOnboardStep(BaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@BaseStep.store_state
def execute(self):
"""Onboard vendor.
diff --git a/src/onaptests/steps/onboard/vf.py b/src/onaptests/steps/onboard/vf.py
index b614fd5..3fc7443 100644
--- a/src/onaptests/steps/onboard/vf.py
+++ b/src/onaptests/steps/onboard/vf.py
@@ -13,14 +13,14 @@ from .vsp import VspOnboardStep, YamlTemplateVspOnboardStep
class VfOnboardStep(BaseStep):
"""Vf onboard step."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- VspOnboardStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(VspOnboardStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(VspOnboardStep())
@property
def description(self) -> str:
@@ -32,6 +32,13 @@ class VfOnboardStep(BaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@BaseStep.store_state
def execute(self):
"""Onboard Vf.
@@ -59,14 +66,14 @@ class VfOnboardStep(BaseStep):
class YamlTemplateVfOnboardStep(YamlTemplateBaseStep):
"""Vf onboard using YAML template step."""
- def __init__(self, cleanup=False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- YamlTemplateVspOnboardStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(YamlTemplateVspOnboardStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(YamlTemplateVspOnboardStep())
@property
def description(self) -> str:
@@ -78,6 +85,13 @@ class YamlTemplateVfOnboardStep(YamlTemplateBaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@property
def yaml_template(self) -> dict:
"""YAML template.
diff --git a/src/onaptests/steps/onboard/vsp.py b/src/onaptests/steps/onboard/vsp.py
index 577b1cf..06e0fa2 100644
--- a/src/onaptests/steps/onboard/vsp.py
+++ b/src/onaptests/steps/onboard/vsp.py
@@ -10,14 +10,14 @@ from .vendor import VendorOnboardStep
class VspOnboardStep(BaseStep):
"""Vsp onboard step."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- VendorOnboardStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(VendorOnboardStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(VendorOnboardStep())
@property
def description(self) -> str:
@@ -29,6 +29,13 @@ class VspOnboardStep(BaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@BaseStep.store_state
def execute(self):
"""Onboard Vsp.
@@ -58,14 +65,14 @@ class VspOnboardStep(BaseStep):
class YamlTemplateVspOnboardStep(YamlTemplateBaseStep):
"""Vsp onboard using YAML template step."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- VendorOnboardStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(VendorOnboardStep(cleanup=cleanup))
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+ self.add_step(VendorOnboardStep())
@property
def description(self) -> str:
@@ -77,6 +84,13 @@ class YamlTemplateVspOnboardStep(YamlTemplateBaseStep):
"""Component name."""
return "SDC"
+ def check_preconditions(self, cleanup=False) -> bool:
+ if not super().check_preconditions(cleanup):
+ return False
+ if cleanup:
+ return settings.SDC_CLEANUP
+ return True
+
@property
def yaml_template(self) -> dict:
"""YAML template.
diff --git a/src/onaptests/steps/simulator/cds_mockserver.py b/src/onaptests/steps/simulator/cds_mockserver.py
index 9fc4162..75d0767 100644
--- a/src/onaptests/steps/simulator/cds_mockserver.py
+++ b/src/onaptests/steps/simulator/cds_mockserver.py
@@ -14,14 +14,14 @@ from onaptests.utils.exceptions import OnapTestException
class CdsMockserverCnfConfigureStep(BaseStep):
"""Configure cds mockserver expectations."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CreateInstanceStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(CreateInstanceStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(CreateInstanceStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py b/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py
index 2a4f47e..5adba2c 100644
--- a/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py
+++ b/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py
@@ -17,14 +17,14 @@ from onaptests.utils.exceptions import EnvironmentPreparationException, OnapTest
class PnfSimulatorCnfRegisterStep(BaseStep):
"""PNF simulator registration step."""
- def __init__(self, cleanup: bool = False) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CreateInstanceStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(CreateInstanceStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(CreateInstanceStep())
@property
def description(self) -> str: