mirror of
https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git
synced 2025-09-01 03:55:53 +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
15
fifloader.py
15
fifloader.py
@ -179,19 +179,16 @@ def merge_inputs(inputs, validate=False, clean=False):
|
|||||||
for (name, newsuite) in data['TestSuites'].items():
|
for (name, newsuite) in data['TestSuites'].items():
|
||||||
try:
|
try:
|
||||||
existing = testsuites[name]
|
existing = testsuites[name]
|
||||||
# combine and stash the profiles and groups
|
# copy, combine and stash the profiles and groups
|
||||||
combinedprofiles = {}
|
combinedprofiles = dict(existing.get('profiles', {}))
|
||||||
if 'profiles' in existing:
|
combinedprofiles.update(newsuite.get('profiles', {}))
|
||||||
existing['profiles'].update(newsuite['profiles'])
|
combinedpgroups = dict(existing.get('profile_groups', {}))
|
||||||
combinedprofiles = existing['profiles']
|
combinedpgroups.update(newsuite.get('profile_groups', {}))
|
||||||
combinedpgroups = {}
|
|
||||||
if 'profile_groups' in existing:
|
|
||||||
existing['profile_groups'].update(newsuite.get('profile_groups', {}))
|
|
||||||
combinedpgroups = existing['profile_groups']
|
|
||||||
# now update the existing suite with the new one, this
|
# now update the existing suite with the new one, this
|
||||||
# will overwrite the profiles and groups
|
# will overwrite the profiles and groups
|
||||||
existing.update(newsuite)
|
existing.update(newsuite)
|
||||||
# now restore the combined profiles and groups
|
# now restore the combined profiles and groups
|
||||||
|
if combinedprofiles:
|
||||||
existing['profiles'] = combinedprofiles
|
existing['profiles'] = combinedprofiles
|
||||||
if combinedpgroups:
|
if combinedpgroups:
|
||||||
existing['profile_groups'] = combinedpgroups
|
existing['profile_groups'] = combinedpgroups
|
||||||
|
@ -50,6 +50,11 @@
|
|||||||
"profiles": {
|
"profiles": {
|
||||||
"fedora-updates-server-x86_64-*-64bit": 40
|
"fedora-updates-server-x86_64-*-64bit": 40
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"base_update_cli": {
|
||||||
|
"profiles": {
|
||||||
|
"fedora-updates-server-ppc64le-*-ppc64le": 40
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,11 @@
|
|||||||
"USER_LOGIN": "false"
|
"USER_LOGIN": "false"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"base_update_cli": {
|
||||||
|
"profile_groups": {
|
||||||
|
"fedora-server-2arch": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
"install_default_upload": {
|
"install_default_upload": {
|
||||||
"profile_groups": {
|
"profile_groups": {
|
||||||
"fedora-server-2arch": 10
|
"fedora-server-2arch": 10
|
||||||
|
@ -85,14 +85,17 @@ def test_merge_inputs(input1, input2):
|
|||||||
assert len(pgroups) == 3
|
assert len(pgroups) == 3
|
||||||
assert not jobtemplates
|
assert not jobtemplates
|
||||||
# testsuite merging is the most complex feature
|
# testsuite merging is the most complex feature
|
||||||
# len should be 3 as there is 1 unique suite in each input file,
|
# len should be 4 as there is 1 unique suite in each input file,
|
||||||
# and one defined in both which should be merged
|
# and two defined in both which should be merged
|
||||||
assert len(testsuites) == 3
|
assert len(testsuites) == 4
|
||||||
# check the merged suite was merged correctly
|
# check the merged suite was merged correctly
|
||||||
# we should have the profiles and profile groups from *both*
|
# we should have the profiles and profile groups from *both*
|
||||||
# input files...
|
# input files...
|
||||||
assert len(testsuites['base_selinux']['profiles']) == 2
|
assert len(testsuites['base_selinux']['profiles']) == 2
|
||||||
assert len(testsuites['base_selinux']['profile_groups']) == 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
|
# and we should still have the settings (note, combining settings
|
||||||
# is not supported, the last-read settings dict is always used)
|
# is not supported, the last-read settings dict is always used)
|
||||||
assert len(testsuites['base_selinux']['settings']) == 6
|
assert len(testsuites['base_selinux']['settings']) == 6
|
||||||
@ -107,7 +110,7 @@ def test_generate_job_templates():
|
|||||||
(machines, _, products, profiles, pgroups, testsuites, _) = _get_merged()
|
(machines, _, products, profiles, pgroups, testsuites, _) = _get_merged()
|
||||||
templates = fifloader.generate_job_templates(products, profiles, pgroups, testsuites)
|
templates = fifloader.generate_job_templates(products, profiles, pgroups, testsuites)
|
||||||
# we should get one template per profile in merged input
|
# we should get one template per profile in merged input
|
||||||
assert len(templates) == 8
|
assert len(templates) == 11
|
||||||
for template in templates:
|
for template in templates:
|
||||||
assert template['group_name'] in ['fedora', 'Fedora PowerPC', 'Fedora AArch64',
|
assert template['group_name'] in ['fedora', 'Fedora PowerPC', 'Fedora AArch64',
|
||||||
'Fedora Updates', 'Fedora PowerPC Updates',
|
'Fedora Updates', 'Fedora PowerPC Updates',
|
||||||
|
Loading…
Reference in New Issue
Block a user