2016-04-22 09:15:06 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import mock
|
|
|
|
import os
|
2019-10-04 12:45:03 +00:00
|
|
|
import six
|
2020-01-22 10:02:22 +00:00
|
|
|
|
2016-05-25 11:39:02 +00:00
|
|
|
try:
|
|
|
|
import unittest2 as unittest
|
|
|
|
except ImportError:
|
|
|
|
import unittest
|
2016-04-22 09:15:06 +00:00
|
|
|
import json
|
2016-04-26 12:55:46 +00:00
|
|
|
import tempfile
|
2018-01-02 20:06:08 +00:00
|
|
|
import re
|
2018-08-15 07:20:40 +00:00
|
|
|
from dogpile.cache import make_region
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
from pungi.phases.pkgset import pkgsets
|
|
|
|
from tests import helpers
|
|
|
|
|
|
|
|
|
|
|
|
class MockPathInfo(object):
|
|
|
|
def __init__(self, topdir):
|
|
|
|
self.topdir = topdir
|
|
|
|
|
|
|
|
def build(self, build_info):
|
|
|
|
return self.topdir
|
|
|
|
|
|
|
|
def get_filename(self, rpm_info):
|
2020-01-22 10:02:22 +00:00
|
|
|
return "{name}@{version}@{release}@{arch}".format(**rpm_info)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
def signed(self, rpm_info, sigkey):
|
2020-01-22 10:02:22 +00:00
|
|
|
return os.path.join("signed", sigkey, self.get_filename(rpm_info))
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
def rpm(self, rpm_info):
|
2020-01-22 10:02:22 +00:00
|
|
|
return os.path.join("rpms", self.get_filename(rpm_info))
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
class MockFile(object):
|
|
|
|
def __init__(self, path):
|
2020-01-22 10:02:22 +00:00
|
|
|
if path.startswith("/tmp"):
|
2016-04-22 09:15:06 +00:00
|
|
|
# Drop /tmp/something/ from path
|
2020-01-22 10:02:22 +00:00
|
|
|
path = path.split("/", 3)[-1]
|
2016-04-22 12:05:38 +00:00
|
|
|
self.file_path = path
|
2016-04-22 09:15:06 +00:00
|
|
|
self.file_name = os.path.basename(path)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.name, self.version, self.release, self.arch = self.file_name.split("@")
|
|
|
|
self.sourcerpm = "{0.name}-{0.version}-{0.release}.{0.arch}".format(self)
|
2016-04-22 12:05:38 +00:00
|
|
|
self.exclusivearch = []
|
|
|
|
self.excludearch = []
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
def __hash__(self):
|
2016-04-22 12:05:38 +00:00
|
|
|
return hash(self.file_path)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
def __repr__(self):
|
2016-04-22 12:05:38 +00:00
|
|
|
return self.file_path
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
def __eq__(self, other):
|
|
|
|
try:
|
2016-04-22 12:05:38 +00:00
|
|
|
return self.file_path == other.file_path
|
2016-04-22 09:15:06 +00:00
|
|
|
except AttributeError:
|
2016-04-22 12:05:38 +00:00
|
|
|
return self.file_path == other
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
def __le__(self, other):
|
|
|
|
try:
|
2016-04-22 12:05:38 +00:00
|
|
|
return self.file_path < other.file_path
|
2016-04-22 09:15:06 +00:00
|
|
|
except AttributeError:
|
2016-04-22 12:05:38 +00:00
|
|
|
return self.file_path < other
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2016-05-25 11:27:57 +00:00
|
|
|
def __lt__(self, other):
|
|
|
|
return self <= other and self != other
|
|
|
|
|
|
|
|
def __ge__(self, other):
|
|
|
|
return not (self <= other) or self == other
|
|
|
|
|
|
|
|
def __gt__(self, other):
|
|
|
|
return not (self <= other)
|
|
|
|
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
class MockFileCache(dict):
|
|
|
|
"""Mock for kobo.pkgset.FileCache.
|
|
|
|
It gets data from filename and does not touch filesystem.
|
|
|
|
"""
|
2020-01-22 10:02:22 +00:00
|
|
|
|
2016-04-22 09:15:06 +00:00
|
|
|
def __init__(self, _wrapper):
|
|
|
|
super(MockFileCache, self).__init__()
|
2016-04-28 07:05:03 +00:00
|
|
|
self.file_cache = self
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
def add(self, file_path):
|
|
|
|
obj = MockFile(file_path)
|
|
|
|
self[file_path] = obj
|
|
|
|
return obj
|
|
|
|
|
|
|
|
|
|
|
|
class FakePool(object):
|
|
|
|
"""This class will be substituted for ReaderPool.
|
|
|
|
It implements the same interface, but uses only the last added worker to
|
|
|
|
process all tasks sequentially.
|
|
|
|
"""
|
2020-01-22 10:02:22 +00:00
|
|
|
|
2016-04-22 09:15:06 +00:00
|
|
|
def __init__(self, package_set, logger=None):
|
|
|
|
self.queue = []
|
|
|
|
self.worker = None
|
|
|
|
self.package_set = package_set
|
|
|
|
|
|
|
|
def log_warning(self, *args, **kwargs):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@property
|
|
|
|
def queue_total(self):
|
|
|
|
return len(self.queue)
|
|
|
|
|
|
|
|
def queue_put(self, item):
|
|
|
|
self.queue.append(item)
|
|
|
|
|
|
|
|
def add(self, worker):
|
|
|
|
self.worker = worker
|
|
|
|
|
|
|
|
def start(self):
|
|
|
|
for i, item in enumerate(self.queue):
|
|
|
|
self.worker.process(item, i)
|
|
|
|
|
|
|
|
def stop(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2016-04-22 12:05:38 +00:00
|
|
|
class PkgsetCompareMixin(object):
|
|
|
|
def assertPkgsetEqual(self, actual, expected):
|
2017-09-05 08:01:21 +00:00
|
|
|
for k, v1 in expected.items():
|
2016-04-22 12:05:38 +00:00
|
|
|
self.assertIn(k, actual)
|
|
|
|
v2 = actual.pop(k)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(self, v1, v2)
|
2016-04-22 12:05:38 +00:00
|
|
|
self.assertEqual({}, actual)
|
|
|
|
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.pkgset.pkgsets.ReaderPool", new=FakePool)
|
|
|
|
@mock.patch("kobo.pkgset.FileCache", new=MockFileCache)
|
2016-04-22 12:05:38 +00:00
|
|
|
class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
|
2016-04-22 09:15:06 +00:00
|
|
|
def setUp(self):
|
|
|
|
super(TestKojiPkgset, self).setUp()
|
2020-01-22 10:02:22 +00:00
|
|
|
with open(os.path.join(helpers.FIXTURE_DIR, "tagged-rpms.json")) as f:
|
2016-04-22 09:15:06 +00:00
|
|
|
self.tagged_rpms = json.load(f)
|
|
|
|
|
|
|
|
self.path_info = MockPathInfo(self.topdir)
|
|
|
|
|
|
|
|
self.koji_wrapper = mock.Mock()
|
|
|
|
self.koji_wrapper.koji_proxy.listTaggedRPMS.return_value = self.tagged_rpms
|
|
|
|
self.koji_wrapper.koji_module.pathinfo = self.path_info
|
|
|
|
|
|
|
|
def _touch_files(self, filenames):
|
|
|
|
for filename in filenames:
|
|
|
|
helpers.touch(os.path.join(self.topdir, filename))
|
|
|
|
|
|
|
|
def assertPkgsetEqual(self, actual, expected):
|
2017-09-05 08:01:21 +00:00
|
|
|
for k, v1 in expected.items():
|
2016-04-22 09:15:06 +00:00
|
|
|
self.assertIn(k, actual)
|
|
|
|
v2 = actual.pop(k)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(self, v1, v2)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual({}, actual, msg="Some architectures were missing")
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
def test_all_arches(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
self._touch_files(
|
|
|
|
[
|
|
|
|
"rpms/pungi@4.1.3@3.fc25@noarch",
|
|
|
|
"rpms/pungi@4.1.3@3.fc25@src",
|
|
|
|
"rpms/bash@4.3.42@4.fc24@i686",
|
|
|
|
"rpms/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
"rpms/bash@4.3.42@4.fc24@src",
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@i686",
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
]
|
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2019-07-25 13:35:02 +00:00
|
|
|
pkgset = pkgsets.KojiPackageSet("pkgset", self.koji_wrapper, [None])
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
result = pkgset.populate("f25")
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
self.koji_wrapper.koji_proxy.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[mock.call.listTaggedRPMS("f25", event=None, inherit=True, latest=True)],
|
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
result,
|
|
|
|
{
|
|
|
|
"src": ["rpms/pungi@4.1.3@3.fc25@src", "rpms/bash@4.3.42@4.fc24@src"],
|
|
|
|
"noarch": ["rpms/pungi@4.1.3@3.fc25@noarch"],
|
|
|
|
"i686": [
|
|
|
|
"rpms/bash@4.3.42@4.fc24@i686",
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@i686",
|
|
|
|
],
|
|
|
|
"x86_64": [
|
|
|
|
"rpms/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
def test_only_one_arch(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
self._touch_files(
|
|
|
|
[
|
|
|
|
"rpms/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
]
|
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2019-07-25 13:35:02 +00:00
|
|
|
pkgset = pkgsets.KojiPackageSet(
|
2020-01-22 10:02:22 +00:00
|
|
|
"pkgset", self.koji_wrapper, [None], arches=["x86_64"]
|
2019-07-25 13:35:02 +00:00
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
result = pkgset.populate("f25")
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
self.koji_wrapper.koji_proxy.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[mock.call.listTaggedRPMS("f25", event=None, inherit=True, latest=True)],
|
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
result,
|
|
|
|
{
|
|
|
|
"x86_64": [
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
"rpms/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
]
|
|
|
|
},
|
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
def test_find_signed_with_preference(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
self._touch_files(
|
|
|
|
[
|
|
|
|
"signed/cafebabe/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
"signed/deadbeef/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
"signed/deadbeef/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
]
|
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2019-07-25 13:35:02 +00:00
|
|
|
pkgset = pkgsets.KojiPackageSet(
|
2020-01-22 10:02:22 +00:00
|
|
|
"pkgset", self.koji_wrapper, ["cafebabe", "deadbeef"], arches=["x86_64"]
|
2019-07-25 13:35:02 +00:00
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
result = pkgset.populate("f25")
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
self.koji_wrapper.koji_proxy.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[mock.call.listTaggedRPMS("f25", event=None, inherit=True, latest=True)],
|
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
result,
|
|
|
|
{
|
|
|
|
"x86_64": [
|
|
|
|
"signed/cafebabe/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
"signed/deadbeef/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
]
|
|
|
|
},
|
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
def test_find_signed_fallback_unsigned(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
self._touch_files(
|
|
|
|
[
|
|
|
|
"signed/cafebabe/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
]
|
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2019-07-25 13:35:02 +00:00
|
|
|
pkgset = pkgsets.KojiPackageSet(
|
2020-01-22 10:02:22 +00:00
|
|
|
"pkgset", self.koji_wrapper, ["cafebabe", None], arches=["x86_64"]
|
2019-07-25 13:35:02 +00:00
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
result = pkgset.populate("f25")
|
2016-04-22 09:15:06 +00:00
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
self.koji_wrapper.koji_proxy.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[mock.call.listTaggedRPMS("f25", event=None, inherit=True, latest=True)],
|
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
result,
|
|
|
|
{
|
|
|
|
"x86_64": [
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
"signed/cafebabe/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
]
|
|
|
|
},
|
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2016-04-26 12:41:39 +00:00
|
|
|
def test_can_not_find_signed_package(self):
|
2019-07-25 13:35:02 +00:00
|
|
|
pkgset = pkgsets.KojiPackageSet(
|
2020-01-22 10:02:22 +00:00
|
|
|
"pkgset", self.koji_wrapper, ["cafebabe"], arches=["x86_64"]
|
2019-07-25 13:35:02 +00:00
|
|
|
)
|
2016-04-26 12:41:39 +00:00
|
|
|
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
2020-01-22 10:02:22 +00:00
|
|
|
pkgset.populate("f25")
|
2016-04-26 12:41:39 +00:00
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
self.koji_wrapper.koji_proxy.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[mock.call.listTaggedRPMS("f25", event=None, inherit=True, latest=True)],
|
|
|
|
)
|
2016-04-26 12:41:39 +00:00
|
|
|
|
2018-01-02 20:06:08 +00:00
|
|
|
figure = re.compile(
|
2020-02-06 07:09:32 +00:00
|
|
|
r"^RPM\(s\) not found for sigs: .+Check log for details.+bash-4\.3\.42-4\.fc24.+bash-debuginfo-4\.3\.42-4\.fc24$", # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
re.DOTALL,
|
|
|
|
)
|
2018-01-02 20:06:08 +00:00
|
|
|
self.assertRegexpMatches(str(ctx.exception), figure)
|
2016-04-26 12:41:39 +00:00
|
|
|
|
2018-02-12 07:02:45 +00:00
|
|
|
def test_can_not_find_signed_package_allow_invalid_sigkeys(self):
|
2019-07-25 13:35:02 +00:00
|
|
|
pkgset = pkgsets.KojiPackageSet(
|
|
|
|
"pkgset",
|
|
|
|
self.koji_wrapper,
|
2020-01-22 10:02:22 +00:00
|
|
|
["cafebabe"],
|
|
|
|
arches=["x86_64"],
|
2019-07-25 13:35:02 +00:00
|
|
|
allow_invalid_sigkeys=True,
|
|
|
|
)
|
2018-02-12 07:02:45 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
pkgset.populate("f25")
|
2018-02-12 07:02:45 +00:00
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
self.koji_wrapper.koji_proxy.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[mock.call.listTaggedRPMS("f25", event=None, inherit=True, latest=True)],
|
|
|
|
)
|
2018-02-12 07:02:45 +00:00
|
|
|
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
2018-02-12 12:21:07 +00:00
|
|
|
pkgset.raise_invalid_sigkeys_exception(pkgset.invalid_sigkey_rpms)
|
2018-02-12 07:02:45 +00:00
|
|
|
|
|
|
|
figure = re.compile(
|
2020-02-06 07:09:32 +00:00
|
|
|
r"^RPM\(s\) not found for sigs: .+Check log for details.+bash-4\.3\.42-4\.fc24.+bash-debuginfo-4\.3\.42-4\.fc24$", # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
re.DOTALL,
|
|
|
|
)
|
2018-02-12 07:02:45 +00:00
|
|
|
self.assertRegexpMatches(str(ctx.exception), figure)
|
|
|
|
|
2016-04-26 12:41:39 +00:00
|
|
|
def test_can_not_find_any_package(self):
|
2019-07-25 13:35:02 +00:00
|
|
|
pkgset = pkgsets.KojiPackageSet(
|
2020-01-22 10:02:22 +00:00
|
|
|
"pkgset", self.koji_wrapper, ["cafebabe", None], arches=["x86_64"]
|
2019-07-25 13:35:02 +00:00
|
|
|
)
|
2016-04-26 12:41:39 +00:00
|
|
|
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
2020-01-22 10:02:22 +00:00
|
|
|
pkgset.populate("f25")
|
2016-04-26 12:41:39 +00:00
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
self.koji_wrapper.koji_proxy.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[mock.call.listTaggedRPMS("f25", event=None, inherit=True, latest=True)],
|
|
|
|
)
|
2016-04-26 12:41:39 +00:00
|
|
|
|
2017-10-30 08:16:18 +00:00
|
|
|
self.assertRegexpMatches(
|
|
|
|
str(ctx.exception),
|
2020-01-22 10:02:22 +00:00
|
|
|
r"^RPM\(s\) not found for sigs: .+Check log for details.+",
|
|
|
|
)
|
2016-04-26 12:41:39 +00:00
|
|
|
|
2017-10-16 12:20:37 +00:00
|
|
|
def test_packages_attribute(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
self._touch_files(
|
|
|
|
[
|
|
|
|
"rpms/pungi@4.1.3@3.fc25@noarch",
|
|
|
|
"rpms/pungi@4.1.3@3.fc25@src",
|
|
|
|
"rpms/bash@4.3.42@4.fc24@i686",
|
|
|
|
"rpms/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
"rpms/bash@4.3.42@4.fc24@src",
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@i686",
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
]
|
|
|
|
)
|
2017-10-16 12:20:37 +00:00
|
|
|
|
2019-07-25 13:35:02 +00:00
|
|
|
pkgset = pkgsets.KojiPackageSet(
|
|
|
|
"pkgset",
|
|
|
|
self.koji_wrapper,
|
|
|
|
[None],
|
|
|
|
packages=["bash"],
|
|
|
|
populate_only_packages=True,
|
|
|
|
)
|
2017-10-16 12:20:37 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
result = pkgset.populate("f25")
|
2017-10-16 12:20:37 +00:00
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
self.koji_wrapper.koji_proxy.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[mock.call.listTaggedRPMS("f25", event=None, inherit=True, latest=True)],
|
|
|
|
)
|
2017-10-16 12:20:37 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
result,
|
|
|
|
{
|
|
|
|
"src": ["rpms/bash@4.3.42@4.fc24@src"],
|
|
|
|
"i686": ["rpms/bash@4.3.42@4.fc24@i686"],
|
|
|
|
"x86_64": ["rpms/bash@4.3.42@4.fc24@x86_64"],
|
|
|
|
},
|
|
|
|
)
|
2017-10-16 12:20:37 +00:00
|
|
|
|
2018-08-15 07:20:40 +00:00
|
|
|
def test_get_latest_rpms_cache(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
self._touch_files(
|
|
|
|
[
|
|
|
|
"rpms/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
]
|
|
|
|
)
|
2018-08-15 07:20:40 +00:00
|
|
|
|
|
|
|
cache_region = make_region().configure("dogpile.cache.memory")
|
2019-07-25 13:35:02 +00:00
|
|
|
pkgset = pkgsets.KojiPackageSet(
|
|
|
|
"pkgset",
|
|
|
|
self.koji_wrapper,
|
|
|
|
[None],
|
2020-01-22 10:02:22 +00:00
|
|
|
arches=["x86_64"],
|
2019-07-25 13:35:02 +00:00
|
|
|
cache_region=cache_region,
|
|
|
|
)
|
2018-08-15 07:20:40 +00:00
|
|
|
|
|
|
|
# Try calling the populate twice, but expect just single listTaggedRPMs
|
|
|
|
# call - that means the caching worked.
|
|
|
|
for i in range(2):
|
2020-01-22 10:02:22 +00:00
|
|
|
result = pkgset.populate("f25")
|
2018-08-15 07:20:40 +00:00
|
|
|
self.assertEqual(
|
|
|
|
self.koji_wrapper.koji_proxy.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call.listTaggedRPMS(
|
|
|
|
"f25", event=None, inherit=True, latest=True
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2018-08-15 07:20:40 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
result,
|
2020-01-22 10:02:22 +00:00
|
|
|
{
|
|
|
|
"x86_64": [
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
"rpms/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
]
|
|
|
|
},
|
|
|
|
)
|
2018-08-15 07:20:40 +00:00
|
|
|
|
|
|
|
def test_get_latest_rpms_cache_different_id(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
self._touch_files(
|
|
|
|
[
|
|
|
|
"rpms/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
]
|
|
|
|
)
|
2018-08-15 07:20:40 +00:00
|
|
|
|
|
|
|
cache_region = make_region().configure("dogpile.cache.memory")
|
2019-07-25 13:35:02 +00:00
|
|
|
pkgset = pkgsets.KojiPackageSet(
|
|
|
|
"pkgset",
|
|
|
|
self.koji_wrapper,
|
|
|
|
[None],
|
2020-01-22 10:02:22 +00:00
|
|
|
arches=["x86_64"],
|
2019-07-25 13:35:02 +00:00
|
|
|
cache_region=cache_region,
|
|
|
|
)
|
2018-08-15 07:20:40 +00:00
|
|
|
|
|
|
|
# Try calling the populate twice with different event id. It must not
|
|
|
|
# cache anything.
|
|
|
|
expected_calls = []
|
|
|
|
for i in range(2):
|
|
|
|
expected_calls.append(
|
2020-01-22 10:02:22 +00:00
|
|
|
mock.call.listTaggedRPMS("f25", event=i, inherit=True, latest=True)
|
|
|
|
)
|
|
|
|
result = pkgset.populate("f25", event={"id": i})
|
|
|
|
self.assertEqual(self.koji_wrapper.koji_proxy.mock_calls, expected_calls)
|
2018-08-15 07:20:40 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
result,
|
2020-01-22 10:02:22 +00:00
|
|
|
{
|
|
|
|
"x86_64": [
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
"rpms/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
]
|
|
|
|
},
|
|
|
|
)
|
2016-04-22 09:15:06 +00:00
|
|
|
|
2018-09-14 08:59:53 +00:00
|
|
|
def test_extra_builds_attribute(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
self._touch_files(
|
|
|
|
[
|
|
|
|
"rpms/pungi@4.1.3@3.fc25@noarch",
|
|
|
|
"rpms/pungi@4.1.3@3.fc25@src",
|
|
|
|
"rpms/bash@4.3.42@4.fc24@i686",
|
|
|
|
"rpms/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
"rpms/bash@4.3.42@4.fc24@src",
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@i686",
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
]
|
|
|
|
)
|
2018-09-14 08:59:53 +00:00
|
|
|
|
|
|
|
# Return "pungi" RPMs and builds using "get_latest_rpms" which gets
|
|
|
|
# them from Koji multiCall.
|
2020-01-22 10:02:22 +00:00
|
|
|
extra_rpms = [rpm for rpm in self.tagged_rpms[0] if rpm["name"] == "pungi"]
|
|
|
|
extra_builds = [
|
|
|
|
build for build in self.tagged_rpms[1] if build["package_name"] == "pungi"
|
|
|
|
]
|
2018-09-14 08:59:53 +00:00
|
|
|
self.koji_wrapper.retrying_multicall_map.side_effect = [
|
2020-01-22 10:02:22 +00:00
|
|
|
extra_builds,
|
|
|
|
[extra_rpms],
|
|
|
|
]
|
2018-09-14 08:59:53 +00:00
|
|
|
|
|
|
|
# Do not return "pungi" RPMs and builds using the listTaggedRPMs, so
|
|
|
|
# we can be sure "pungi" gets into compose using the `extra_builds`.
|
|
|
|
self.koji_wrapper.koji_proxy.listTaggedRPMS.return_value = [
|
|
|
|
[rpm for rpm in self.tagged_rpms[0] if rpm["name"] != "pungi"],
|
2020-01-22 10:02:22 +00:00
|
|
|
[b for b in self.tagged_rpms[1] if b["package_name"] != "pungi"],
|
|
|
|
]
|
2018-09-14 08:59:53 +00:00
|
|
|
|
|
|
|
pkgset = pkgsets.KojiPackageSet(
|
2019-07-25 13:35:02 +00:00
|
|
|
"pkgset", self.koji_wrapper, [None], extra_builds=["pungi-4.1.3-3.fc25"]
|
|
|
|
)
|
2018-09-14 08:59:53 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
result = pkgset.populate("f25")
|
2018-09-14 08:59:53 +00:00
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
self.koji_wrapper.koji_proxy.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[mock.call.listTaggedRPMS("f25", event=None, inherit=True, latest=True)],
|
|
|
|
)
|
2018-09-14 08:59:53 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
result,
|
|
|
|
{
|
|
|
|
"src": ["rpms/pungi@4.1.3@3.fc25@src", "rpms/bash@4.3.42@4.fc24@src"],
|
|
|
|
"noarch": ["rpms/pungi@4.1.3@3.fc25@noarch"],
|
|
|
|
"i686": [
|
|
|
|
"rpms/bash@4.3.42@4.fc24@i686",
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@i686",
|
|
|
|
],
|
|
|
|
"x86_64": [
|
|
|
|
"rpms/bash@4.3.42@4.fc24@x86_64",
|
|
|
|
"rpms/bash-debuginfo@4.3.42@4.fc24@x86_64",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
)
|
2018-09-14 08:59:53 +00:00
|
|
|
|
|
|
|
|
2020-02-25 03:02:39 +00:00
|
|
|
class TestReuseKojiPkgset(helpers.PungiTestCase):
|
|
|
|
def setUp(self):
|
|
|
|
super(TestReuseKojiPkgset, self).setUp()
|
|
|
|
self.old_compose_dir = tempfile.mkdtemp()
|
|
|
|
self.old_compose = helpers.DummyCompose(self.old_compose_dir, {})
|
|
|
|
self.compose = helpers.DummyCompose(
|
|
|
|
self.topdir, {"old_composes": os.path.dirname(self.old_compose_dir)}
|
|
|
|
)
|
|
|
|
|
|
|
|
self.koji_wrapper = mock.Mock()
|
|
|
|
|
|
|
|
self.tag = "test-tag"
|
|
|
|
self.inherited_tag = "inherited-test-tag"
|
|
|
|
self.pkgset = pkgsets.KojiPackageSet(
|
|
|
|
self.tag, self.koji_wrapper, [None], arches=["x86_64"]
|
|
|
|
)
|
|
|
|
self.pkgset.log_debug = mock.Mock()
|
|
|
|
self.pkgset.log_info = mock.Mock()
|
|
|
|
|
|
|
|
def assert_not_reuse(self):
|
|
|
|
self.assertIsNone(getattr(self.pkgset, "reuse", None))
|
|
|
|
|
|
|
|
def test_resue_no_old_compose_found(self):
|
|
|
|
self.pkgset.try_to_reuse(self.compose, self.tag)
|
|
|
|
self.pkgset.log_info.assert_called_once_with(
|
|
|
|
"Trying to reuse pkgset data of old compose"
|
|
|
|
)
|
|
|
|
self.pkgset.log_debug.assert_called_once_with(
|
|
|
|
"No old compose found. Nothing to reuse."
|
|
|
|
)
|
|
|
|
self.assert_not_reuse()
|
|
|
|
|
|
|
|
@mock.patch.object(helpers.paths.Paths, "get_old_compose_topdir")
|
|
|
|
def test_reuse_read_koji_event_file_failed(self, mock_old_topdir):
|
|
|
|
mock_old_topdir.return_value = self.old_compose_dir
|
|
|
|
self.pkgset._get_koji_event_from_file = mock.Mock(
|
|
|
|
side_effect=Exception("unknown error")
|
|
|
|
)
|
|
|
|
self.pkgset.try_to_reuse(self.compose, self.tag)
|
|
|
|
self.pkgset.log_debug.assert_called_once_with(
|
|
|
|
"Can't read koji event from file: unknown error"
|
|
|
|
)
|
|
|
|
self.assert_not_reuse()
|
|
|
|
|
|
|
|
@mock.patch.object(helpers.paths.Paths, "get_old_compose_topdir")
|
|
|
|
def test_reuse_build_under_tag_changed(self, mock_old_topdir):
|
|
|
|
mock_old_topdir.return_value = self.old_compose_dir
|
|
|
|
self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1])
|
|
|
|
self.koji_wrapper.koji_proxy.queryHistory.return_value = {"tag_listing": [{}]}
|
|
|
|
|
|
|
|
self.pkgset.try_to_reuse(self.compose, self.tag)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
self.pkgset.log_debug.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"Koji event doesn't match, querying changes between event 1 and 3"
|
|
|
|
),
|
|
|
|
mock.call("Builds under tag %s changed. Can't reuse." % self.tag),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assert_not_reuse()
|
|
|
|
|
|
|
|
@mock.patch.object(helpers.paths.Paths, "get_old_compose_topdir")
|
|
|
|
def test_reuse_build_under_inherited_tag_changed(self, mock_old_topdir):
|
|
|
|
mock_old_topdir.return_value = self.old_compose_dir
|
|
|
|
self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1])
|
|
|
|
self.koji_wrapper.koji_proxy.queryHistory.side_effect = [
|
|
|
|
{"tag_listing": []},
|
|
|
|
{"tag_listing": [{}]},
|
|
|
|
]
|
|
|
|
self.koji_wrapper.koji_proxy.getFullInheritance.return_value = [
|
|
|
|
{"name": self.inherited_tag}
|
|
|
|
]
|
|
|
|
|
|
|
|
self.pkgset.try_to_reuse(self.compose, self.tag)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
self.pkgset.log_debug.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"Koji event doesn't match, querying changes between event 1 and 3"
|
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Builds under inherited tag %s changed. Can't reuse."
|
|
|
|
% self.inherited_tag
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assert_not_reuse()
|
|
|
|
|
|
|
|
@mock.patch("pungi.paths.os.path.exists", return_value=True)
|
|
|
|
@mock.patch.object(helpers.paths.Paths, "get_old_compose_topdir")
|
|
|
|
def test_reuse_failed_load_reuse_file(self, mock_old_topdir, mock_exists):
|
|
|
|
mock_old_topdir.return_value = self.old_compose_dir
|
|
|
|
self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1])
|
|
|
|
self.koji_wrapper.koji_proxy.queryHistory.return_value = {"tag_listing": []}
|
|
|
|
self.koji_wrapper.koji_proxy.getFullInheritance.return_value = []
|
|
|
|
self.pkgset.load_old_file_cache = mock.Mock(
|
|
|
|
side_effect=Exception("unknown error")
|
|
|
|
)
|
|
|
|
|
|
|
|
self.pkgset.try_to_reuse(self.compose, self.tag)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
self.pkgset.log_debug.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"Koji event doesn't match, querying changes between event 1 and 3"
|
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Loading reuse file: %s"
|
|
|
|
% os.path.join(
|
|
|
|
self.old_compose_dir,
|
|
|
|
"work/global",
|
|
|
|
"pkgset_%s_reuse.pickle" % self.tag,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
mock.call("Failed to load reuse file: unknown error"),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assert_not_reuse()
|
|
|
|
|
|
|
|
@mock.patch("pungi.paths.os.path.exists", return_value=True)
|
|
|
|
@mock.patch.object(helpers.paths.Paths, "get_old_compose_topdir")
|
|
|
|
def test_reuse_criteria_not_match(self, mock_old_topdir, mock_exists):
|
|
|
|
mock_old_topdir.return_value = self.old_compose_dir
|
|
|
|
self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1])
|
|
|
|
self.koji_wrapper.koji_proxy.queryHistory.return_value = {"tag_listing": []}
|
|
|
|
self.koji_wrapper.koji_proxy.getFullInheritance.return_value = []
|
|
|
|
self.pkgset.load_old_file_cache = mock.Mock(
|
|
|
|
return_value={"allow_invalid_sigkeys": True}
|
|
|
|
)
|
|
|
|
|
|
|
|
self.pkgset.try_to_reuse(self.compose, self.tag)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
self.pkgset.log_debug.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"Koji event doesn't match, querying changes between event 1 and 3"
|
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Loading reuse file: %s"
|
|
|
|
% os.path.join(
|
|
|
|
self.old_compose_dir,
|
|
|
|
"work/global",
|
|
|
|
"pkgset_%s_reuse.pickle" % self.tag,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
self.pkgset.log_info.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call("Trying to reuse pkgset data of old compose"),
|
|
|
|
mock.call("Criteria does not match. Nothing to reuse."),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assert_not_reuse()
|
|
|
|
|
|
|
|
@mock.patch("pungi.phases.pkgset.pkgsets.copy_all")
|
|
|
|
@mock.patch("pungi.paths.os.path.exists", return_value=True)
|
|
|
|
@mock.patch.object(helpers.paths.Paths, "get_old_compose_topdir")
|
|
|
|
def test_reuse_pkgset(self, mock_old_topdir, mock_exists, mock_copy_all):
|
|
|
|
mock_old_topdir.return_value = self.old_compose_dir
|
|
|
|
self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1])
|
|
|
|
self.koji_wrapper.koji_proxy.queryHistory.return_value = {"tag_listing": []}
|
|
|
|
self.koji_wrapper.koji_proxy.getFullInheritance.return_value = []
|
|
|
|
self.pkgset.load_old_file_cache = mock.Mock(
|
|
|
|
return_value={
|
|
|
|
"allow_invalid_sigkeys": self.pkgset._allow_invalid_sigkeys,
|
|
|
|
"packages": self.pkgset.packages,
|
|
|
|
"populate_only_packages": self.pkgset.populate_only_packages,
|
|
|
|
"extra_builds": self.pkgset.extra_builds,
|
|
|
|
"sigkeys": self.pkgset.sigkey_ordering,
|
|
|
|
"include_packages": None,
|
|
|
|
"rpms_by_arch": mock.Mock(),
|
|
|
|
"srpms_by_name": mock.Mock(),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
self.pkgset.old_file_cache = mock.Mock()
|
|
|
|
|
|
|
|
self.pkgset.try_to_reuse(self.compose, self.tag)
|
|
|
|
|
|
|
|
old_repo_dir = os.path.join(self.old_compose_dir, "work/global/repo", self.tag)
|
|
|
|
self.assertEqual(
|
|
|
|
self.pkgset.log_info.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call("Trying to reuse pkgset data of old compose"),
|
|
|
|
mock.call("Copying repo data for reuse: %s" % old_repo_dir),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(old_repo_dir, self.pkgset.reuse)
|
|
|
|
self.assertEqual(self.pkgset.file_cache, self.pkgset.old_file_cache)
|
|
|
|
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("kobo.pkgset.FileCache", new=MockFileCache)
|
2016-04-22 12:05:38 +00:00
|
|
|
class TestMergePackageSets(PkgsetCompareMixin, unittest.TestCase):
|
|
|
|
def test_merge_in_another_arch(self):
|
2019-07-25 13:35:02 +00:00
|
|
|
first = pkgsets.PackageSetBase("first", [None])
|
|
|
|
second = pkgsets.PackageSetBase("second", [None])
|
2016-04-22 12:05:38 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
for name in ["rpms/pungi@4.1.3@3.fc25@noarch", "rpms/pungi@4.1.3@3.fc25@src"]:
|
2016-04-22 12:05:38 +00:00
|
|
|
pkg = first.file_cache.add(name)
|
|
|
|
first.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
for name in ["rpms/bash@4.3.42@4.fc24@i686"]:
|
2016-04-22 12:05:38 +00:00
|
|
|
pkg = second.file_cache.add(name)
|
|
|
|
second.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
first.merge(second, "i386", ["i686"])
|
2016-04-22 12:05:38 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
first.rpms_by_arch,
|
|
|
|
{
|
|
|
|
"src": ["rpms/pungi@4.1.3@3.fc25@src"],
|
|
|
|
"noarch": ["rpms/pungi@4.1.3@3.fc25@noarch"],
|
|
|
|
"i686": ["rpms/bash@4.3.42@4.fc24@i686"],
|
|
|
|
},
|
|
|
|
)
|
2016-04-22 12:05:38 +00:00
|
|
|
|
|
|
|
def test_merge_includes_noarch_with_different_exclude_arch(self):
|
2019-07-25 13:35:02 +00:00
|
|
|
first = pkgsets.PackageSetBase("first", [None])
|
|
|
|
second = pkgsets.PackageSetBase("second", [None])
|
2016-04-22 12:05:38 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
pkg = first.file_cache.add("rpms/bash@4.3.42@4.fc24@i686")
|
2016-04-22 12:05:38 +00:00
|
|
|
first.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
pkg = second.file_cache.add("rpms/pungi@4.1.3@3.fc25@noarch")
|
|
|
|
pkg.excludearch = ["x86_64"]
|
2016-04-22 12:05:38 +00:00
|
|
|
second.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
first.merge(second, "i386", ["i686", "noarch"])
|
2016-04-22 12:05:38 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
first.rpms_by_arch,
|
|
|
|
{
|
|
|
|
"i686": ["rpms/bash@4.3.42@4.fc24@i686"],
|
|
|
|
"noarch": ["rpms/pungi@4.1.3@3.fc25@noarch"],
|
|
|
|
},
|
|
|
|
)
|
2016-04-22 12:05:38 +00:00
|
|
|
|
|
|
|
def test_merge_excludes_noarch_exclude_arch(self):
|
2019-07-25 13:35:02 +00:00
|
|
|
first = pkgsets.PackageSetBase("first", [None])
|
|
|
|
second = pkgsets.PackageSetBase("second", [None])
|
2016-04-22 12:05:38 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
pkg = first.file_cache.add("rpms/bash@4.3.42@4.fc24@i686")
|
2016-04-22 12:05:38 +00:00
|
|
|
first.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
pkg = second.file_cache.add("rpms/pungi@4.1.3@3.fc25@noarch")
|
|
|
|
pkg.excludearch = ["i686"]
|
2016-04-22 12:05:38 +00:00
|
|
|
second.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
first.merge(second, "i386", ["i686", "noarch"])
|
2016-04-22 12:05:38 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
first.rpms_by_arch, {"i686": ["rpms/bash@4.3.42@4.fc24@i686"], "noarch": []}
|
|
|
|
)
|
2016-04-22 12:05:38 +00:00
|
|
|
|
|
|
|
def test_merge_excludes_noarch_exclusive_arch(self):
|
2019-07-25 13:35:02 +00:00
|
|
|
first = pkgsets.PackageSetBase("first", [None])
|
|
|
|
second = pkgsets.PackageSetBase("second", [None])
|
2016-04-22 12:05:38 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
pkg = first.file_cache.add("rpms/bash@4.3.42@4.fc24@i686")
|
2016-04-22 12:05:38 +00:00
|
|
|
first.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
pkg = second.file_cache.add("rpms/pungi@4.1.3@3.fc25@noarch")
|
|
|
|
pkg.exclusivearch = ["x86_64"]
|
2016-04-22 12:05:38 +00:00
|
|
|
second.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
first.merge(second, "i386", ["i686", "noarch"])
|
2016-04-22 12:05:38 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
first.rpms_by_arch, {"i686": ["rpms/bash@4.3.42@4.fc24@i686"], "noarch": []}
|
|
|
|
)
|
2016-04-22 12:05:38 +00:00
|
|
|
|
|
|
|
def test_merge_includes_noarch_with_same_exclusive_arch(self):
|
2019-07-25 13:35:02 +00:00
|
|
|
first = pkgsets.PackageSetBase("first", [None])
|
|
|
|
second = pkgsets.PackageSetBase("second", [None])
|
2016-04-22 12:05:38 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
pkg = first.file_cache.add("rpms/bash@4.3.42@4.fc24@i686")
|
2016-04-22 12:05:38 +00:00
|
|
|
first.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
pkg = second.file_cache.add("rpms/pungi@4.1.3@3.fc25@noarch")
|
|
|
|
pkg.exclusivearch = ["i686"]
|
2016-04-22 12:05:38 +00:00
|
|
|
second.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
first.merge(second, "i386", ["i686", "noarch"])
|
2016-04-22 12:05:38 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
first.rpms_by_arch,
|
|
|
|
{
|
|
|
|
"i686": ["rpms/bash@4.3.42@4.fc24@i686"],
|
|
|
|
"noarch": ["rpms/pungi@4.1.3@3.fc25@noarch"],
|
|
|
|
},
|
|
|
|
)
|
2016-04-22 12:05:38 +00:00
|
|
|
|
|
|
|
def test_merge_skips_package_in_cache(self):
|
2019-07-25 13:35:02 +00:00
|
|
|
first = pkgsets.PackageSetBase("first", [None])
|
|
|
|
second = pkgsets.PackageSetBase("second", [None])
|
2016-04-22 12:05:38 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
pkg = first.file_cache.add("rpms/bash@4.3.42@4.fc24@i686")
|
2016-04-22 12:05:38 +00:00
|
|
|
first.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
pkg = second.file_cache.add("rpms/bash@4.3.42@4.fc24@i686")
|
2016-04-22 12:05:38 +00:00
|
|
|
second.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
first.merge(second, "i386", ["i686"])
|
2016-04-22 12:05:38 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
first.rpms_by_arch, {"i686": ["rpms/bash@4.3.42@4.fc24@i686"]}
|
|
|
|
)
|
2016-04-22 12:05:38 +00:00
|
|
|
|
|
|
|
def test_merge_skips_src_without_binary(self):
|
2019-07-25 13:35:02 +00:00
|
|
|
first = pkgsets.PackageSetBase("first", [None])
|
|
|
|
second = pkgsets.PackageSetBase("second", [None])
|
2016-04-22 12:05:38 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
pkg = first.file_cache.add("rpms/bash@4.3.42@4.fc24@i686")
|
2016-04-22 12:05:38 +00:00
|
|
|
first.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
pkg = second.file_cache.add("rpms/pungi@4.1.3@3.fc25@src")
|
2016-04-22 12:05:38 +00:00
|
|
|
second.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
first.merge(second, "i386", ["i686", "src"])
|
2016-04-22 12:05:38 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertPkgsetEqual(
|
|
|
|
first.rpms_by_arch,
|
|
|
|
{"i686": ["rpms/bash@4.3.42@4.fc24@i686"], "src": [], "nosrc": []},
|
|
|
|
)
|
2016-04-22 12:05:38 +00:00
|
|
|
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("kobo.pkgset.FileCache", new=MockFileCache)
|
2016-04-26 12:55:46 +00:00
|
|
|
class TestSaveFileList(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
fd, self.tmpfile = tempfile.mkstemp()
|
|
|
|
os.close(fd)
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
os.unlink(self.tmpfile)
|
|
|
|
|
|
|
|
def test_save_arches_alphabetically(self):
|
2019-07-25 13:35:02 +00:00
|
|
|
pkgset = pkgsets.PackageSetBase("pkgset", [None])
|
2020-01-22 10:02:22 +00:00
|
|
|
for name in [
|
|
|
|
"rpms/pungi@4.1.3@3.fc25@x86_64",
|
|
|
|
"rpms/pungi@4.1.3@3.fc25@src",
|
|
|
|
"rpms/pungi@4.1.3@3.fc25@ppc64",
|
|
|
|
]:
|
2016-04-26 12:55:46 +00:00
|
|
|
pkg = pkgset.file_cache.add(name)
|
|
|
|
pkgset.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
|
|
|
pkgset.save_file_list(self.tmpfile)
|
|
|
|
|
|
|
|
with open(self.tmpfile) as f:
|
2020-01-22 10:02:22 +00:00
|
|
|
rpms = f.read().strip().split("\n")
|
|
|
|
self.assertEqual(
|
|
|
|
rpms,
|
|
|
|
[
|
|
|
|
"rpms/pungi@4.1.3@3.fc25@ppc64",
|
|
|
|
"rpms/pungi@4.1.3@3.fc25@src",
|
|
|
|
"rpms/pungi@4.1.3@3.fc25@x86_64",
|
|
|
|
],
|
|
|
|
)
|
2016-04-26 12:55:46 +00:00
|
|
|
|
|
|
|
def test_save_strip_prefix(self):
|
2019-07-25 13:35:02 +00:00
|
|
|
pkgset = pkgsets.PackageSetBase("pkgset", [None])
|
2020-01-22 10:02:22 +00:00
|
|
|
for name in ["rpms/pungi@4.1.3@3.fc25@noarch", "rpms/pungi@4.1.3@3.fc25@src"]:
|
2016-04-26 12:55:46 +00:00
|
|
|
pkg = pkgset.file_cache.add(name)
|
|
|
|
pkgset.rpms_by_arch.setdefault(pkg.arch, []).append(pkg)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
pkgset.save_file_list(self.tmpfile, remove_path_prefix="rpms/")
|
2016-04-26 12:55:46 +00:00
|
|
|
|
|
|
|
with open(self.tmpfile) as f:
|
2020-01-22 10:02:22 +00:00
|
|
|
rpms = f.read().strip().split("\n")
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self, rpms, ["pungi@4.1.3@3.fc25@noarch", "pungi@4.1.3@3.fc25@src"]
|
|
|
|
)
|