pkgset: Allow populating packages from multiple koji tags

One of the use cases is https://pagure.io/odcs/issue/7.

Merges: #660
Signed-off-by: Qixiang Wan <qwan@redhat.com>
This commit is contained in:
Qixiang Wan 2017-06-27 19:48:02 +08:00 committed by Lubomír Sedlář
parent 9193a6902e
commit 18bd37ff2c
5 changed files with 43 additions and 4 deletions

View File

@ -405,7 +405,7 @@ Options
(*str*) -- "koji" (any koji instance) or "repos" (arbitrary yum repositories)
**pkgset_koji_tag** [mandatory]
(*str*) -- tag to read package set from
(*str|[str]*) -- tag(s) to read package set from
**pkgset_koji_inherit** = True
(*bool*) -- inherit builds from parent tags; we can turn it off only if we

View File

@ -718,7 +718,7 @@ def _make_schema():
"koji_profile": {"type": "string"},
"pkgset_koji_tag": {"type": "string"},
"pkgset_koji_tag": {"$ref": "#/definitions/strings"},
"pkgset_koji_inherit": {
"type": "boolean",
"default": True

View File

@ -18,6 +18,7 @@ import os
import cPickle as pickle
import json
import re
from kobo.shortcuts import force_list
import pungi.wrappers.kojiwrapper
import pungi.phases.pkgset.pkgsets
@ -196,12 +197,12 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, event_id):
compose_tags.append(tag)
if not variant_tags[variant]:
variant_tags[variant].append(compose.conf["pkgset_koji_tag"])
variant_tags[variant].extend(force_list(compose.conf["pkgset_koji_tag"]))
# In case we have no compose tag from module, use the default
# one from config.
if not compose_tags:
compose_tags.append(compose.conf["pkgset_koji_tag"])
compose_tags.extend(force_list(compose.conf["pkgset_koji_tag"]))
inherit = compose.conf["pkgset_koji_inherit"]
global_pkgset_path = os.path.join(

View File

@ -65,6 +65,14 @@ class PkgsetConfigTestCase(ConfigTestCase):
[checks.REQUIRES.format('pkgset_source', 'koji', 'pkgset_koji_tag'),
checks.CONFLICTS.format('pkgset_source', 'koji', 'pkgset_repos')])
def test_pkgset_multiple_koji_tags(self):
cfg = load_config(
pkgset_source='koji',
pkgset_koji_tag=['f25', 'f25-extra'],
pkgset_koji_inherit=False,
)
self.assertValidation(cfg)
class ReleaseConfigTestCase(ConfigTestCase):
def test_layered_without_base_product(self):

View File

@ -117,6 +117,36 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase):
with open(self.pkgset_path) as f:
self.assertEqual(f.read(), 'DATA')
@mock.patch('cPickle.dumps')
@mock.patch('pungi.phases.pkgset.pkgsets.KojiPackageSet')
def test_populate_with_multiple_koji_tags(self, KojiPackageSet, pickle_dumps):
self.compose = helpers.DummyCompose(self.topdir, {
'pkgset_koji_tag': ['f25', 'f25-extra'],
'sigkeys': mock.Mock(),
})
self.compose.DEBUG = False
pickle_dumps.return_value = 'DATA'
orig_pkgset = KojiPackageSet.return_value
pkgset = source_koji.populate_global_pkgset(
self.compose, self.koji_wrapper, '/prefix', 123456)
self.assertIs(pkgset, orig_pkgset)
pkgset.assert_has_calls([mock.call.populate('f25', 123456, inherit=True,
logfile=self.topdir + '/logs/global/packages_from_f25.global.log')])
pkgset.assert_has_calls([mock.call.populate('f25-extra', 123456, inherit=True,
logfile=self.topdir + '/logs/global/packages_from_f25-extra.global.log')])
pkgset.assert_has_calls([mock.call.save_file_list(self.topdir + '/work/global/package_list/global.conf',
remove_path_prefix='/prefix')])
# for each tag, call pkgset.merge once for each variant and once for global pkgset
self.assertEqual(pkgset.merge.call_count, 2 * (len(self.compose.all_variants.values()) + 1))
self.assertItemsEqual(pickle_dumps.call_args_list,
[mock.call(orig_pkgset)])
with open(self.pkgset_path) as f:
self.assertEqual(f.read(), 'DATA')
@mock.patch('cPickle.load')
def test_populate_in_debug_mode(self, pickle_load):
helpers.touch(self.pkgset_path, 'DATA')