From 4bccbde3060931c8fcf61fbf8b61db4a85b3200e Mon Sep 17 00:00:00 2001 From: Lukasz Rajewski Date: Thu, 27 Jul 2023 14:59:15 +0000 Subject: Change cleanup process of tests Issue-ID: TEST-402 Signed-off-by: Lukasz Rajewski Change-Id: Iffe3aeaa4eab6adcabc94d143d1f94a684cd4657 --- src/onaptests/steps/onboard/pnf.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'src/onaptests/steps/onboard/pnf.py') 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. -- cgit 1.2.3-korg