aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/base.py
diff options
context:
space:
mode:
authorMichal Jagiello <michal.jagiello@t-mobile.pl>2021-01-12 20:30:16 +0000
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2021-01-12 20:39:04 +0000
commit1b5383b287358f97ecee424b3dc9432c519e1090 (patch)
treefb4c7d7fa1a3565c8d79eeff5710df741d94c886 /src/onaptests/steps/base.py
parentd089e89005df1b4b3b6238a2937e23791c07d9ae (diff)
Fix steps time measurement
Substeps execution time is not stored with the right time of step execution Issue-ID: TEST-292 Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl> Change-Id: I58e2aecb1f3cfb1a2bf78a438fc3d508ecf83cc1
Diffstat (limited to 'src/onaptests/steps/base.py')
-rw-r--r--src/onaptests/steps/base.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/onaptests/steps/base.py b/src/onaptests/steps/base.py
index 9e1c991..aa2be6a 100644
--- a/src/onaptests/steps/base.py
+++ b/src/onaptests/steps/base.py
@@ -40,6 +40,7 @@ class BaseStep(ABC):
self._cleanup: bool = cleanup
self._parent: "BaseStep" = None
self._reports_collection: ReportsCollection = None
+ self._start_time: float = None
def add_step(self, step: "BaseStep") -> None:
"""Add substep.
@@ -122,7 +123,6 @@ class BaseStep(ABC):
def store_state(cls, fun):
def wrapper(self, *args, **kwargs):
try:
- start_time: float = time.time()
ret = fun(self, *args, **kwargs)
execution_status: ReportStepStatus = ReportStepStatus.PASS
return ret
@@ -130,24 +130,29 @@ class BaseStep(ABC):
execution_status: ReportStepStatus = ReportStepStatus.FAIL
raise
finally:
+ if not self._start_time:
+ self._logger.error("No execution start time saved for %s step. Fix it by call `super.execute()` "
+ "in step class `execute()` method definition")
+ self._start_time = time.time()
self.reports_collection.put(
Report(
step_description=f"[{self.component}] {self.name}: {self.description}",
step_execution_status=execution_status,
- step_execution_duration=time.time() - start_time
+ step_execution_duration=time.time() - self._start_time
)
)
return wrapper
def execute(self) -> None:
- """Step's action.
+ """Step's action execution.
Run all substeps action before it's own action.
- Override this method and remember to call `super().action()` before.
+ Override this method and remember to call `super().execute()` before.
"""
for step in self._steps:
step.execute()
+ self._start_time = time.time()
def cleanup(self) -> None:
"""Step's cleanup.