From 55e29b457c9c98b5d004f341d16a175737023385 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Wed, 7 May 2014 01:04:17 -0400 Subject: [PATCH] Make run_stress.py script an entry point With change f8b816af0751b10cc20b0ab456ca334150fcdf5f we started packaging binaries using pbr entry points. The run_stress.py script previously lived in tempest.stress, howver since it is intended to be run as a binary the proper place for it is now tempest.cmd and using an entry-point it will be easier to run it outside of the tempest tree. Change-Id: I96b2c7915875f4f9d7869b8728bf2c6f6ccbeec9 --- setup.cfg | 1 + tempest/{stress => cmd}/run_stress.py | 46 ++++++++++++++------------- tempest/stress/README.rst | 6 ++-- tempest/tests/stress/test_stress.py | 2 +- tox.ini | 2 +- 5 files changed, 30 insertions(+), 27 deletions(-) rename tempest/{stress => cmd}/run_stress.py (98%) diff --git a/setup.cfg b/setup.cfg index 339da124cd..5c62710d1e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,6 +21,7 @@ classifier = console_scripts = verify-tempest-config = tempest.cmd.verify_tempest_config:main javelin2 = tempest.cmd.javelin:main + run-tempest-stress = tempest.cmd.run_stress:main [build_sphinx] all_files = 1 diff --git a/tempest/stress/run_stress.py b/tempest/cmd/run_stress.py similarity index 98% rename from tempest/stress/run_stress.py rename to tempest/cmd/run_stress.py index c7c17c05ec..f773996246 100755 --- a/tempest/stress/run_stress.py +++ b/tempest/cmd/run_stress.py @@ -70,7 +70,29 @@ def discover_stress_tests(path="./", filter_attr=None, call_inherited=False): return tests -def main(ns): +parser = argparse.ArgumentParser(description='Run stress tests') +parser.add_argument('-d', '--duration', default=300, type=int, + help="Duration of test in secs") +parser.add_argument('-s', '--serial', action='store_true', + help="Trigger running tests serially") +parser.add_argument('-S', '--stop', action='store_true', + default=False, help="Stop on first error") +parser.add_argument('-n', '--number', type=int, + help="How often an action is executed for each process") +group = parser.add_mutually_exclusive_group(required=True) +group.add_argument('-a', '--all', action='store_true', + help="Execute all stress tests") +parser.add_argument('-T', '--type', + help="Filters tests of a certain type (e.g. gate)") +parser.add_argument('-i', '--call-inherited', action='store_true', + default=False, + help="Call also inherited function with stress attribute") +group.add_argument('-t', "--tests", nargs='?', + help="Name of the file with test description") + + +def main(): + ns = parser.parse_args() result = 0 if not ns.all: tests = json.load(open(ns.tests, 'r')) @@ -97,29 +119,9 @@ def main(ns): return result -parser = argparse.ArgumentParser(description='Run stress tests') -parser.add_argument('-d', '--duration', default=300, type=int, - help="Duration of test in secs") -parser.add_argument('-s', '--serial', action='store_true', - help="Trigger running tests serially") -parser.add_argument('-S', '--stop', action='store_true', - default=False, help="Stop on first error") -parser.add_argument('-n', '--number', type=int, - help="How often an action is executed for each process") -group = parser.add_mutually_exclusive_group(required=True) -group.add_argument('-a', '--all', action='store_true', - help="Execute all stress tests") -parser.add_argument('-T', '--type', - help="Filters tests of a certain type (e.g. gate)") -parser.add_argument('-i', '--call-inherited', action='store_true', - default=False, - help="Call also inherited function with stress attribute") -group.add_argument('-t', "--tests", nargs='?', - help="Name of the file with test description") - if __name__ == "__main__": try: - sys.exit(main(parser.parse_args())) + sys.exit(main()) except Exception: LOG.exception("Failure in the stress test framework") sys.exit(1) diff --git a/tempest/stress/README.rst b/tempest/stress/README.rst index b56f96b1af..0a636798e8 100644 --- a/tempest/stress/README.rst +++ b/tempest/stress/README.rst @@ -34,14 +34,14 @@ test suite. All test flag with the `@stresstest` decorator will be executed. In order to use this discovery you have to be in the tempest root directory and execute the following: - tempest/stress/run_stress.py -a -d 30 + run-tempest-stress -a -d 30 Running the sample test ----------------------- -To test installation, do the following (from the tempest/stress directory): +To test installation, do the following: - ./run_stress.py -t etc/server-create-destroy-test.json -d 30 + run-tempest-stress -t tempest/stress/etc/server-create-destroy-test.json -d 30 This sample test tries to create a few VMs and kill a few VMs. diff --git a/tempest/tests/stress/test_stress.py b/tempest/tests/stress/test_stress.py index c76abde389..757d484304 100644 --- a/tempest/tests/stress/test_stress.py +++ b/tempest/tests/stress/test_stress.py @@ -51,5 +51,5 @@ class StressFrameworkTest(tempest.test.BaseTestCase): return proc.returncode def test_help_function(self): - result = self._cmd("python", "-m tempest.stress.run_stress -h") + result = self._cmd("python", "-m tempest.cmd.run_stress -h") self.assertEqual(0, result) diff --git a/tox.ini b/tox.ini index 2110362343..6b4acc6f56 100644 --- a/tox.ini +++ b/tox.ini @@ -77,7 +77,7 @@ commands = [testenv:stress] sitepackages = True commands = - python -m tempest/stress/run_stress -a -d 3600 -S + run-tempest-stress -a -d 3600 -S [testenv:venv] commands = {posargs}