Add run_stress to cliff-based cli framework
Also disable ability to run script in stand-alone mode. So users need to use 'tempest run-stress' instead. Change-Id: I3effd1b71b2375f75a11f5924205741be0903361 Implements: blueprint tempest-cli-improvements
This commit is contained in:
parent
c90fa78906
commit
e5c7028236
@ -35,6 +35,7 @@ console_scripts =
|
||||
tempest.cm =
|
||||
init = tempest.cmd.init:TempestInit
|
||||
cleanup = tempest.cmd.cleanup:TempestCleanup
|
||||
run-stress = tempest.cmd.run_stress:TempestRunStress
|
||||
oslo.config.opts =
|
||||
tempest.config = tempest.config:list_opts
|
||||
|
||||
|
65
tempest/cmd/run_stress.py
Executable file → Normal file
65
tempest/cmd/run_stress.py
Executable file → Normal file
@ -23,6 +23,7 @@ except ImportError:
|
||||
# unittest in python 2.6 does not contain loader, so uses unittest2
|
||||
from unittest2 import loader
|
||||
|
||||
from cliff import command
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils as json
|
||||
from testtools import testsuite
|
||||
@ -70,29 +71,42 @@ def discover_stress_tests(path="./", filter_attr=None, call_inherited=False):
|
||||
return tests
|
||||
|
||||
|
||||
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")
|
||||
class TempestRunStress(command.Command):
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
pa = super(TempestRunStress, self).get_parser(prog_name)
|
||||
pa = add_arguments(pa)
|
||||
return pa
|
||||
|
||||
def take_action(self, pa):
|
||||
return action(pa)
|
||||
|
||||
|
||||
def main():
|
||||
ns = parser.parse_args()
|
||||
def add_arguments(parser):
|
||||
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")
|
||||
return parser
|
||||
|
||||
|
||||
def action(ns):
|
||||
result = 0
|
||||
if not ns.all:
|
||||
tests = json.load(open(ns.tests, 'r'))
|
||||
@ -121,6 +135,15 @@ def main():
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
LOG.warning("Deprecated: Use 'tempest run-stress' instead. "
|
||||
"The old entrypoint will be removed in a future release.")
|
||||
parser = argparse.ArgumentParser(description='Run stress tests')
|
||||
pa = add_arguments(parser)
|
||||
ns = pa.parse_args()
|
||||
return action(ns)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.exit(main())
|
||||
|
@ -33,17 +33,17 @@ Running default stress test set
|
||||
|
||||
The stress test framework can automatically discover test inside the tempest
|
||||
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:
|
||||
In order to use this discovery you have to install tempest CLI, be in the
|
||||
tempest root directory and execute the following:
|
||||
|
||||
run-tempest-stress -a -d 30
|
||||
tempest run-stress -a -d 30
|
||||
|
||||
Running the sample test
|
||||
-----------------------
|
||||
|
||||
To test installation, do the following:
|
||||
|
||||
run-tempest-stress -t tempest/stress/etc/server-create-destroy-test.json -d 30
|
||||
tempest run-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.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user