Skip to content

Commit

Permalink
Merge remote-tracking branch 'clebergnu/vt_save_config'
Browse files Browse the repository at this point in the history
Signed-off-by: Cleber Rosa <[email protected]>
  • Loading branch information
clebergnu committed Nov 13, 2020
2 parents 71970d9 + 885a6f6 commit 6d5077b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 18 deletions.
6 changes: 5 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ fedora_33_task:
bootstrap_script: &bootstrap_scr
- $PYTHON -m avocado vt-bootstrap --vt-type=$VT_TYPE --vt-skip-verify-download-assets --yes-to-all
list_script: &list_scr
- $PYTHON -m avocado list --vt-type=$VT_TYPE
- $PYTHON -m avocado list --vt-save-config=/tmp/config --vt-type=$VT_TYPE -- boot | tee /tmp/list
- test $VT_TYPE == "qemu" || test $(wc -l < /tmp/list) -gt 50
- test $VT_TYPE == "libvirt" || test $(wc -l < /tmp/list) -eq 1
- $PYTHON -m avocado list --vt-config=/tmp/config --vt-type=$VT_TYPE -- boot | tee /tmp/list_from_config
- diff /tmp/list /tmp/list_from_config
dry_run_script: &dry_run_scr
- $PYTHON -m avocado --show all run --vt-type=$VT_TYPE --dry-run -- io-github-autotest-qemu.boot

Expand Down
15 changes: 12 additions & 3 deletions avocado_vt/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ def _get_parser(self):
options_processor = VirtTestOptionsProcess(self.config)
return options_processor.get_parser()

def _save_parser_cartesian_config(self, parser):
path = get_opt(self.config, 'vt.save_config')
if path is None:
return
with open(path, 'w') as cartesian_config:
cartesian_config.write("include %s\n" % parser.filename)
for statement in (parser.only_filters + parser.no_filters +
parser.assignments):
cartesian_config.write("%s\n" % statement)

def get_extra_listing(self):
if get_opt(self.config, 'vt_list_guests'):
config = copy.copy(self.config)
Expand Down Expand Up @@ -167,6 +177,7 @@ def _report_bad_discovery(name, reason, which_tests):
def discover(self, url, which_tests=loader.DiscoverMode.DEFAULT):
try:
cartesian_parser = self._get_parser()
self._save_parser_cartesian_config(cartesian_parser)
except Exception as details:
return self._report_bad_discovery(url, details, which_tests)
if url is not None:
Expand All @@ -188,9 +199,7 @@ def discover(self, url, which_tests=loader.DiscoverMode.DEFAULT):
for params in (_ for _ in cartesian_parser.get_dicts()):
# Evaluate the proper avocado-vt test name
test_name = None
if get_opt(self.config, 'vt.config'):
test_name = params.get("shortname")
elif get_opt(self.config, 'vt.type') == "spice":
if get_opt(self.config, 'vt.type') == "spice":
short_name_map_file = params.get("_short_name_map_file")
if "tests-variants.cfg" in short_name_map_file:
test_name = short_name_map_file["tests-variants.cfg"]
Expand Down
27 changes: 16 additions & 11 deletions avocado_vt/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,21 @@ def _process_general_options(self):
self._process_bridge_mode()
self._process_only_type_specific()

def _process_backend_specific_options(self, vt_type):
"""
Calls for processing of backend specific options
"""
backend_specific_options = {
'qemu': self._process_qemu_specific_options,
'lvsb': self._process_lvsb_specific_options,
'openvswitch': self._process_qemu_specific_options,
'libvirt': self._process_libvirt_specific_options,
'spice': self._process_spice_specific_options,
}
specific_opts = backend_specific_options.get(vt_type, None)
if specific_opts is not None:
specific_opts()

def _process_spice_specific_options(self):
"""
Calls for processing all options specific to spice test
Expand Down Expand Up @@ -521,17 +536,7 @@ def _process_options(self):
if vt_type != 'lvsb':
self._process_general_options()

if vt_type == 'qemu':
self._process_qemu_specific_options()
elif vt_type == 'lvsb':
self._process_lvsb_specific_options()
elif vt_type == 'openvswitch':
self._process_qemu_specific_options()
elif vt_type == 'libvirt':
self._process_libvirt_specific_options()
elif vt_type == 'spice':
self._process_spice_specific_options()

self._process_backend_specific_options(vt_type)
self._process_extra_params()

def get_parser(self):
Expand Down
3 changes: 3 additions & 0 deletions avocado_vt/plugins/vt.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def add_basic_vt_options(parser):
help="Explicitly choose a cartesian config. When "
"choosing this, some options will be ignored (see "
"options below)")
parser.add_argument("--vt-save-config", action="store",
dest="vt.save_config",
help="Save the resulting cartesian config to a file")
msg = ("Choose test type (%s). Default: %%(default)s" %
", ".join(SUPPORTED_TEST_TYPES))
parser.add_argument("--vt-type", action="store", dest="vt.type",
Expand Down
Binary file modified selftests/unit/unittest_data/testcfg.huge/test1.cfg.repr.gz
Binary file not shown.
6 changes: 3 additions & 3 deletions virttest/cartesian_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,19 +1439,19 @@ def only_filter(self, variant):

def no_filter(self, variant):
"""
Apply a only filter programatically and keep track of it.
Apply a no filter programatically and keep track of it.
Equivalent to parse a "no variant" line.
:param variant: String with the variant name.
"""
string = "no %s" % variant
self.only_filters.append(string)
self.no_filters.append(string)
self.parse_string(string)

def assign(self, key, value):
"""
Apply a only filter programatically and keep track of it.
Apply an assigment programatically and keep track of it.
Equivalent to parse a "key = value" line.
Expand Down

0 comments on commit 6d5077b

Please sign in to comment.