Add exit codes if run_stress.py detects an error
This is just a very basic exit code handling. Could be later enhanced by
different exit codes.
Implements: blueprint stress-tests
Change-Id: Idcf55163614f69d81fed538f7190bb63fe11dc2c
diff --git a/tempest/stress/driver.py b/tempest/stress/driver.py
index b04a93a..d170eb8 100644
--- a/tempest/stress/driver.py
+++ b/tempest/stress/driver.py
@@ -206,3 +206,7 @@
if not had_errors:
logger.info("cleaning up")
cleanup.cleanup(logger)
+ if had_errors:
+ return 1
+ else:
+ return 0
diff --git a/tempest/stress/run_stress.py b/tempest/stress/run_stress.py
index 9ec1527..106049d 100755
--- a/tempest/stress/run_stress.py
+++ b/tempest/stress/run_stress.py
@@ -18,17 +18,25 @@
import argparse
import json
+import sys
def main(ns):
#NOTE(kodererm): moved import to make "-h" possible without OpenStack
from tempest.stress import driver
+ result = 0
tests = json.load(open(ns.tests, 'r'))
if ns.serial:
for test in tests:
- driver.stress_openstack([test], ns.duration, ns.number)
+ step_result = driver.stress_openstack([test],
+ ns.duration,
+ ns.number)
+ #NOTE(kodererm): we just save the last result code
+ if (step_result != 0):
+ result = step_result
else:
driver.stress_openstack(tests, ns.duration, ns.number)
+ return result
parser = argparse.ArgumentParser(description='Run stress tests. ')
@@ -39,4 +47,6 @@
parser.add_argument('-n', '--number', type=int,
help="How often an action is executed for each process.")
parser.add_argument('tests', help="Name of the file with test description.")
-main(parser.parse_args())
+
+if __name__ == "__main__":
+ sys.exit(main(parser.parse_args()))