Pass parameters between scenarios
[yardstick.git] / yardstick / benchmark / runners / sequence.py
index 3b06e2a..74ff822 100644 (file)
 # yardstick comment: this is a modified copy of
 # rally/rally/benchmark/runners/constant.py
 
-'''A runner that every run changes a specified input value to the scenario.
+"""A runner that every run changes a specified input value to the scenario.
 The input value in the sequence is specified in a list in the input file.
-'''
+"""
 
+from __future__ import absolute_import
 import os
 import multiprocessing
 import logging
@@ -32,7 +33,7 @@ LOG = logging.getLogger(__name__)
 
 
 def _worker_process(queue, cls, method_name, scenario_cfg,
-                    context_cfg, aborted):
+                    context_cfg, aborted, output_queue):
 
     sequence = 1
 
@@ -74,7 +75,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":
@@ -85,6 +86,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)
 
@@ -113,7 +117,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg,
 
 
 class SequenceRunner(base.Runner):
-    '''Run a scenario by changing an input value defined in a list
+    """Run a scenario by changing an input value defined in a list
 
   Parameters
     interval - time to wait between each scenario invocation
@@ -128,7 +132,7 @@ class SequenceRunner(base.Runner):
         type:    [int]
         unit:    na
         default: none
-    '''
+    """
 
     __execution_type__ = 'Sequence'
 
@@ -136,5 +140,5 @@ class SequenceRunner(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()