mirror of
https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git
synced 2025-08-29 10:35:58 +00:00
Fix profile and group merging
Any of the four might not exist. At least *one* of the four has to exist, but we can't rely on any particular one existing, so we have to be very defensive. The only rule is that at least one out of profiles and groups has to exist after merge. Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
parent
b3463c5746
commit
4781fc28ce
17
fifloader.py
17
fifloader.py
@ -179,20 +179,17 @@ def merge_inputs(inputs, validate=False, clean=False):
|
||||
for (name, newsuite) in data['TestSuites'].items():
|
||||
try:
|
||||
existing = testsuites[name]
|
||||
# combine and stash the profiles and groups
|
||||
combinedprofiles = {}
|
||||
if 'profiles' in existing:
|
||||
existing['profiles'].update(newsuite['profiles'])
|
||||
combinedprofiles = existing['profiles']
|
||||
combinedpgroups = {}
|
||||
if 'profile_groups' in existing:
|
||||
existing['profile_groups'].update(newsuite.get('profile_groups', {}))
|
||||
combinedpgroups = existing['profile_groups']
|
||||
# copy, combine and stash the profiles and groups
|
||||
combinedprofiles = dict(existing.get('profiles', {}))
|
||||
combinedprofiles.update(newsuite.get('profiles', {}))
|
||||
combinedpgroups = dict(existing.get('profile_groups', {}))
|
||||
combinedpgroups.update(newsuite.get('profile_groups', {}))
|
||||
# now update the existing suite with the new one, this
|
||||
# will overwrite the profiles and groups
|
||||
existing.update(newsuite)
|
||||
# now restore the combined profiles and groups
|
||||
existing['profiles'] = combinedprofiles
|
||||
if combinedprofiles:
|
||||
existing['profiles'] = combinedprofiles
|
||||
if combinedpgroups:
|
||||
existing['profile_groups'] = combinedpgroups
|
||||
except KeyError:
|
||||
|
@ -50,6 +50,11 @@
|
||||
"profiles": {
|
||||
"fedora-updates-server-x86_64-*-64bit": 40
|
||||
}
|
||||
},
|
||||
"base_update_cli": {
|
||||
"profiles": {
|
||||
"fedora-updates-server-ppc64le-*-ppc64le": 40
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,6 +91,11 @@
|
||||
"USER_LOGIN": "false"
|
||||
}
|
||||
},
|
||||
"base_update_cli": {
|
||||
"profile_groups": {
|
||||
"fedora-server-2arch": 30
|
||||
}
|
||||
},
|
||||
"install_default_upload": {
|
||||
"profile_groups": {
|
||||
"fedora-server-2arch": 10
|
||||
|
@ -85,14 +85,17 @@ def test_merge_inputs(input1, input2):
|
||||
assert len(pgroups) == 3
|
||||
assert not jobtemplates
|
||||
# testsuite merging is the most complex feature
|
||||
# len should be 3 as there is 1 unique suite in each input file,
|
||||
# and one defined in both which should be merged
|
||||
assert len(testsuites) == 3
|
||||
# len should be 4 as there is 1 unique suite in each input file,
|
||||
# and two defined in both which should be merged
|
||||
assert len(testsuites) == 4
|
||||
# check the merged suite was merged correctly
|
||||
# we should have the profiles and profile groups from *both*
|
||||
# input files...
|
||||
assert len(testsuites['base_selinux']['profiles']) == 2
|
||||
assert len(testsuites['base_selinux']['profile_groups']) == 2
|
||||
# ...including when only one file has each attribute...
|
||||
assert len(testsuites['base_update_cli']['profile_groups']) == 1
|
||||
assert len(testsuites['base_update_cli']['profiles']) == 1
|
||||
# and we should still have the settings (note, combining settings
|
||||
# is not supported, the last-read settings dict is always used)
|
||||
assert len(testsuites['base_selinux']['settings']) == 6
|
||||
@ -107,7 +110,7 @@ def test_generate_job_templates():
|
||||
(machines, _, products, profiles, pgroups, testsuites, _) = _get_merged()
|
||||
templates = fifloader.generate_job_templates(products, profiles, pgroups, testsuites)
|
||||
# we should get one template per profile in merged input
|
||||
assert len(templates) == 8
|
||||
assert len(templates) == 11
|
||||
for template in templates:
|
||||
assert template['group_name'] in ['fedora', 'Fedora PowerPC', 'Fedora AArch64',
|
||||
'Fedora Updates', 'Fedora PowerPC Updates',
|
||||
|
Loading…
Reference in New Issue
Block a user