Merge "Pass parameters between scenarios"
[yardstick.git] / yardstick / benchmark / runners / arithmetic.py
index 956c3ff..7ec5933 100755 (executable)
 # yardstick comment: this is a modified copy of
 # rally/rally/benchmark/runners/constant.py
 
-'''A runner that every run arithmetically steps specified input value(s) to
+"""A runner that every run arithmetically steps specified input value(s) to
 the scenario. This just means step value(s) is added to the previous value(s).
 It is possible to combine several named input values and run with those either
 as nested for loops or combine each i:th index of each "input value list"
 until the end of the shortest list is reached (optimally all lists should be
 defined with the same number of values when using such iter_type).
-'''
+"""
 
 from __future__ import absolute_import
 
@@ -42,7 +42,7 @@ LOG = logging.getLogger(__name__)
 
 
 def _worker_process(queue, cls, method_name, scenario_cfg,
-                    context_cfg, aborted):
+                    context_cfg, aborted, output_queue):
 
     sequence = 1
 
@@ -108,7 +108,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg,
         errors = ""
 
         try:
-            method(data)
+            result = method(data)
         except AssertionError as assertion:
             # SLA validation failed in scenario, determine what to do now
             if sla_action == "assert":
@@ -119,6 +119,9 @@ def _worker_process(queue, cls, method_name, scenario_cfg,
         except Exception as e:
             errors = traceback.format_exc()
             LOG.exception(e)
+        else:
+            if result:
+                output_queue.put(result)
 
         time.sleep(interval)
 
@@ -139,7 +142,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg,
 
         sequence += 1
 
-        if (errors and sla_action is None):
+        if errors and sla_action is None:
             break
 
     benchmark.teardown()
@@ -147,7 +150,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg,
 
 
 class ArithmeticRunner(base.Runner):
-    '''Run a scenario arithmetically stepping input value(s)
+    """Run a scenario arithmetically stepping input value(s)
 
   Parameters
     interval - time to wait between each scenario invocation
@@ -180,7 +183,7 @@ class ArithmeticRunner(base.Runner):
           default: none
     -
       name - and so on......
-    '''
+    """
 
     __execution_type__ = 'Arithmetic'
 
@@ -188,5 +191,5 @@ class ArithmeticRunner(base.Runner):
         self.process = multiprocessing.Process(
             target=_worker_process,
             args=(self.result_queue, cls, method, scenario_cfg,
-                  context_cfg, self.aborted))
+                  context_cfg, self.aborted, self.output_queue))
         self.process.start()