Improve logging for unsigned packages

Relates: https://pagure.io/pungi/issue/820

Signed-off-by: Ondrej Nosek <onosek@redhat.com>
This commit is contained in:
Ondrej Nosek 2018-01-02 21:06:08 +01:00
parent 2152e7ea26
commit d4d264eb33
2 changed files with 9 additions and 4 deletions

View File

@ -124,10 +124,13 @@ class PackageSetBase(kobo.log.LoggingBase):
self.log_debug("Package set: worker threads stopped (RPMs)") self.log_debug("Package set: worker threads stopped (RPMs)")
if self._invalid_sigkey_rpms: if self._invalid_sigkey_rpms:
def nvr_formatter(package_info):
# joins NVR parts of the package with '-' character.
return '-'.join((package_info['name'], package_info['version'], package_info['release']))
raise RuntimeError( raise RuntimeError(
"RPM(s) not found for sigs: %s. Check log for details. Unsigned packages:\n%s" % ( "RPM(s) not found for sigs: %s. Check log for details. Unsigned packages:\n%s" % (
self.sigkey_ordering, self.sigkey_ordering,
'\n'.join([rpminfo['name'] for rpminfo in self._invalid_sigkey_rpms]))) '\n'.join(sorted(set([nvr_formatter(rpminfo) for rpminfo in self._invalid_sigkey_rpms])))))
return self.rpms_by_arch return self.rpms_by_arch

View File

@ -10,6 +10,7 @@ except ImportError:
import unittest import unittest
import json import json
import tempfile import tempfile
import re
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
@ -259,9 +260,10 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
self.koji_wrapper.koji_proxy.mock_calls, self.koji_wrapper.koji_proxy.mock_calls,
[mock.call.listTaggedRPMS('f25', event=None, inherit=True, latest=True)]) [mock.call.listTaggedRPMS('f25', event=None, inherit=True, latest=True)])
self.assertRegexpMatches( figure = re.compile(
str(ctx.exception), r'^RPM\(s\) not found for sigs: .+Check log for details.+bash-4\.3\.42-4\.fc24.+bash-debuginfo-4\.3\.42-4\.fc24$',
r'^RPM\(s\) not found for sigs: .+Check log for details.+') re.DOTALL)
self.assertRegexpMatches(str(ctx.exception), figure)
def test_can_not_find_any_package(self): def test_can_not_find_any_package(self):
pkgset = pkgsets.KojiPackageSet(self.koji_wrapper, ['cafebabe', None], arches=['x86_64']) pkgset = pkgsets.KojiPackageSet(self.koji_wrapper, ['cafebabe', None], arches=['x86_64'])