From f5af797ce3530f7650bba94e20b0ce2a0b8c2ad9 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Wed, 11 Jun 2014 15:13:45 -0500 Subject: [PATCH] Port to docopt Signed-off-by: Zack Cerza --- scripts/suite.py | 134 +++++++++++++++----------------------------- teuthology/suite.py | 26 ++++----- 2 files changed, 57 insertions(+), 103 deletions(-) diff --git a/scripts/suite.py b/scripts/suite.py index 6a7336a03bca3..b8a9cb5011021 100644 --- a/scripts/suite.py +++ b/scripts/suite.py @@ -1,97 +1,51 @@ -import argparse +import docopt import teuthology.suite +doc = """ +usage: teuthology-suite [-h] + teuthology-suite --name --collections ... [options] + teuthology-suite -n -c ... [options] [...] -def main(): - teuthology.suite.main(parse_args()) - - -def parse_args(): - parser = argparse.ArgumentParser(description=""" -Run a suite of ceph integration tests. - -A suite is a set of collections. - -A collection is a directory containing facets. - -A facet is a directory containing config snippets. +Run a suite of ceph integration tests. A suite is a set of collections. A +collection is a directory containing facets. A facet is a directory containing +config snippets. Running a collection means running teuthology for every +configuration combination generated by taking one config snippet from each +facet. Any config files passed on the command line will be used for every +combination, and will override anything in the suite. -Running a collection means running teuthology for every configuration -combination generated by taking one config snippet from each facet. +positional arguments: + Optional extra job yaml to include + +optional arguments: + -h, --help Show this help message and exit + -v, --verbose Be more verbose + --dry-run Do a dry run; do not schedule anything + -n, --name Name for this suite + --base Base directory for the collection(s) + -c , --collections + The collections to run + --owner Job owner + --email When tests finish or time out, send an email to this + address. + --timeout How long, in seconds, to wait for jobs to finish + before sending email. This does not kill jobs. + [default: 21600] + -p , --priority + Job priority (lower is sooner) + [default: 1000] + -N , --num Number of times to run/queue the job + [default: 1] + -l , --limit + Queue at most this many jobs + [default: 0] + -w , --worker + Which worker to use (type of machine) + [default: plana] + +""" -Any config files passed on the command line will be used for every -combination, and will override anything in the suite. -""") - parser.add_argument( - '-v', '--verbose', - action='store_true', default=None, - help='be more verbose', - ) - parser.add_argument( - '--dry-run', - action='store_true', default=None, - help='do a dry run; do not schedule anything', - ) - parser.add_argument( - '--name', - help='name for this suite', - required=True, - ) - parser.add_argument( - '--base', - default=None, - help='base directory for the collection(s)' - ) - parser.add_argument( - '--collections', - metavar='DIR', - nargs='+', - required=True, - help='the collections to run', - ) - parser.add_argument( - '--owner', - help='job owner', - ) - parser.add_argument( - '--email', - help='address to email test failures to', - ) - parser.add_argument( - '--timeout', - help='how many seconds to wait for jobs to finish before emailing ' + - 'results', - ) - parser.add_argument( - '-n', '--num', - default=1, - type=int, - help='number of times to run/queue each job' - ) - parser.add_argument( - '-p', '--priority', - default=1000, - type=int, - help='queue priority (lower value is higher priority)' - ) - parser.add_argument( - '-l', '--limit', - default=0, - type=int, - help='limit number of jobs in loop to N' - ) - parser.add_argument( - '-w', '--worker', - default='plana', - help='which worker to use (type of machine)', - ) - parser.add_argument( - 'config', - metavar='CONFFILE', - nargs='*', - default=[], - help='config file to read', - ) - return parser.parse_args() +def main(): + args = docopt.docopt(doc) + teuthology.suite.main(args) diff --git a/teuthology/suite.py b/teuthology/suite.py index 2cc12d15022b9..399f4661c6346 100644 --- a/teuthology/suite.py +++ b/teuthology/suite.py @@ -17,19 +17,19 @@ log = logging.getLogger(__name__) def main(args): - verbose = args.verbose - limit = args.limit - dry_run = args.dry_run - name = args.name - priority = args.priority - num = args.num - worker = args.worker - owner = args.owner - base = args.base - collections = args.collections - email = args.email - timeout = args.timeout - base_yaml_paths = args.config + verbose = args['--verbose'] + limit = int(args['--limit']) + dry_run = args['--dry-run'] + name = args['--name'] + priority = int(args['--priority']) + num = int(args['--num']) + worker = args['--worker'] + owner = args['--owner'] + base = args['--base'] + collections = args['--collections'] + email = args['--email'] + timeout = args['--timeout'] + base_yaml_paths = args[''] if verbose: teuthology.log.setLevel(logging.DEBUG) -- 2.39.5