fix exit status at SLA assertion 54/754/2
authorHans Feldt <hans.feldt@ericsson.com>
Wed, 3 Jun 2015 16:04:31 +0000 (18:04 +0200)
committerHans Feldt <hans.feldt@ericsson.com>
Thu, 4 Jun 2015 14:01:17 +0000 (16:01 +0200)
tested by changing SLA action to assert and lower rtt, yardstick
command should exit non zero

Change-Id: I2dd091941fb4359add849f218cacc04f364142cd
JIRA: YARDSTICK-25
Signed-off-by: Hans Feldt <hans.feldt@ericsson.com>
samples/ping-parallel.yaml
yardstick/benchmark/runners/base.py
yardstick/main.py

index 0e632aa..1924e76 100644 (file)
@@ -17,14 +17,14 @@ scenarios:
     duration: 60
     interval: 1
   sla:
-    max_rtt: 15
-    action: monitor
+    max_rtt: 10
+    action: assert
 -
   type: Ping
   options:
     packetsize: 200
-  client: client.demo
-  server: server.demo
+  host: client.demo
+  target: server.demo
   runner:
     type: Duration
     duration: 60
@@ -39,10 +39,16 @@ context:
   flavor: m1.tiny
   user: cirros
 
+  placement_groups:
+    pgrp1:
+      policy: "availability"
+
   servers:
     client:
       floating_ip: true
+      placement: "pgrp1"
     server:
+      placement: "pgrp1"
 
   networks:
     test:
index 59ec473..38ca34f 100644 (file)
@@ -74,6 +74,15 @@ class Runner(object):
             Runner.queue.put('_TERMINATE_')
             Runner.dump_process.join()
 
+    @staticmethod
+    def terminate_all():
+        '''Terminate all runners (subprocesses)'''
+        log.debug("Terminating all runners")
+        for runner in Runner.runners:
+            runner.process.terminate()
+            runner.process.join()
+            Runner.release(runner)
+
     def __init__(self, config, queue):
         self.context = {}
         self.config = config
@@ -92,3 +101,4 @@ class Runner(object):
 
     def join(self):
         self.process.join()
+        return self.process.exitcode
index f270bf9..050a564 100755 (executable)
@@ -54,6 +54,8 @@ class TaskParser(object):
 
 def atexit_handler():
     '''handler for process termination'''
+    base_runner.Runner.terminate_all()
+
     if HeatStack.stacks_exist():
         print "Deleting all stacks"
     HeatStack.delete_all()
@@ -87,6 +89,14 @@ def run_one_scenario(scenario_cfg, context, output_file):
     return runner
 
 
+def runner_join(runner):
+    '''join (wait for) a runner, exit process at runner failure'''
+    status = runner.join()
+    base_runner.Runner.release(runner)
+    if status != 0:
+        sys.exit("Runner failed")
+
+
 def main():
     '''yardstick main'''
 
@@ -110,16 +120,14 @@ def main():
 
         # Wait for runners to finish
         for runner in runners:
-            runner.join()
+            runner_join(runner)
             print "Runner ended, output in", prog_args.output_file
-            base_runner.Runner.release(runner)
     else:
         # run serially
         for scenario in scenarios:
             runner = run_one_scenario(scenario, context, prog_args.output_file)
-            runner.join()
+            runner_join(runner)
             print "Runner ended, output in", prog_args.output_file
-            base_runner.Runner.release(runner)
 
     if prog_args.keep_deploy:
         # keep deployment, forget about stack (hide it for exit handler)