summaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/runners
diff options
context:
space:
mode:
authorQiLiang <liangqi1@huawei.com>2015-10-21 12:29:53 +0000
committerQiLiang <liangqi1@huawei.com>2015-10-27 03:34:28 +0000
commit2e1094d4aee93180126d3ce86db3cc7df2e87bc5 (patch)
tree221e98fd325ff6fcb4fbbb3e656a3789f3a77342 /yardstick/benchmark/runners
parent884926d05f435217c7dac038b3bfbd7e9d05826b (diff)
Heat context code refactor part 2
Heat context code refactor to cater for the evolution of the Yardstick framework. Refactor runner_cfg host/target info handle, as specified at https://etherpad.opnfv.org/p/yardstick_framework step 4. Get general Context info (use Context.get). Before this refactor host and target vm must have the same user name and ssh key, that is not general enough for later extension. test_case.yaml do NOT need to change. JIRA: YARDSTICK-168 Change-Id: I5cfe868f3c6f633214ef550bc9676fe1de0709db Signed-off-by: QiLiang <liangqi1@huawei.com>
Diffstat (limited to 'yardstick/benchmark/runners')
-rwxr-xr-xyardstick/benchmark/runners/arithmetic.py13
-rwxr-xr-xyardstick/benchmark/runners/base.py6
-rw-r--r--yardstick/benchmark/runners/duration.py13
-rwxr-xr-xyardstick/benchmark/runners/iteration.py13
-rw-r--r--yardstick/benchmark/runners/sequence.py13
5 files changed, 31 insertions, 27 deletions
diff --git a/yardstick/benchmark/runners/arithmetic.py b/yardstick/benchmark/runners/arithmetic.py
index 68c8bfdef..af2303479 100755
--- a/yardstick/benchmark/runners/arithmetic.py
+++ b/yardstick/benchmark/runners/arithmetic.py
@@ -22,7 +22,7 @@ from yardstick.benchmark.runners import base
LOG = logging.getLogger(__name__)
-def _worker_process(queue, cls, method_name, scenario_cfg):
+def _worker_process(queue, cls, method_name, scenario_cfg, context_cfg):
sequence = 1
@@ -40,12 +40,13 @@ def _worker_process(queue, cls, method_name, scenario_cfg):
LOG.info("worker START, step(%s, %d, %d, %d), class %s",
arg_name, start, stop, step, cls)
- benchmark = cls(runner_cfg)
+ benchmark = cls(scenario_cfg, context_cfg)
benchmark.setup()
method = getattr(benchmark, method_name)
queue.put({'runner_id': runner_cfg['runner_id'],
- 'scenario_cfg': scenario_cfg})
+ 'scenario_cfg': scenario_cfg,
+ 'context_cfg': context_cfg})
sla_action = None
if "sla" in scenario_cfg:
@@ -63,7 +64,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg):
errors = ""
try:
- method(scenario_cfg, data)
+ method(data)
except AssertionError as assertion:
# SLA validation failed in scenario, determine what to do now
if sla_action == "assert":
@@ -129,8 +130,8 @@ class ArithmeticRunner(base.Runner):
__execution_type__ = 'Arithmetic'
- def _run_benchmark(self, cls, method, scenario_cfg):
+ def _run_benchmark(self, cls, method, scenario_cfg, context_cfg):
self.process = multiprocessing.Process(
target=_worker_process,
- args=(self.result_queue, cls, method, scenario_cfg))
+ args=(self.result_queue, cls, method, scenario_cfg, context_cfg))
self.process.start()
diff --git a/yardstick/benchmark/runners/base.py b/yardstick/benchmark/runners/base.py
index cc8c93cb6..d443806a7 100755
--- a/yardstick/benchmark/runners/base.py
+++ b/yardstick/benchmark/runners/base.py
@@ -169,7 +169,6 @@ class Runner(object):
Runner.release(runner)
def __init__(self, config, queue):
- self.context = {}
self.config = config
self.periodic_action_process = None
self.result_queue = queue
@@ -189,7 +188,8 @@ class Runner(object):
log.debug("post-stop data: \n%s" % data)
self.result_queue.put({'post-stop-action-data': data})
- def run(self, scenario_type, scenario_cfg):
+ def run(self, scenario_cfg, context_cfg):
+ scenario_type = scenario_cfg["type"]
class_name = base_scenario.Scenario.get(scenario_type)
path_split = class_name.split(".")
module_path = ".".join(path_split[:-1])
@@ -228,7 +228,7 @@ class Runner(object):
self.result_queue))
self.periodic_action_process.start()
- self._run_benchmark(cls, "run", scenario_cfg)
+ self._run_benchmark(cls, "run", scenario_cfg, context_cfg)
def join(self):
self.process.join()
diff --git a/yardstick/benchmark/runners/duration.py b/yardstick/benchmark/runners/duration.py
index e4ad037af..40e0aa708 100644
--- a/yardstick/benchmark/runners/duration.py
+++ b/yardstick/benchmark/runners/duration.py
@@ -21,7 +21,7 @@ from yardstick.benchmark.runners import base
LOG = logging.getLogger(__name__)
-def _worker_process(queue, cls, method_name, scenario_cfg):
+def _worker_process(queue, cls, method_name, scenario_cfg, context_cfg):
sequence = 1
@@ -33,7 +33,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg):
runner_cfg['runner_id'] = os.getpid()
- benchmark = cls(runner_cfg)
+ benchmark = cls(scenario_cfg, context_cfg)
benchmark.setup()
method = getattr(benchmark, method_name)
@@ -42,7 +42,8 @@ def _worker_process(queue, cls, method_name, scenario_cfg):
sla_action = scenario_cfg["sla"].get("action", "assert")
queue.put({'runner_id': runner_cfg['runner_id'],
- 'scenario_cfg': scenario_cfg})
+ 'scenario_cfg': scenario_cfg,
+ 'context_cfg': context_cfg})
start = time.time()
while True:
@@ -54,7 +55,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg):
errors = ""
try:
- method(scenario_cfg, data)
+ method(data)
except AssertionError as assertion:
# SLA validation failed in scenario, determine what to do now
if sla_action == "assert":
@@ -109,8 +110,8 @@ If the scenario ends before the time has elapsed, it will be started again.
'''
__execution_type__ = 'Duration'
- def _run_benchmark(self, cls, method, scenario_cfg):
+ def _run_benchmark(self, cls, method, scenario_cfg, context_cfg):
self.process = multiprocessing.Process(
target=_worker_process,
- args=(self.result_queue, cls, method, scenario_cfg))
+ args=(self.result_queue, cls, method, scenario_cfg, context_cfg))
self.process.start()
diff --git a/yardstick/benchmark/runners/iteration.py b/yardstick/benchmark/runners/iteration.py
index b6d861d6c..077e0e813 100755
--- a/yardstick/benchmark/runners/iteration.py
+++ b/yardstick/benchmark/runners/iteration.py
@@ -21,7 +21,7 @@ from yardstick.benchmark.runners import base
LOG = logging.getLogger(__name__)
-def _worker_process(queue, cls, method_name, scenario_cfg):
+def _worker_process(queue, cls, method_name, scenario_cfg, context_cfg):
sequence = 1
@@ -33,12 +33,13 @@ def _worker_process(queue, cls, method_name, scenario_cfg):
runner_cfg['runner_id'] = os.getpid()
- benchmark = cls(runner_cfg)
+ benchmark = cls(scenario_cfg, context_cfg)
benchmark.setup()
method = getattr(benchmark, method_name)
queue.put({'runner_id': runner_cfg['runner_id'],
- 'scenario_cfg': scenario_cfg})
+ 'scenario_cfg': scenario_cfg,
+ 'context_cfg': context_cfg})
sla_action = None
if "sla" in scenario_cfg:
@@ -53,7 +54,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg):
errors = ""
try:
- method(scenario_cfg, data)
+ method(data)
except AssertionError as assertion:
# SLA validation failed in scenario, determine what to do now
if sla_action == "assert":
@@ -108,8 +109,8 @@ If the scenario ends before the time has elapsed, it will be started again.
'''
__execution_type__ = 'Iteration'
- def _run_benchmark(self, cls, method, scenario_cfg):
+ def _run_benchmark(self, cls, method, scenario_cfg, context_cfg):
self.process = multiprocessing.Process(
target=_worker_process,
- args=(self.result_queue, cls, method, scenario_cfg))
+ args=(self.result_queue, cls, method, scenario_cfg, context_cfg))
self.process.start()
diff --git a/yardstick/benchmark/runners/sequence.py b/yardstick/benchmark/runners/sequence.py
index 29f86e19c..a410eea0e 100644
--- a/yardstick/benchmark/runners/sequence.py
+++ b/yardstick/benchmark/runners/sequence.py
@@ -22,7 +22,7 @@ from yardstick.benchmark.runners import base
LOG = logging.getLogger(__name__)
-def _worker_process(queue, cls, method_name, scenario_cfg):
+def _worker_process(queue, cls, method_name, scenario_cfg, context_cfg):
sequence = 1
@@ -42,12 +42,13 @@ def _worker_process(queue, cls, method_name, scenario_cfg):
LOG.info("worker START, sequence_values(%s, %s), class %s",
arg_name, sequence_values, cls)
- benchmark = cls(runner_cfg)
+ benchmark = cls(scenario_cfg, context_cfg)
benchmark.setup()
method = getattr(benchmark, method_name)
queue.put({'runner_id': runner_cfg['runner_id'],
- 'scenario_cfg': scenario_cfg})
+ 'scenario_cfg': scenario_cfg,
+ 'context_cfg': context_cfg})
sla_action = None
if "sla" in scenario_cfg:
@@ -63,7 +64,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg):
errors = ""
try:
- method(scenario_cfg, data)
+ method(data)
except AssertionError as assertion:
# SLA validation failed in scenario, determine what to do now
if sla_action == "assert":
@@ -121,8 +122,8 @@ class SequenceRunner(base.Runner):
__execution_type__ = 'Sequence'
- def _run_benchmark(self, cls, method, scenario_cfg):
+ def _run_benchmark(self, cls, method, scenario_cfg, context_cfg):
self.process = multiprocessing.Process(
target=_worker_process,
- args=(self.result_queue, cls, method, scenario_cfg))
+ args=(self.result_queue, cls, method, scenario_cfg, context_cfg))
self.process.start()