def configure(self, parser): run_subcommand_parser = parser.subcommands.choices.get('run', None) if run_subcommand_parser is None: return help_msg = ('Enable JSON result format and write it to FILE. ' 'Use "-" to redirect to the standard output.') settings.register_option(section='run.json', key='output', default=None, action=FileOrStdoutAction, help_msg=help_msg, metavar='FILE', parser=run_subcommand_parser, long_arg='--json') help_msg = ('Enables default JSON result in the job results ' 'directory. File will be named "results.json".') settings.register_option(section='run.json', key='job_result', default='on', choices=('on', 'off'), help_msg=help_msg, parser=run_subcommand_parser, long_arg='--json-job-result')
def configure(self, parser): run_subcommand_parser = parser.subcommands.choices.get('run', None) if run_subcommand_parser is None: return msg = 'result-upload options' parser = run_subcommand_parser.add_argument_group(msg) help_msg = 'Specify the result upload url' settings.register_option(section='plugins.result_upload', key='url', default=None, help_msg=help_msg, parser=parser, long_arg='--result-upload-url') try: rsync_bin = utils_path.find_command('rsync') def_ssh = ('ssh -oLogLevel=error -o stricthostkeychecking=no' ' -o userknownhostsfile=/dev/null' ' -o batchmode=yes -o passwordauthentication=no') def_upload_cmd = '%s -arz -e \'%s \'' % (rsync_bin, def_ssh) except utils_path.CmdNotFoundError: def_upload_cmd = None help_msg = 'Specify the command to upload results' settings.register_option(section='plugins.result_upload', key='command', help_msg=help_msg, default=def_upload_cmd, parser=parser, long_arg='--result-upload-cmd')
def configure(self, parser): subparser = parser.subcommands.choices.get('run', None) if subparser is None: return mux_options = subparser.add_argument_group( "yaml to mux testsuite options") help_msg = "Filter only part of the YAML suite file" settings.register_option(section='run', key='mux_suite_only', nargs='+', help_msg=help_msg, parser=mux_options, long_arg='--mux-suite-only', key_type=list, default=[]) help_msg = "Filter out part of the YAML suite file" settings.register_option(section='run', key='mux_suite_out', nargs='+', help_msg=help_msg, parser=mux_options, long_arg='--mux-suite-out', key_type=list, default=[])
def configure(self, parser): """ Add the subparser for the assets action. :param parser: The Avocado command line application parser :type parser: :class:`avocado.core.parser.ArgumentParser` """ parser = super(Assets, self).configure(parser) subcommands = parser.add_subparsers(dest='assets_subcommand') subcommands.required = True fetch_subcommand_parser = subcommands.add_parser( 'fetch', help='Fetch assets from test source or config file if it\'s not' ' already in the cache') help_msg = "Path to avocado instrumented test" settings.register_option(section='assets.fetch', key='references', help_msg=help_msg, default=[], metavar='AVOCADO_INSTRUMENTED', key_type=list, nargs='+', parser=fetch_subcommand_parser, positional_arg=True) help_msg = "always return success for the fetch command." settings.register_option(section='assets.fetch', key='ignore_errors', help_msg=help_msg, default=False, key_type=bool, parser=fetch_subcommand_parser, long_arg='--ignore-errors')
def test_update_argparse(self): future_settings.register_option(section='bar', key='foo', default=1, help_msg='bar foo') parser = argparse.ArgumentParser(description='Basic parser.') future_settings.add_argparser_to_option('bar.foo', parser, '--bar-foo') stored_parser = future_settings._namespaces.get('bar.foo').parser self.assertIsInstance(stored_parser, argparse.ArgumentParser)
def test_register_value(self): future_settings.register_option(section='foo', key='bar', default=1, key_type=int, help_msg='foo bar') result = future_settings.as_dict() self.assertEqual(result['foo.bar'], 1) self.assertIsInstance(result['foo.bar'], int)
def test_registered_already(self): with self.assertRaises(DuplicatedNamespace): future_settings.register_option(section='foo', key='bar', default=1, help_msg='foo bar') future_settings.register_option(section='foo', key='bar', default=1, help_msg='foo bar')
def configure(self, parser): parser = super(NRun, self).configure(parser) help_msg = 'List of test references (aliases or paths)' settings.register_option(section='nrun', key='references', default=[], key_type=list, help_msg=help_msg, nargs='*', parser=parser, metavar="TEST_REFERENCE", positional_arg=True) help_msg = 'Disable task shuffle' settings.register_option(section='nrun', key='disable_task_randomization', default=False, help_msg=help_msg, key_type=bool, parser=parser, long_arg='--disable-task-randomization') help_msg = ('Number of parallel tasks to run the tests. You can ' 'disable parallel execution by passing 1.') settings.register_option(section='nrun', key='parallel_tasks', default=2 * multiprocessing.cpu_count() - 1, key_type=int, help_msg=help_msg, parser=parser, long_arg='--parallel-tasks') help_msg = 'Host and port for the status server' settings.register_option(section='nrun.status_server', key='listen', default='127.0.0.1:8888', metavar="HOST:PORT", help_msg=help_msg, parser=parser, long_arg='--status-server') help_msg = ("Spawn tests in a specific spawner. Available spawners: " "'process' and 'podman'") settings.register_option(section="nrun", key="spawner", default='process', help_msg=help_msg, parser=parser, long_arg="--spawner") parser_common_args.add_tag_filter_args(parser)
def initialize(self): section = 'job.run.result.xunit' help_msg = ('Enable xUnit result format and write it to FILE. ' 'Use "-" to redirect to the standard output.') settings.register_option(section=section, key='output', help_msg=help_msg, default=None) help_msg = ('Enables default xUnit result in the job results ' 'directory. File will be named "results.xml".') settings.register_option(section=section, key='enabled', help_msg=help_msg, default='on') help_msg = ('Override the reported job name. By default uses the ' 'Avocado job name which is always unique. This is useful ' 'for reporting in Jenkins as it only evaluates ' 'first-failure from jobs of the same name.') settings.register_option(section='job.run.result.xunit', key='job_name', default=None, help_msg=help_msg) help_msg = ('Limit the attached job log to given number of characters ' '(k/m/g suffix allowed)') settings.register_option(section='job.run.result.xunit', key='max_test_log_chars', help_msg=help_msg, key_type=lambda x: DataSize(x).b, default='100000')
def configure(self, parser): run_subcommand_parser = parser.subcommands.choices.get('run', None) if run_subcommand_parser is None: return help_msg = 'Archive (ZIP) files generated by tests' settings.register_option(section='run.results', key='archive', default=False, help_msg=help_msg, key_type=bool, parser=run_subcommand_parser, short_arg='-z', long_arg='--archive')
def initialize(self): help_msg = 'Mail recipient.' future_settings.register_option(section='plugins.job.mail', key='recipient', default='*****@*****.**', help_msg=help_msg) help_msg = 'Mail header.' future_settings.register_option(section='plugins.job.mail', key='header', default='[AVOCADO JOB NOTIFICATION]', help_msg=help_msg) help_msg = 'Mail sender.' future_settings.register_option( section='plugins.job.mail', key='sender', default='*****@*****.**', help_msg=help_msg) help_msg = 'Mail server.' future_settings.register_option(section='plugins.job.mail', key='server', default='localhost', help_msg=help_msg)
def initialize(self): help_msg = ('Enable JSON result format and write it to FILE. ' 'Use "-" to redirect to the standard output.') settings.register_option(section='job.run.result.json', key='output', default=None, help_msg=help_msg) help_msg = ('Enables default JSON result in the job results ' 'directory. File will be named "results.json".') settings.register_option(section='job.run.result.json', key='enabled', default='on', help_msg=help_msg)
def initialize(self): help_msg = 'Warn if configured (or default) directory does not exist' future_settings.register_option(section='plugins.jobscripts', key='warn_non_existing_dir', key_type=bool, default=False, help_msg=help_msg) help_msg = 'Warn if any script run return non-zero status' future_settings.register_option(section='plugins.jobscripts', key='warn_non_zero_status', key_type=bool, default=True, help_msg=help_msg) help_msg = 'Directory with scripts to be executed before a job is run' default = '/etc/avocado/scripts/job/pre.d/' future_settings.register_option(section='plugins.jobscripts', key='pre', key_type=prepend_base_path, help_msg=help_msg, default=default) help_msg = 'Directory with scripts to be executed after a job is run' default = '/etc/avocado/scripts/job/post.d/' future_settings.register_option(section='plugins.jobscripts', key='post', key_type=prepend_base_path, help_msg=help_msg, default=default)
def configure(self, parser): run_subcommand_parser = parser.subcommands.choices.get('run', None) if run_subcommand_parser is None: return help_msg = ('Records test status changes (for use with ' 'avocado-journal-replay and avocado-server)') settings.register_option(section='run.journal', key='enabled', default=False, key_type=bool, help_msg=help_msg, parser=run_subcommand_parser, long_arg='--journal')
def configure(self, parser): help_msg = 'Load the Variants from a JSON serialized file' for name in ("run", "variants"): # intentionally omitting "multiplex" subparser = parser.subcommands.choices.get(name, None) if subparser is None: continue sparser = subparser.add_argument_group('JSON serialized based ' 'varianter options') settings.register_option(section=name, key='json_variants_load', default=None, help_msg=help_msg, parser=sparser, long_arg='--json-variants-load')
def configure(self, parser): """ Add the subparser for the run action. :param parser: The Avocado command line application parser :type parser: :class:`avocado.core.parser.ArgumentParser` """ parser = super(SysInfo, self).configure(parser) help_msg = 'Directory where Avocado will dump sysinfo data.' settings.register_option(section='sysinfo.collect', key='sysinfodir', default='./', help_msg=help_msg, parser=parser, positional_arg=True, nargs='?')
def configure(self, parser): parser = super(Config, self).configure(parser) help_msg = ('Shows the data directories currently being used by ' 'Avocado') future_settings.register_option(section='config', key='datadir', key_type=bool, default=False, help_msg=help_msg, parser=parser, long_arg='--datadir') subcommands = parser.add_subparsers(dest='config_subcommand', metavar='sub-command') help_msg = 'Show a configuration reference with all registered options' subcommands.add_parser('reference', help=help_msg)
def configure(self, parser): try: pict_binary = utils_path.find_command('pict') except utils_path.CmdNotFoundError: pict_binary = None for name in ("run", "variants"): # intentionally omitting "multiplex" subparser = parser.subcommands.choices.get(name, None) if subparser is None: continue pict = subparser.add_argument_group('pict based varianter options') help_msg = ('Where to find the binary version of the pict tool. ' 'Tip: download it from ' '"https://github.com/Microsoft/pict" and run `make` ' 'to build it') settings.register_option(section=name, key='pict_binary', help_msg=help_msg, default=pict_binary, metavar='PATH', parser=pict, long_arg='--pict-binary') help_msg = "Paths to a pict parameter file" settings.register_option(section=name, key='pict_parameter_file', metavar='PATH', help_msg=help_msg, default=None, parser=pict, long_arg='--pict-parameter-file') help_msg = ('Default path for parameters generated on the ' 'Pict based variants') settings.register_option(section=name, key='pict_parameter_path', metavar='PATH', help_msg=help_msg, default='/run', parser=pict, long_arg='--pict-parameter-path') help_msg = ("Order of combinations. Maximum number is specific to " "parameter file content") settings.register_option(section=name, key='pict_combinations_order', metavar='ORDER', key_type=int, help_msg=help_msg, default=2, parser=pict, long_arg='--pict-order-of-combinations')
def configure(self, parser): """ Add the subparser for the run action. :param parser: The Avocado command line application parser :type parser: :class:`avocado.core.parser.ArgumentParser` """ parser = super(SysInfo, self).configure(parser) help_msg = ('Directory where Avocado will dump sysinfo data. If one ' 'is not given explicitly, it will default to a directory ' 'named "sysinfo-" followed by a timestamp in the current ' 'working directory.') settings.register_option(section='sysinfo.collect', key='sysinfodir', default=None, help_msg=help_msg, parser=parser, positional_arg=True, nargs='?')
def configure(self, parser): run_subcommand_parser = parser.subcommands.choices.get('run', None) if run_subcommand_parser is None: return msg = 'resultsdb options' parser = run_subcommand_parser.add_argument_group(msg) help_msg = 'Specify the resultsdb API url' settings.register_option(section='plugins.resultsdb', key='api_url', default=None, help_msg=help_msg, parser=parser, long_arg='--resultsdb-api') help_msg = 'Specify the URL where the logs are published' settings.register_option(section='plugins.resultsdb', key='logs_url', default=None, help_msg=help_msg, parser=parser, long_arg='--resultsdb-logs') help_msg = 'Maximum note size limit' settings.register_option(section='plugins.resultsdb', key='note_size_limit', default=0, key_type=int, help_msg=help_msg, parser=parser, long_arg='--resultsdb-note-limit')
def initialize(self): section = 'job.run.result.tap' help_msg = ('Enable TAP result output and write it to FILE. Use ' '"-" to redirect to standard output.') settings.register_option( section=section, key='output', help_msg=help_msg, default=None) help_msg = ('Enables default TAP result in the job results directory. ' 'File will be named "results.tap"') settings.register_option( section=section, key='enabled', help_msg=help_msg, default='on') help_msg = 'Include test logs as comments in TAP output.' settings.register_option( section=section, key='include_logs', default=False, key_type=bool, help_msg=help_msg)
def configure(self, parser): cmd_parser = parser.subcommands.choices.get('run', None) if cmd_parser is None: return help_msg = ('Enable TAP result output and write it to FILE. Use ' '"-" to redirect to standard output.') settings.register_option(section='run.tap', key='output', metavar='FILE', action=FileOrStdoutAction, help_msg=help_msg, default=None, parser=cmd_parser, long_arg='--tap') help_msg = ('Enables default TAP result in the job results directory. ' 'File will be named "results.tap"') settings.register_option(section='run.tap', key='job_result', help_msg=help_msg, default='on', choices=('on', 'off'), parser=cmd_parser, long_arg='--tap-job-result') help_msg = 'Include test logs as comments in TAP output.' settings.register_option(section='run.tap', key='include_logs', default=False, key_type=bool, help_msg=help_msg, parser=cmd_parser, long_arg='--tap-include-logs')
def configure(self, parser): parser = super(List, self).configure(parser) settings.register_option(section='nlist', key='references', default=[], nargs='*', key_type=list, help_msg='Test references', parser=parser, positional_arg=True) help_msg = ('Show extra information on resolution, besides ' 'sucessful resolutions') settings.register_option(section='nlist', key='verbose', default=False, key_type=bool, help_msg=help_msg, parser=parser, long_arg='--verbose', short_arg='-V') help_msg = 'Writes runnable recipe files to a directory' settings.register_option(section='nlist.recipes', key='write_to_directory', default=None, metavar='DIRECTORY', help_msg=help_msg, parser=parser, long_arg='--write-recipes-to-directory') parser_common_args.add_tag_filter_args(parser)
def configure(self, parser): run_subcommand_parser = parser.subcommands.choices.get('run', None) if run_subcommand_parser is None: return wrap_group = run_subcommand_parser.add_argument_group( 'wrapper support') help_msg = ('Use a script to wrap executables run by a test. The ' 'wrapper is either a path to a script (AKA a global ' 'wrapper) or a path to a script followed by colon symbol ' '(:), plus a shell like glob to the target EXECUTABLE. ' 'Multiple wrapper options are allowed, but only one ' 'global wrapper can be defined.') settings.register_option(section='run.wrapper', key='wrappers', default=[], key_type=list, help_msg=help_msg, action='append', metavar='SCRIPT[:EXECUTABLE]', parser=wrap_group, long_arg='--wrapper')
def initialize(self): help_msg = ("Location of one or more Avocado multiplex (.yaml) " "FILE(s) (order dependent)") settings.register_option(section=self.name, key='files', default=[], key_type=list, help_msg=help_msg) help_msg = 'Filter only path(s) from multiplexing' settings.register_option(section=self.name, key='filter_only', default=[], key_type=list, help_msg=help_msg) help_msg = 'Filter out path(s) from multiplexing' settings.register_option(section=self.name, key='filter_out', default=[], help_msg=help_msg) help_msg = ("List of default paths used to determine path priority " "when querying for parameters") settings.register_option(section=self.name, key='parameter_paths', default=['/run/*'], key_type=list, help_msg=help_msg) help_msg = ("Inject [path:]key:node values into the final " "multiplex tree.") settings.register_option(section=self.name, key='inject', default=[], help_msg=help_msg, key_type=list)
def configure(self, parser): run_subcommand_parser = parser.subcommands.choices.get('run', None) if run_subcommand_parser is None: return help_msg = ('Enable xUnit result format and write it to FILE. ' 'Use "-" to redirect to the standard output.') settings.register_option(section='run.xunit', key='output', metavar='FILE', action=FileOrStdoutAction, help_msg=help_msg, default=None, parser=run_subcommand_parser.output, long_arg='--xunit') help_msg = ('Enables default xUnit result in the job results ' 'directory. File will be named "results.xml".') settings.register_option(section='run.xunit', key='job_result', help_msg=help_msg, choices=('on', 'off'), default='on', parser=run_subcommand_parser.output, long_arg='--xunit-job-result') help_msg = ('Override the reported job name. By default uses the ' 'Avocado job name which is always unique. This is useful ' 'for reporting in Jenkins as it only evaluates ' 'first-failure from jobs of the same name.') settings.register_option(section='run.xunit', key='job_name', default=None, help_msg=help_msg, parser=run_subcommand_parser.output, long_arg='--xunit-job-name') help_msg = ('Limit the attached job log to given number of characters ' '(k/m/g suffix allowed)') settings.register_option(section='run.xunit', key='max_test_log_chars', metavar='SIZE', help_msg=help_msg, default='100000', key_type=lambda x: DataSize(x).b, parser=run_subcommand_parser.output, long_arg='--xunit-max-test-log-chars')
def configure(self, parser): """ Add the subparser for the list action. :param parser: The Avocado command line application parser :type parser: :class:`avocado.core.parser.ArgumentParser` """ parser = super(List, self).configure(parser) help_msg = ('List of test references (aliases or paths). If empty, ' 'Avocado will list tests on the configured test source, ' '(see "avocado config --datadir") Also, if there are ' 'other test loader plugins active, tests from those ' 'plugins might also show up (behavior may vary among ' 'plugins)') settings.register_option(section='list', key='references', default=[], nargs='*', key_type=list, help_msg=help_msg, parser=parser, positional_arg=True) loader.add_loader_options(parser, 'list') parser_common_args.add_tag_filter_args(parser)
def configure(self, parser): for name in ("run", "variants"): subparser = parser.subcommands.choices.get(name, None) if subparser is None: continue subparser.add_argument_group('CIT varianter options') settings.register_option(section="{}.cit".format(name), key='parameter_file', metavar='PATH', help_msg='Paths to a parameter file', parser=subparser, default=None, long_arg='--cit-parameter-file') help_msg = "Order of combinations. Maximum number is 6" settings.register_option(section="{}.cit".format(name), key='combination_order', key_type=int, parser=subparser, help_msg=help_msg, metavar='ORDER', default=DEFAULT_ORDER_OF_COMBINATIONS, long_arg='--cit-order-of-combinations')
def configure(self, parser): run_subcommand_parser = parser.subcommands.choices.get('run', None) if run_subcommand_parser is None: return msg = 'job replay' replay_parser = run_subcommand_parser.add_argument_group(msg) help_msg = ('Replay a job identified by its (partial) hash id. ' 'Use "--replay" latest to replay the latest job.') future_settings.register_option(section='run.replay', key='job_id', default=None, help_msg=help_msg, parser=replay_parser, long_arg='--replay') help_msg = 'Filter tests to replay by test status.' future_settings.register_option(section='run.replay', key='test_status', default=[], help_msg=help_msg, key_type=self._valid_status, parser=replay_parser, long_arg='--replay-test-status') help_msg = 'Ignore variants and/or configuration from the source job.' future_settings.register_option(section='run.replay', key='ignore', default=[], help_msg=help_msg, key_type=self._valid_ignore, parser=replay_parser, long_arg='--replay-ignore') help_msg = 'Resume an interrupted job' future_settings.register_option(section='run.replay', key='resume', default=False, help_msg=help_msg, key_type=bool, parser=replay_parser, long_arg='--replay-resume')
def configure(self, parser): """ Add the subparser for the assets action. :param parser: The Avocado command line application parser :type parser: :class:`avocado.core.parser.ArgumentParser` """ parser = super(Jobs, self).configure(parser) subcommands = parser.add_subparsers(dest='jobs_subcommand', metavar='sub-command') subcommands.required = True help_msg = 'List all known jobs by Avocado' subcommands.add_parser('list', help=help_msg) help_msg = ('Show details about a specific job. When passing a Job ' 'ID, you can use any Job Reference (job_id, "latest", ' 'or job results path).') show_parser = subcommands.add_parser('show', help=help_msg) settings.register_option(section='jobs.show', key='job_id', help_msg='JOB id', metavar='JOBID', default='latest', nargs='?', positional_arg=True, parser=show_parser) help_msg = ('Download output files generated by tests on ' 'AVOCADO_TEST_OUTPUT_DIR') output_files_parser = subcommands.add_parser('get-output-files', help=help_msg) settings.register_option(section='jobs.get.output_files', key='job_id', help_msg='JOB id', metavar='JOBID', default=None, positional_arg=True, parser=output_files_parser) settings.register_option(section='jobs.get.output_files', key='destination', help_msg='Destination path', metavar='DESTINATION', default=None, positional_arg=True, parser=output_files_parser)