diff options
Diffstat (limited to 'automated/utils')
-rwxr-xr-x | automated/utils/test-runner.py | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/automated/utils/test-runner.py b/automated/utils/test-runner.py index b3833b9..fd4591a 100755 --- a/automated/utils/test-runner.py +++ b/automated/utils/test-runner.py @@ -10,6 +10,7 @@ import shlex import shutil import subprocess import sys +import textwrap import time from uuid import uuid4 @@ -25,6 +26,19 @@ except ImportError as e: sys.exit(1) +class StoreDictKeyPair(argparse.Action): + def __init__(self, option_strings, dest, nargs=None, **kwargs): + self._nargs = nargs + super(StoreDictKeyPair, self).__init__(option_strings, dest, nargs=nargs, **kwargs) + + def __call__(self, parser, namespace, values, option_string=None): + my_dict = {} + for kv in values: + k, v = kv.split("=") + my_dict[k] = v + setattr(namespace, self.dest, my_dict) + + # quit gracefully if the connection is closed by remote host SSH_PARAMS = "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ServerAliveInterval=5" @@ -253,6 +267,11 @@ class TestDefinition(object): ret_val.append('SKIP_INSTALL="True"\n') ret_val.append('######\n') + ret_val.append('###custom parameters from command line###\n') + if self.args.test_def_params: + for param_name, param_value in self.args.test_def_params.items(): + ret_val.append('%s=\'%s\'\n' % (param_name, param_value)) + ret_val.append('######\n') return ret_val @@ -710,37 +729,45 @@ class ResultParser(object): def get_args(): - parser = argparse.ArgumentParser() + parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('-o', '--output', default=os.getenv("HOME", "") + '/output', dest='output', - help=''' + help=textwrap.dedent('''\ specify a directory to store test and result files. Default: $HOME/output - ''') + ''')) parser.add_argument('-p', '--test_plan', default=None, dest='test_plan', - help=''' + help=textwrap.dedent('''\ specify an test plan file which has tests and related params listed in yaml format. - ''') + ''')) parser.add_argument('-d', '--test_def', default=None, dest='test_def', - help=''' + help=textwrap.dedent('''\ base on test definition repo location, specify relative path to the test definition to run. Format example: "ubuntu/smoke-tests-basic.yaml" - ''') + ''')) + parser.add_argument('-r', '--test_def_params', default={}, dest='test_def_params', + action=StoreDictKeyPair, nargs="+", metavar="KEY=VALUE", + help=textwrap.dedent('''\ + Set additional parameters when using test definition without + a test plan. The name values are set similarily to environment + variables: + --test_def_params KEY1=VALUE1 KEY2=VALUE2 ... + ''')) parser.add_argument('-k', '--kind', default="automated", dest='kind', choices=['automated', 'manual'], - help=''' + help=textwrap.dedent('''\ Selects type of tests to be executed from the test plan. Possible options: automated, manual - '''), + ''')) parser.add_argument('-t', '--timeout', type=int, default=None, dest='timeout', help='Specify test timeout') parser.add_argument('-g', '--target', default=None, - dest='target', help=''' + dest='target', help=textwrap.dedent('''\ Specify SSH target to execute tests. Format: user@host Note: ssh authentication must be paswordless - ''') + ''')) parser.add_argument('-s', '--skip_install', dest='skip_install', default=False, action='store_true', help='skip install section defined in test definition.') |