diff options
author | Lukasz Rajewski <lukasz.rajewski@t-mobile.pl> | 2024-02-08 20:18:28 +0100 |
---|---|---|
committer | Lukasz Rajewski <lukasz.rajewski@t-mobile.pl> | 2024-02-08 20:23:24 +0100 |
commit | af615065352ab1bb059f221cc1fdb0b9b05eacac (patch) | |
tree | fb62b85b3d2d41e83ae512f0a4dee57770ee6428 | |
parent | a032fbea3cdd556243bd1bb4e92c2a77baef316f (diff) |
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 <lukasz.rajewski@t-mobile.pl>
Change-Id: I2ed0aaaab9e43fef56685958b03fd796df25bc3b
-rw-r--r-- | src/onaptests/steps/base.py | 15 |
1 files changed, 15 insertions, 0 deletions
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 @@ -193,6 +195,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: |