aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/cmd
diff options
context:
space:
mode:
authorJo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>2015-12-11 15:50:22 +0100
committerJörgen Karlsson <jorgen.w.karlsson@ericsson.com>2015-12-15 17:12:55 +0000
commit05c1840c9c4dda154c9c5d00ff3cd23ba202330b (patch)
treee440c79354739c5a9921757226e9d9128ee5766d /yardstick/cmd
parent3dfc4babd729b64757608945536e180e8c8ef271 (diff)
Add run_in_background attribute to scenarios
This change adds the possibility to run scenarios as "background tasks". Background scenarios/tasks: - are started before all "normal scenarios" - runs in parallel with "normal scenarios" - terminates when all "normal scenarios" have completed their tasks They are intended as a way to perform background tasks, e.g. collect data such as cpuload etc, in parallel with the execution of normal benchmarking scenarios. Note that we already have the 'run_in_parallel' attribute but this attribute has a couple of issues and do not solve all the uses cases. Change-Id: I9c5230bfdbbb66030f57b658ce1db87ff2c2d62b Signed-off-by: Jo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>
Diffstat (limited to 'yardstick/cmd')
-rwxr-xr-xyardstick/cmd/commands/task.py41
1 files changed, 37 insertions, 4 deletions
diff --git a/yardstick/cmd/commands/task.py b/yardstick/cmd/commands/task.py
index d6cd6984c..a56824aac 100755
--- a/yardstick/cmd/commands/task.py
+++ b/yardstick/cmd/commands/task.py
@@ -16,6 +16,7 @@ import atexit
import ipaddress
import time
import logging
+from itertools import ifilter
from yardstick.benchmark.contexts.base import Context
from yardstick.benchmark.runners import base as base_runner
from yardstick.common.task_template import TaskTemplate
@@ -108,11 +109,20 @@ class TaskCommands(object):
for context in Context.list:
context.deploy()
+ background_runners = []
+
+ # Start all background scenarios
+ for scenario in ifilter(_is_background_scenario, scenarios):
+ scenario["runner"] = dict(type="Duration", duration=1000000000)
+ runner = run_one_scenario(scenario, output_file)
+ background_runners.append(runner)
+
runners = []
if run_in_parallel:
for scenario in scenarios:
- runner = run_one_scenario(scenario, output_file)
- runners.append(runner)
+ if not _is_background_scenario(scenario):
+ runner = run_one_scenario(scenario, output_file)
+ runners.append(runner)
# Wait for runners to finish
for runner in runners:
@@ -121,9 +131,25 @@ class TaskCommands(object):
else:
# run serially
for scenario in scenarios:
- runner = run_one_scenario(scenario, output_file)
+ if not _is_background_scenario(scenario):
+ runner = run_one_scenario(scenario, output_file)
+ runner_join(runner)
+ print "Runner ended, output in", output_file
+
+ # Abort background runners
+ for runner in background_runners:
+ runner.abort()
+
+ # Wait for background runners to finish
+ for runner in background_runners:
+ if runner.join(timeout=60) is None:
+ # Nuke if it did not stop nicely
+ base_runner.Runner.terminate(runner)
runner_join(runner)
- print "Runner ended, output in", output_file
+ else:
+ base_runner.Runner.release(runner)
+ print "Background task ended"
+
# TODO: Move stuff below into TaskCommands class !?
@@ -280,6 +306,13 @@ def _is_same_heat_context(host_attr, target_attr):
return False
+def _is_background_scenario(scenario):
+ if "run_in_background" in scenario:
+ return scenario["run_in_background"]
+ else:
+ return False
+
+
def run_one_scenario(scenario_cfg, output_file):
'''run one scenario using context'''
runner_cfg = scenario_cfg["runner"]