~andrewjbeach/juju-ci-tools/get-juju-dict

« back to all changes in this revision

Viewing changes to utility.py

  • Committer: Aaron Bentley
  • Date: 2016-09-20 18:03:54 UTC
  • mfrom: (1575.2.14 soft-timeouts-6)
  • Revision ID: aaron.bentley@canonical.com-20160920180354-7c7o5evlpoabrz9y
Add --timeout to most test scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
318
318
    return '/usr/bin/juju'
319
319
 
320
320
 
321
 
def add_basic_testing_arguments(parser, using_jes=False):
 
321
def _to_deadline(timeout):
 
322
    return datetime.utcnow() + timedelta(seconds=int(timeout))
 
323
 
 
324
 
 
325
def add_basic_testing_arguments(parser, using_jes=False, deadline=True):
322
326
    """Returns the parser loaded with basic testing arguments.
323
327
 
324
328
    The basic testing arguments, used in conjuction with boot_context ensures
339
343
 
340
344
    :param parser: an ArgumentParser.
341
345
    :param using_jes: whether args should be tailored for JES testing.
 
346
    :param deadline: If true, support the --timeout option and convert to a
 
347
        deadline.
342
348
    """
343
349
 
344
350
    # Optional postional arguments
386
392
    parser.add_argument('--keep-env', action='store_true',
387
393
                        help='Keep the Juju environment after the test'
388
394
                        ' completes.')
 
395
    if deadline:
 
396
        parser.add_argument('--timeout', dest='deadline', type=_to_deadline,
 
397
                            help="The script timeout, in seconds.")
389
398
    return parser
390
399
 
391
400