Make run_stress.py script an entry point

With change f8b816af07 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
This commit is contained in:
Matthew Treinish 2014-05-07 01:04:17 -04:00
parent dfbceca69b
commit 55e29b457c
5 changed files with 30 additions and 27 deletions

View File

@ -21,6 +21,7 @@ classifier =
console_scripts = console_scripts =
verify-tempest-config = tempest.cmd.verify_tempest_config:main verify-tempest-config = tempest.cmd.verify_tempest_config:main
javelin2 = tempest.cmd.javelin:main javelin2 = tempest.cmd.javelin:main
run-tempest-stress = tempest.cmd.run_stress:main
[build_sphinx] [build_sphinx]
all_files = 1 all_files = 1

View File

@ -70,7 +70,29 @@ def discover_stress_tests(path="./", filter_attr=None, call_inherited=False):
return tests 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 result = 0
if not ns.all: if not ns.all:
tests = json.load(open(ns.tests, 'r')) tests = json.load(open(ns.tests, 'r'))
@ -97,29 +119,9 @@ def main(ns):
return result 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__": if __name__ == "__main__":
try: try:
sys.exit(main(parser.parse_args())) sys.exit(main())
except Exception: except Exception:
LOG.exception("Failure in the stress test framework") LOG.exception("Failure in the stress test framework")
sys.exit(1) sys.exit(1)

View File

@ -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 In order to use this discovery you have to be in the tempest root directory
and execute the following: and execute the following:
tempest/stress/run_stress.py -a -d 30 run-tempest-stress -a -d 30
Running the sample test 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. This sample test tries to create a few VMs and kill a few VMs.

View File

@ -51,5 +51,5 @@ class StressFrameworkTest(tempest.test.BaseTestCase):
return proc.returncode return proc.returncode
def test_help_function(self): 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) self.assertEqual(0, result)

View File

@ -77,7 +77,7 @@ commands =
[testenv:stress] [testenv:stress]
sitepackages = True sitepackages = True
commands = commands =
python -m tempest/stress/run_stress -a -d 3600 -S run-tempest-stress -a -d 3600 -S
[testenv:venv] [testenv:venv]
commands = {posargs} commands = {posargs}