]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Port to docopt
authorZack Cerza <zack@cerza.org>
Wed, 11 Jun 2014 20:13:45 +0000 (15:13 -0500)
committerZack Cerza <zack@cerza.org>
Wed, 25 Jun 2014 18:54:22 +0000 (12:54 -0600)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
scripts/suite.py
teuthology/suite.py

index 6a7336a03bca366deb468f91a87146192f3530fc..b8a9cb501102186981c4c44c6228e6d79bc1c42a 100644 (file)
@@ -1,97 +1,51 @@
-import argparse
+import docopt
 
 import teuthology.suite
 
+doc = """
+usage: teuthology-suite [-h]
+       teuthology-suite --name <name> --collections <dir>... [options]
+       teuthology-suite -n <name> -c <dir>... [options] [<config_yaml>...]
 
-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:
+  <config_yaml>          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>      Name for this suite
+  --base <base>          Base directory for the collection(s)
+  -c <dir>, --collections <dir>
+                         The collections to run
+  --owner <owner>        Job owner
+  --email <email>        When tests finish or time out, send an email to this
+                         address.
+  --timeout <timeout>    How long, in seconds, to wait for jobs to finish
+                         before sending email. This does not kill jobs.
+                         [default: 21600]
+  -p <priority>, --priority <priority>
+                         Job priority (lower is sooner)
+                         [default: 1000]
+  -N <num>, --num <num>  Number of times to run/queue the job
+                         [default: 1]
+  -l <limit>, --limit <limit>
+                         Queue at most this many jobs
+                         [default: 0]
+  -w <worker>, --worker <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)
index 2cc12d15022b99571a2b1d6efbbeac6179931503..399f4661c6346ece4a3d35b37e70c77bcd3d33df 100644 (file)
@@ -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['<config_yaml>']
 
     if verbose:
         teuthology.log.setLevel(logging.DEBUG)