From d42caf1c389bda92ad037abe400a44e9b16ff2e6 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Mar 12 2018 20:57:06 +0000 Subject: Handle fedfind UnsupportedComposeError (debug log, ignore) fedfind 4.x raises a specific exception for composes it knows it does not support. relvalconsumer should catch these and just ignore them. Signed-off-by: Adam Williamson --- diff --git a/relvalconsumer.py b/relvalconsumer.py index ac04e3d..6ffbb03 100644 --- a/relvalconsumer.py +++ b/relvalconsumer.py @@ -26,6 +26,7 @@ import subprocess import sys import time +import fedfind.exceptions import fedfind.helpers import fedmsg.consumers import hawkey @@ -79,6 +80,10 @@ class RelvalConsumer(fedmsg.consumers.FedmsgConsumer): # get the validation event instance try: event = site.get_validation_event(cid=cid) + except fedfind.exceptions.UnsupportedComposeError: + # this is a common, expected case, not worth logging at info + self._log('debug', "compose {0} not supported by fedfind".format(cid)) + return except ValueError: self._log('info', "Could not determine event for compose {0}".format(cid)) diff --git a/test_relvalconsumer.py b/test_relvalconsumer.py index 189a86b..47956a9 100644 --- a/test_relvalconsumer.py +++ b/test_relvalconsumer.py @@ -112,6 +112,7 @@ with mock.patch('fedmsg.consumers.FedmsgConsumer.__init__', return_value=None): # These are all fake IDs for various composes, in the order we'll test them. RAWHIDE1 = 'Fedora-Rawhide-20160601.n.0' +UPDATE1 = 'Fedora-25-updates-20180312.0' RAWHIDE2 = 'Fedora-Rawhide-20160601.n.1' RAWHIDE3 = 'Fedora-Rawhide-20160605.n.0' RAWHIDE4 = 'Fedora-Rawhide-20160620.n.0' @@ -212,6 +213,17 @@ class TestRelvalConsumerPreBranch: @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetsame) @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.NightlyEvent(None, '25', 'Rawhide', '20160605.n.0')) + def test_unsupported_compose(self, fakesmtp, fakecreate, fakesubproc): + """When we encounter a compose that fedfind doesn't support + (and raises a specific exception for), we shouldn't crash, we + should just create no event and go on our merry way.""" + CONSUMER.consume(_fakemsg(UPDATE1)) + assert fakecreate.call_count == 0 + assert fakesmtp.call_count == 0 + assert fakesubproc.call_count == 0 + + @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetsame) + @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.NightlyEvent(None, '25', 'Rawhide', '20160605.n.0')) def test_rawhide4(self, fakesmtp, fakecreate, fakesubproc): """Another Rawhide nightly 15 days later should produce an event even if the packages are the same.