From bf892d9cf62b6bc64ea76d8b69a8fe3751cabd75 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Mon, 12 Mar 2018 14:14:57 +0000 Subject: Add "Scenario" class wait methods for runners "Duration" and "Iteration" runners execute a passive wait during the execution of the work process. This wait time is done at the end of the scenario "run" method execution. This patch adds a pre-run and post-run wait period, which will depends on the Scenario executed. The wait time will be always the same, but the execution order (pre-wait time, run method, post-wait time) will depends on the Scenario. By default, any Scenario will execute the "run" method and them will wait the specified time. NetworkServicesTestCase Scenario will wait the specified time and them will execute the "run" method to retrieve the KPIs. JIRA: YARDSTICK-1067 Change-Id: I6ad6bfc6978815b6b2d4df63f2ac2f8815fb5b8a Signed-off-by: Rodolfo Alonso Hernandez --- yardstick/benchmark/scenarios/base.py | 9 +++++++++ yardstick/benchmark/scenarios/networking/vnf_generic.py | 9 +++++++++ 2 files changed, 18 insertions(+) (limited to 'yardstick/benchmark/scenarios') diff --git a/yardstick/benchmark/scenarios/base.py b/yardstick/benchmark/scenarios/base.py index 3b88ade7d..58a02805c 100644 --- a/yardstick/benchmark/scenarios/base.py +++ b/yardstick/benchmark/scenarios/base.py @@ -14,6 +14,7 @@ # under the License. import abc +import time import six from stevedore import extension @@ -52,6 +53,14 @@ class Scenario(object): """Default teardown implementation for Scenario classes""" pass + def pre_run_wait_time(self, time_seconds): + """Time waited before executing the run method""" + pass + + def post_run_wait_time(self, time_seconds): + """Time waited after executing the run method""" + time.sleep(time_seconds) + @staticmethod def get_types(): """return a list of known runner type (class) names""" diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py index 0e4785294..be2fa3f3b 100644 --- a/yardstick/benchmark/scenarios/networking/vnf_generic.py +++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py @@ -14,6 +14,7 @@ import copy import logging +import time import ipaddress from itertools import chain @@ -484,3 +485,11 @@ class NetworkServiceTestCase(scenario_base.Scenario): # https://bugs.python.org/issue9400 LOG.exception("") raise RuntimeError("Error in teardown") + + def pre_run_wait_time(self, time_seconds): + """Time waited before executing the run method""" + time.sleep(time_seconds) + + def post_run_wait_time(self, time_seconds): + """Time waited after executing the run method""" + pass -- cgit 1.2.3-korg