From af615065352ab1bb059f221cc1fdb0b9b05eacac Mon Sep 17 00:00:00 2001 From: Lukasz Rajewski Date: Thu, 8 Feb 2024 20:18:28 +0100 Subject: Prevent cleanup of parent when substep has failed Prevent cleanup of parent when substep has failed Issue-ID: TEST-402 Signed-off-by: Lukasz Rajewski Change-Id: I2ed0aaaab9e43fef56685958b03fd796df25bc3b --- src/onaptests/steps/base.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/onaptests/steps/base.py b/src/onaptests/steps/base.py index d788fd4..00229ba 100644 --- a/src/onaptests/steps/base.py +++ b/src/onaptests/steps/base.py @@ -46,6 +46,7 @@ class StoreStateHandler(ABC): self._start_cleanup_time = time.time() try: if (self._cleanup and self._state_execute and + (not self.has_substeps or self._substeps_executed) and (self._is_validation_only or self.check_preconditions(cleanup=True))): self._log_execution_state("START", cleanup) @@ -160,6 +161,7 @@ class BaseStep(StoreStateHandler, ABC): self._state_clean: bool = False self._nesting_level: int = 0 self._break_on_error: bool = break_on_error + self._substeps_executed: bool = False self._is_validation_only = settings.IF_VALIDATION self._is_force_cleanup = os.environ.get(IF_FORCE_CLEANUP) is not None @@ -192,6 +194,18 @@ class BaseStep(StoreStateHandler, ABC): """ return self._parent + @property + def has_substeps(self) -> bool: + """Has step substeps. + + If sdc has substeps. + + Returns: + bool: True if step has substeps + + """ + return len(self._steps) > 0 + @property def is_executed(self) -> bool: """Is step executed. @@ -348,6 +362,7 @@ class BaseStep(StoreStateHandler, ABC): if substep_error and self._break_on_error: raise SubstepExecutionException("Cannot continue due to failed substeps") self._log_execution_state("CONTINUE") + self._substeps_executed = True self._start_execution_time = time.time() def _cleanup_substeps(self) -> None: -- cgit 1.2.3-korg