From 2631b5c3242bc22936d448a89e590f1f2e0e55fc Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Sep 19 2019 19:18:36 +0000 Subject: Add support for filing bugs on oversize images We added this feature to relval, now let's make the consumer able to use it (optionally). Also extend the tests a bit so they really test the test consumer. Signed-off-by: Adam Williamson --- diff --git a/relvalconsumer.py b/relvalconsumer.py index 8ba9d49..732ba2c 100644 --- a/relvalconsumer.py +++ b/relvalconsumer.py @@ -43,6 +43,7 @@ class RelvalConsumer(object): """ def __init__(self): self.relval_prod = fedora_messaging.config.conf["consumer_config"]["relval_prod"] + self.relval_bugzilla = fedora_messaging.config.conf["consumer_config"]["relval_bugzilla"] self.logger = logging.getLogger(self.__class__.__name__) def __call__(self, message): @@ -216,7 +217,13 @@ class RelvalConsumer(object): return # Run the image size check (this is as good a place as any) - args = ('relval', 'size-check', '--cid', cid) + args = ['relval', 'size-check', '--cid', cid] + if self.relval_bugzilla: + # submit bug reports for oversize images + args.append('--bugzilla') + if not self.relval_prod: + # edit stg wiki, submit bugs to partner-bugzilla + args.append('--test') try: ret = subprocess.call(args) if ret > 0: diff --git a/relvalconsumer.toml b/relvalconsumer.toml index e84993f..68a57d3 100644 --- a/relvalconsumer.toml +++ b/relvalconsumer.toml @@ -51,6 +51,11 @@ routing_keys = ["org.fedoraproject.prod.pungi.compose.status.change"] # production instance anywhere in the world at any one time; unless # you are very sure you are maintaining it, leave this at false. relval_prod = false +# Whether to file bugs for oversize images. If relval_prod is true, +# the bugs will be filed in production Bugzilla; if it's false, they +# will be filed in partner-bugzilla. Leave this false unless you're +# really sure you want to do this. +relval_bugzilla = false [qos] prefetch_size = 0 diff --git a/test_relvalconsumer.py b/test_relvalconsumer.py index 8fcce5d..6d49af9 100644 --- a/test_relvalconsumer.py +++ b/test_relvalconsumer.py @@ -107,11 +107,13 @@ mock.patch('mwclient.client.Site.site_init', autospec=True).start() PRODCONF = { 'consumer_config': { 'relval_prod': True, + 'relval_bugzilla': True, } } TESTCONF = { 'consumer_config': { - 'relval_prod': True, + 'relval_prod': False, + 'relval_bugzilla': False, } } @@ -188,7 +190,7 @@ class TestRelvalConsumerPreBranch: assert fakecreate.call_args[1]['check'] is True # check size-check got run assert fakesubproc.call_count == 1 - assert fakesubproc.call_args[0][0] == ('relval', 'size-check', '--cid', 'Fedora-Rawhide-20160601.n.0') + assert fakesubproc.call_args[0][0] == ['relval', 'size-check', '--cid', 'Fedora-Rawhide-20160601.n.0', '--bugzilla'] fakesubproc.reset_mock() @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetdifferent) @@ -441,3 +443,20 @@ class TestRelvalConsumerPostBranch: with pytest.raises(fedora_messaging.exceptions.Drop): # FIXME: check log messages CONSUMER(_fakemsg('PLAYGROUND-8-20190730.n.0')) + + @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetdifferent) + @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.NightlyEvent(None, '25', 'Rawhide', '20160620.n.0')) + def test_testconsumer(self, fakesmtp, fakecreate, fakesubproc): + """Creating second Branched nightly again with test consumer, + to make sure that works. + """ + TESTCONSUMER(_fakemsg(BRANCHED2)) + assert fakecreate.call_args[1]['check'] is True + # check size-check got run + assert fakesubproc.call_count == 1 + assert fakesubproc.call_args[0][0] == ['relval', 'size-check', '--cid', 'Fedora-25-20160629.n.0', '--test'] + # check we didn't send a mail + assert fakesmtp.call_count == 0 + # FIXME we should check we used stg wiki, but it's a bit tricky + # with these mocks + fakesubproc.reset_mock()