Skip to content

Commit

Permalink
Merge edc382b into a9c585d
Browse files Browse the repository at this point in the history
  • Loading branch information
rbikar committed Sep 7, 2021
2 parents a9c585d + edc382b commit 5cb5190
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 7 deletions.
75 changes: 75 additions & 0 deletions tests/test_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,81 @@ def test_get_rpm_output_set(ubi_config):
assert output[0].version == "11"


def test_get_rpm_output_set_include_modular_and_all_versions(ubi_config):
"""tests getting rpm output set from RpmMatcher, modular packages included as well as all version of given package, only blacklist is applied"""
matcher = RpmMatcher(None, ubi_config)
# This unit will be in the output set - we allow all versions
unit_1 = UbiUnit(
RpmUnit(
name="test",
version="10",
release="20",
arch="x86_64",
),
None,
)
# this one will be excluded using blacklist
unit_2 = UbiUnit(
RpmUnit(
name="excluded_with_globbing123456789",
version="11",
release="20",
arch="x86_64",
),
None,
)
# this one will be excluded using blacklist
unit_3 = UbiUnit(
RpmUnit(
name="excluded_package",
version="10",
release="20",
arch="x86_64",
),
None,
)
# this is another unit that that will in the output set
unit_4 = UbiUnit(
RpmUnit(
name="test",
version="11",
release="20",
arch="x86_64",
),
None,
)
# this one is inluded, we don't exclude modular packages this time
unit_5 = UbiUnit(
RpmUnit(
name="modular_package",
version="10",
release="20",
arch="x86_64",
filename="modular_package.rpm",
),
None,
)

rpms = [unit_1, unit_2, unit_3, unit_4, unit_5]
output = matcher._get_rpm_output_set(
rpms, modular_rpm_filenames=None, keep_all_versions=True
)

# in the output set there aer three units
assert len(output) == 3
# let's sort the output there might, order in not guranteed
output.sort(key=lambda x: x.version)

assert output[0].name == "test"
assert output[0].version == "10"

assert output[1].name == "modular_package"
assert output[1].version == "10"

assert output[2].name == "test"
assert output[2].version == "11"


def test_get_pkgs_from_all_modules(pulp):
"""tests getting pkgs filenames from all available modulemd units"""
repo = YumRepository(
Expand Down
24 changes: 17 additions & 7 deletions ubipop/_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,15 @@ def run(self):
)
)

# the output set of source rpms is almost ready at this point
# because it was created from final output set of binary and debug rpm
# so just need to apply blacklist and nothing else
self.source_rpms = f_proxy(
self._executor.submit(
self._get_rpm_output_set, source_rpms, modular_rpm_filenames
self._get_rpm_output_set,
source_rpms,
modular_rpm_filenames=None,
keep_all_versions=True,
)
)

Expand Down Expand Up @@ -393,7 +399,9 @@ def extract_modular_filenames():
modules = self._search_moludemds([Criteria.true()], self._input_repos.rpm)
return self._executor.submit(extract_modular_filenames)

def _get_rpm_output_set(self, rpms, modular_rpm_filenames):
def _get_rpm_output_set(
self, rpms, modular_rpm_filenames=None, keep_all_versions=False
):
blacklist_parsed = self._parse_blacklist_config()
name_rpms_maps = {}

Expand All @@ -414,9 +422,10 @@ def is_blacklisted(rpm):
return blacklisted

for rpm in rpms:
# skip modular rpms
if rpm.filename in modular_rpm_filenames:
continue
if modular_rpm_filenames:
# skip modular rpms
if rpm.filename in modular_rpm_filenames:
continue
# skip blacklisted rpms
if is_blacklisted(rpm):
continue
Expand All @@ -426,8 +435,9 @@ def is_blacklisted(rpm):
out = []
# sort rpms and keep N latest versions of them
for rpm_list in name_rpms_maps.values():
rpm_list.sort(key=vercmp_sort())
self._keep_n_latest_rpms(rpm_list)
if not keep_all_versions:
rpm_list.sort(key=vercmp_sort())
self._keep_n_latest_rpms(rpm_list)
out.extend(rpm_list)

return out
Expand Down

0 comments on commit 5cb5190

Please sign in to comment.