summaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/core/task.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark/core/task.py')
-rw-r--r--yardstick/benchmark/core/task.py114
1 files changed, 62 insertions, 52 deletions
diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py
index 75703cf50..53298d8d3 100644
--- a/yardstick/benchmark/core/task.py
+++ b/yardstick/benchmark/core/task.py
@@ -125,9 +125,10 @@ class Task(object): # pragma: no cover
except KeyboardInterrupt:
raise
except Exception:
- LOG.exception("Running test case %s failed!", case_name)
+ LOG.error('Testcase: "%s" FAILED!!!', case_name, exc_info=True)
testcases[case_name] = {'criteria': 'FAIL', 'tc_data': []}
else:
+ LOG.info('Testcase: "%s" SUCCESS!!!', case_name)
testcases[case_name] = {'criteria': 'PASS', 'tc_data': data}
if args.keep_deploy:
@@ -259,23 +260,23 @@ class Task(object): # pragma: no cover
# Wait for runners to finish
for runner in runners:
- status = runner_join(runner)
+ status = runner_join(runner, self.outputs, result)
if status != 0:
- raise RuntimeError
- self.outputs.update(runner.get_output())
- result.extend(runner.get_result())
+ raise RuntimeError(
+ "{0} runner status {1}".format(runner.__execution_type__, status))
LOG.info("Runner ended, output in %s", output_file)
else:
# run serially
for scenario in scenarios:
if not _is_background_scenario(scenario):
runner = self.run_one_scenario(scenario, output_file)
- status = runner_join(runner)
+ status = runner_join(runner, self.outputs, result)
if status != 0:
- LOG.error('Scenario: %s ERROR', scenario.get('type'))
- raise RuntimeError
- self.outputs.update(runner.get_output())
- result.extend(runner.get_result())
+ LOG.error('Scenario NO.%s: "%s" ERROR!',
+ scenarios.index(scenario) + 1,
+ scenario.get('type'))
+ raise RuntimeError(
+ "{0} runner status {1}".format(runner.__execution_type__, status))
LOG.info("Runner ended, output in %s", output_file)
# Abort background runners
@@ -284,15 +285,13 @@ class Task(object): # pragma: no cover
# Wait for background runners to finish
for runner in background_runners:
- status = runner.join(JOIN_TIMEOUT)
+ status = runner.join(self.outputs, result, JOIN_TIMEOUT)
if status is None:
# Nuke if it did not stop nicely
base_runner.Runner.terminate(runner)
- runner.join(JOIN_TIMEOUT)
+ runner.join(self.outputs, result, JOIN_TIMEOUT)
base_runner.Runner.release(runner)
- self.outputs.update(runner.get_output())
- result.extend(runner.get_result())
print("Background task ended")
return result
@@ -325,23 +324,30 @@ class Task(object): # pragma: no cover
# TODO support get multi hosts/vms info
context_cfg = {}
- if "host" in scenario_cfg:
- context_cfg['host'] = Context.get_server(scenario_cfg["host"])
+ server_name = scenario_cfg.get('options', {}).get('server_name', {})
- if "target" in scenario_cfg:
- if is_ip_addr(scenario_cfg["target"]):
- context_cfg['target'] = {}
- context_cfg['target']["ipaddr"] = scenario_cfg["target"]
+ def config_context_target(cfg):
+ target = cfg['target']
+ if is_ip_addr(target):
+ context_cfg['target'] = {"ipaddr": target}
else:
- context_cfg['target'] = Context.get_server(
- scenario_cfg["target"])
- if self._is_same_heat_context(scenario_cfg["host"],
- scenario_cfg["target"]):
- context_cfg["target"]["ipaddr"] = \
- context_cfg["target"]["private_ip"]
+ context_cfg['target'] = Context.get_server(target)
+ if self._is_same_context(cfg["host"], target):
+ context_cfg['target']["ipaddr"] = context_cfg['target']["private_ip"]
else:
- context_cfg["target"]["ipaddr"] = \
- context_cfg["target"]["ip"]
+ context_cfg['target']["ipaddr"] = context_cfg['target']["ip"]
+
+ host_name = server_name.get('host', scenario_cfg.get('host'))
+ if host_name:
+ context_cfg['host'] = Context.get_server(host_name)
+
+ for item in [server_name, scenario_cfg]:
+ try:
+ config_context_target(item)
+ except KeyError:
+ pass
+ else:
+ break
if "targets" in scenario_cfg:
ip_list = []
@@ -351,8 +357,8 @@ class Task(object): # pragma: no cover
context_cfg['target'] = {}
else:
context_cfg['target'] = Context.get_server(target)
- if self._is_same_heat_context(scenario_cfg["host"],
- target):
+ if self._is_same_context(scenario_cfg["host"],
+ target):
ip_list.append(context_cfg["target"]["private_ip"])
else:
ip_list.append(context_cfg["target"]["ip"])
@@ -370,7 +376,7 @@ class Task(object): # pragma: no cover
return runner
- def _is_same_heat_context(self, host_attr, target_attr):
+ def _is_same_context(self, host_attr, target_attr):
"""check if two servers are in the same heat context
host_attr: either a name for a server created by yardstick or a dict
with attribute name mapping when using external heat templates
@@ -378,7 +384,7 @@ class Task(object): # pragma: no cover
with attribute name mapping when using external heat templates
"""
for context in self.contexts:
- if context.__context_type__ != "Heat":
+ if context.__context_type__ not in {"Heat", "Kubernetes"}:
continue
host = context._get_server(host_attr)
@@ -635,9 +641,14 @@ def get_networks_from_nodes(nodes):
return networks
-def runner_join(runner):
- """join (wait for) a runner, exit process at runner failure"""
- status = runner.join()
+def runner_join(runner, outputs, result):
+ """join (wait for) a runner, exit process at runner failure
+ :param outputs:
+ :type outputs: dict
+ :param result:
+ :type result: list
+ """
+ status = runner.join(outputs, result)
base_runner.Runner.release(runner)
return status
@@ -669,25 +680,24 @@ def parse_task_args(src_name, args):
def change_server_name(scenario, suffix):
- try:
- host = scenario['host']
- except KeyError:
- pass
- else:
- try:
- host['name'] += suffix
- except TypeError:
- scenario['host'] += suffix
- try:
- target = scenario['target']
- except KeyError:
- pass
- else:
+ def add_suffix(cfg, key):
try:
- target['name'] += suffix
- except TypeError:
- scenario['target'] += suffix
+ value = cfg[key]
+ except KeyError:
+ pass
+ else:
+ try:
+ value['name'] += suffix
+ except TypeError:
+ cfg[key] += suffix
+
+ server_name = scenario.get('options', {}).get('server_name', {})
+
+ add_suffix(scenario, 'host')
+ add_suffix(scenario, 'target')
+ add_suffix(server_name, 'host')
+ add_suffix(server_name, 'target')
try:
key = 'targets'