mirror of
https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git
synced 2025-08-30 11:05:50 +00:00
Allow nested ProfileGroups
OK, this is getting kinda close to over-engineering, but what the heck. With this, a profile group can contain another profile group. There is no infinite recursion protection yet. Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
parent
4781fc28ce
commit
900629606b
21
fifloader.py
21
fifloader.py
@ -222,6 +222,22 @@ def merge_inputs(inputs, validate=False, clean=False):
|
||||
|
||||
return (machines, flavors, products, profiles, pgroups, testsuites, jobtemplates)
|
||||
|
||||
def recurse_pgroup(pgroup, baseprio, pgroups, seen):
|
||||
"""Recursion handler allowing nested profile groups. Takes the
|
||||
top-level profile group name and priority, the full ProfileGroups
|
||||
dict, and a set for infinite recursion checking.
|
||||
"""
|
||||
profiles = {}
|
||||
for (item, prio) in pgroups[pgroup].items():
|
||||
if item in seen:
|
||||
sys.exit(f"Infinite recursion between profile groups {pgroup} and {item}")
|
||||
seen.add(item)
|
||||
if item in pgroups:
|
||||
profiles.update(recurse_pgroup(item, prio+baseprio, pgroups, seen))
|
||||
else:
|
||||
profiles[item] = prio+baseprio
|
||||
return profiles
|
||||
|
||||
def generate_job_templates(products, profiles, pgroups, testsuites):
|
||||
"""Given machines, products, profiles and testsuites (after
|
||||
merging and handling of flavors, but still in intermediate format),
|
||||
@ -231,10 +247,7 @@ def generate_job_templates(products, profiles, pgroups, testsuites):
|
||||
for (name, suite) in testsuites.items():
|
||||
suiteprofs = {}
|
||||
for (pgroup, baseprio) in suite.get('profile_groups', {}).items():
|
||||
if pgroup not in pgroups:
|
||||
sys.exit(f"Error: profile group {pgroup} does not exist!")
|
||||
for (gotprof, pprio) in pgroups[pgroup].items():
|
||||
suiteprofs[gotprof] = pprio+baseprio
|
||||
suiteprofs.update(recurse_pgroup(pgroup, baseprio, pgroups, set()))
|
||||
suiteprofs.update(suite.get('profiles', {}))
|
||||
if not suiteprofs:
|
||||
print("Warning: no profiles for test suite {}".format(name))
|
||||
|
@ -67,7 +67,7 @@
|
||||
},
|
||||
"ProfileGroups": {
|
||||
"fedora-server-2arch": {
|
||||
"fedora-Server-dvd-iso-ppc64le-*-ppc64le": 0,
|
||||
"fedora-server-1arch": 0,
|
||||
"fedora-Server-dvd-iso-x86_64-*-64bit": 1
|
||||
},
|
||||
"fedora-server-1arch": {
|
||||
|
@ -129,6 +129,11 @@ def test_generate_job_templates():
|
||||
assert len(aboots) == 4
|
||||
assert {t['machine_name'] for t in aboots} == {'ppc64le', '64bit'}
|
||||
|
||||
# test the recursion check
|
||||
pgroups['fedora-server-1arch']['fedora-server-2arch'] = 0
|
||||
with pytest.raises(SystemExit, match=r"^Infinite recursion.*"):
|
||||
templates = fifloader.generate_job_templates(products, profiles, pgroups, testsuites)
|
||||
|
||||
def test_reverse_qol():
|
||||
"""Test for reverse_qol."""
|
||||
(machines, flavors, products, _, _, testsuites, _) = _get_merged()
|
||||
|
Loading…
Reference in New Issue
Block a user