Fix a bug for algorithm of arithmetic runner.
[yardstick.git] / yardstick / benchmark / runners / arithmetic.py
old mode 100644 (file)
new mode 100755 (executable)
index bac7efb..f73d1cd
@@ -26,9 +26,6 @@ def _worker_process(queue, cls, method_name, context, scenario_args):
 
     sequence = 1
 
-    benchmark = cls(context)
-    method = getattr(benchmark, method_name)
-
     interval = context.get("interval", 1)
     arg_name = context.get('name')
     stop = context.get('stop')
@@ -41,14 +38,19 @@ def _worker_process(queue, cls, method_name, context, scenario_args):
     LOG.info("worker START, step(%s, %d, %d, %d), class %s",
              arg_name, start, stop, step, cls)
 
+    benchmark = cls(context)
+    benchmark.setup()
+    method = getattr(benchmark, method_name)
+
     record_context = {"runner": context["runner"],
                       "host": context["host"]}
 
     sla_action = None
     if "sla" in scenario_args:
         sla_action = scenario_args["sla"].get("action", "assert")
+    margin = 1 if step > 0 else -1
 
-    for value in range(start, stop, step):
+    for value in range(start, stop+margin, step):
 
         options[arg_name] = value
 
@@ -91,10 +93,35 @@ def _worker_process(queue, cls, method_name, context, scenario_args):
         if errors:
             break
 
+    benchmark.teardown()
     LOG.info("worker END")
 
 
 class ArithmeticRunner(base.Runner):
+    '''Run a scenario arithmetically stepping an input value
+
+  Parameters
+    interval - time to wait between each scenario invocation
+        type:    int
+        unit:    seconds
+        default: 1 sec
+    name - name of scenario option that will be increased for each invocation
+        type:    string
+        unit:    na
+        default: none
+    start - value to use in first invocation of scenario
+        type:    int
+        unit:    na
+        default: none
+    step - value added to start value in next invocation of scenario
+        type:    int
+        unit:    na
+        default: none
+    stop - value indicating end of invocation
+        type:    int
+        unit:    na
+        default: none
+    '''
 
     __execution_type__ = 'Arithmetic'