From 8d174a25909204bc1321138bce58708926d76e94 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: May 15 2020 23:44:22 +0000 Subject: Adjust to wikitcms "dist" support, enable IoT event creation We changed wikitcms to handle dists (Fedora, Fedora-IoT etc.) generically, rather than only having hardcoded support for Fedora and Fedora-Modular. This adapts relvalconsumer to the changes and enables IoT event creation. Signed-off-by: Adam Williamson --- diff --git a/relvalconsumer.py b/relvalconsumer.py index bb6d6b9..877e4cd 100644 --- a/relvalconsumer.py +++ b/relvalconsumer.py @@ -103,9 +103,8 @@ class RelvalConsumer(object): self.logger.error(err) raise fedora_messaging.exceptions.Drop - # don't run on any dist but Fedora at present (modular support - # is still here in case we turn out to need it again) - if dist != 'Fedora': + # these are the only dists we want to create events for ATM + if dist not in ("Fedora", "Fedora-IoT"): return if self.relval_prod: @@ -136,25 +135,21 @@ class RelvalConsumer(object): # creating Rawhide events during Branched periods. Note we have # to handle the case of creating the *first* Rawhide nightly # after a stable release, so we cannot just require release to - # equal wiki.current_compose['release']. We skip this logic - # for Fedora-Modular for now as we're only creating 27 events. - if dist == 'Fedora': - curr = fedfind.helpers.get_current_release() - if not int(event.release) == curr+1: - self.logger.info("Compose %s is not for the next release!", cid) - return - - if dist == 'Fedora': - currev = site.current_event - else: - currev = site.current_modular_event - try: - newdate = fedfind.helpers.date_check(date, out='obj') - currdate = fedfind.helpers.date_check(currev.creation_date, out='obj') - except ValueError: - self.logger.warning("Could not determine date of current or new event!") + # equal wiki.current_compose['release'] + curr = fedfind.helpers.get_current_release() + if not int(event.release) == curr+1: + self.logger.info("Compose %s is not for the next release!", cid) return + currev = site.get_current_event(dist=dist) + if currev: + try: + newdate = fedfind.helpers.date_check(date, out='obj') + currdate = fedfind.helpers.date_check(currev.creation_date, out='obj') + except ValueError: + self.logger.warning("Could not determine date of current or new event!") + return + if typ not in ('nightly', 'production'): self.logger.warning("Unexpected compose type %s for compose %s", typ, cid) return @@ -166,7 +161,7 @@ class RelvalConsumer(object): # next release. diff = '' - if typ == 'production' and event.release == currev.release: + if typ == 'production' and currev and event.release == currev.release: # just check we're actually newer than the current event as a # sanity check ok = True @@ -182,8 +177,9 @@ class RelvalConsumer(object): return # if we're proposing a nightly event for the same release, do the - # date check / package comparison stuff - if typ == 'nightly' and event.release == currev.release: + # date check / package comparison stuff. We treat IoT composes as + # nightlies always, even though their type is production + if (typ == 'nightly' or dist == "Fedora-IoT") and currev and event.release == currev.release: delta = newdate - currdate if delta.days < 3: # we never create an event if it's been < 3 days. @@ -256,21 +252,24 @@ class RelvalConsumer(object): return # Run the image size check (this is as good a place as any) - 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: - self.logger.warning('Size check failed') - else: - self.logger.debug('Size check completed') - except OSError: - self.logger.warning('Attempt to run size check caused error - relval missing?') + # FIXME: don't do this for IoT yet, we don't have a place to + # report the results... + if dist == "Fedora": + 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: + self.logger.warning('Size check failed') + else: + self.logger.debug('Size check completed') + except OSError: + self.logger.warning('Attempt to run size check caused error - relval missing?') # send the announcement mail self.logger.debug("Sending announcement email") @@ -286,8 +285,9 @@ class RelvalConsumer(object): # this is the final part of the testcase_stats link; we want it # to be e.g. '27' for non-modular, '27modular' for modular tcstext = event.release - if dist == 'Fedora-Modular': - tcstext += "modular" + shortdist = dist[7:].lower() + if shortdist: + tcstext += shortdist nighttmpl = ("""From: rawhide@fedoraproject.org To: {0} Subject: {1} {2} nightly compose nominated for testing @@ -350,7 +350,7 @@ http://qa.fedoraproject.org/blockerbugs/current [4] irc://irc.freenode.net/fedora-qa [5] https://lists.fedoraproject.org/archives/list/test@lists.fedoraproject.org/ """) - if typ == 'nightly': + if typ == 'nightly' or dist == "Fedora-IoT": msg = nighttmpl.format( dest, dist, event.version, difftext, tcstext, summurl, '\n'.join(pageurls)) else: diff --git a/test_relvalconsumer.py b/test_relvalconsumer.py index 1fe2ce0..cc2518b 100644 --- a/test_relvalconsumer.py +++ b/test_relvalconsumer.py @@ -90,14 +90,22 @@ def _fakegetcurr2(branched=False): else: return 24 +def _fakegettesttypes(self, dist="Fedora"): + """A faked get_testtypes with the Right Answers hardcoded.""" + if dist == "Fedora": + return ["Installation", "Desktop", "Server", "Cloud", "Base"] + if dist == "Fedora-Modular": + return ["Installation", "Server", "Base"] + if dist == "Fedora-IoT": + return ["General"] + # a bunch of patches we need throughout the tests # ALL SLEEPS MUST DIE mock.patch('time.sleep', autospec=True).start() # page init requires wiki trip mock.patch('mwclient.page.Page.__init__', _fakepginit).start() # testtypes are read from wiki -mock.patch('wikitcms.wiki.Wiki.testtypes', ['Installation', 'Desktop', 'Server', 'Cloud', 'Base']).start() -mock.patch('wikitcms.wiki.Wiki.modular_testtypes', ['Installation', 'Server', 'Base']).start() +mock.patch('wikitcms.wiki.Wiki.get_testtypes', _fakegettesttypes).start() # login hits the wiki, obviously mock.patch('wikitcms.wiki.Wiki.login', autospec=True).start() # so does site init @@ -150,6 +158,68 @@ MODBRANCHED3 = 'Fedora-Modular-27-20171106.n.0' MODBETA1 = 'Fedora-Modular-27-20171108.2' MODBRANCHED4 = 'Fedora-Modular-27-20171125.n.0' MODFINAL1 = 'Fedora-Modular-27-20171126.1' +IOT1 = "Fedora-IoT-25-20160621.0" +IOT2 = "Fedora-IoT-25-20160625.0" +IOT3 = "Fedora-IoT-25-20160714.0" + +# expected email texts +RAWHIDE1MAIL = """From: rawhide@fedoraproject.org +To: test-announce@lists.fedoraproject.org +Subject: Fedora 25 Rawhide 20160601.n.0 nightly compose nominated for testing + +Announcing the creation of a new nightly release validation test event +for Fedora 25 Rawhide 20160601.n.0. Please help run some tests for this +nightly compose if you have time. For more information on nightly +release validation testing, see: +https://fedoraproject.org/wiki/QA:Release_validation_test_plan + +Test coverage information for the current release can be seen at: +https://www.happyassassin.net/testcase_stats/25 + +You can see all results, find testing instructions and image download +locations, and enter results on the Summary page: + +https://fedoraproject.org/wiki/Test_Results:Fedora_25_Rawhide_20160601.n.0_Summary + +The individual test result pages are: + +https://fedoraproject.org/wiki/Test_Results:Fedora_25_Rawhide_20160601.n.0_Installation +https://fedoraproject.org/wiki/Test_Results:Fedora_25_Rawhide_20160601.n.0_Desktop +https://fedoraproject.org/wiki/Test_Results:Fedora_25_Rawhide_20160601.n.0_Server +https://fedoraproject.org/wiki/Test_Results:Fedora_25_Rawhide_20160601.n.0_Cloud +https://fedoraproject.org/wiki/Test_Results:Fedora_25_Rawhide_20160601.n.0_Base + +Thank you for testing! +-- +Mail generated by relvalconsumer: https://pagure.io/fedora-qa/relvalconsumer +""" + +IOT1MAIL = """From: rawhide@fedoraproject.org +To: test-announce@lists.fedoraproject.org +Subject: Fedora-IoT 25 RC 20160621.0 nightly compose nominated for testing + +Announcing the creation of a new nightly release validation test event +for Fedora-IoT 25 RC 20160621.0. Please help run some tests for this +nightly compose if you have time. For more information on nightly +release validation testing, see: +https://fedoraproject.org/wiki/QA:Release_validation_test_plan + +Test coverage information for the current release can be seen at: +https://www.happyassassin.net/testcase_stats/25iot + +You can see all results, find testing instructions and image download +locations, and enter results on the Summary page: + +https://fedoraproject.org/wiki/Test_Results:Fedora-IoT_25_RC_20160621.0_Summary + +The individual test result pages are: + +https://fedoraproject.org/wiki/Test_Results:Fedora-IoT_25_RC_20160621.0_General + +Thank you for testing! +-- +Mail generated by relvalconsumer: https://pagure.io/fedora-qa/relvalconsumer +""" # we don't really want to run size_check @@ -174,8 +244,8 @@ class TestRelvalConsumerPreBranch: @mock.patch('wikitcms.event.ComposeEvent.creation_date', '20160530') # this always needs mocking, as whatever the 'current' event ought # to be in our fake release series. - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.ComposeEvent(None, '24', 'Final', '1.4')) - def test_rawhide1_doomed(self, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.ComposeEvent(None, '24', 'Final', '1.4')) + def test_rawhide1_doomed(self, fakecurrev, fakesmtp, fakecreate, fakesubproc): """We would otherwise create an event for this message - that's the next test - but if the status is DOOMED, we should not. @@ -187,19 +257,23 @@ class TestRelvalConsumerPreBranch: @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetsame) @mock.patch('wikitcms.event.ComposeEvent.creation_date', '20160530') - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.ComposeEvent(None, '24', 'Final', '1.4')) - def test_rawhide1(self, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.ComposeEvent(None, '24', 'Final', '1.4')) + def test_rawhide1(self, fakecurrev, fakesmtp, fakecreate, fakesubproc): """Creating first Rawhide nightly for next release.""" CONSUMER(_fakemsg(RAWHIDE1)) 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', '--bugzilla'] + smtp = fakesmtp.return_value + assert smtp.sendmail.call_args[0][0] == "rawhide@fedoraproject.org" + assert smtp.sendmail.call_args[0][1] == ["test-announce@lists.fedoraproject.org"] + assert smtp.sendmail.call_args[0][2] == RAWHIDE1MAIL fakesubproc.reset_mock() @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetdifferent) - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.NightlyEvent(None, '25', 'Rawhide', '20160601.n.0')) - def test_rawhide2(self, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, '25', 'Rawhide', '20160601.n.0')) + def test_rawhide2(self, fakecurrev, fakesmtp, fakecreate, fakesubproc): """Another Rawhide nightly one day later should not produce an event, even if there are package differences. """ @@ -209,8 +283,8 @@ class TestRelvalConsumerPreBranch: 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', '20160601.n.0')) - def test_rawhide3_same(self, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, '25', 'Rawhide', '20160601.n.0')) + def test_rawhide3_same(self, fakecurrev, fakesmtp, fakecreate, fakesubproc): """Another Rawhide nightly four days later should not produce an event if the packages are the same... """ @@ -219,8 +293,8 @@ class TestRelvalConsumerPreBranch: assert fakesmtp.call_count == 0 @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetdifferent) - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.NightlyEvent(None, '25', 'Rawhide', '20160601.n.0')) - def test_rawhide3_different(self, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, '25', 'Rawhide', '20160601.n.0')) + def test_rawhide3_different(self, fakecurrev, fakesmtp, fakecreate, fakesubproc): """...but the same four days later nightly should produce an event if the packages are different. """ @@ -228,8 +302,8 @@ class TestRelvalConsumerPreBranch: assert fakecreate.call_args[1]['check'] is True @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): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, '25', 'Rawhide', '20160605.n.0')) + def test_unsupported_compose(self, fakecurrev, 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.""" @@ -239,8 +313,8 @@ class TestRelvalConsumerPreBranch: 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): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, '25', 'Rawhide', '20160605.n.0')) + def test_rawhide4(self, fakecurrev, fakesmtp, fakecreate, fakesubproc): """Another Rawhide nightly 15 days later should produce an event even if the packages are the same. """ @@ -258,8 +332,8 @@ class TestRelvalConsumerPostBranch: """ @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetsame) - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.NightlyEvent(None, '25', 'Rawhide', '20160620.n.0')) - def test_branched1(self, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, '25', 'Rawhide', '20160620.n.0')) + def test_branched1(self, fakecurrev, fakesmtp, fakecreate, fakesubproc): """First Branched nightly shouldn't produce an event as it's only one day after the Rawhide nightly. """ @@ -269,8 +343,8 @@ class TestRelvalConsumerPostBranch: assert fakesmtp.call_count == 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_branched2(self, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, '25', 'Rawhide', '20160620.n.0')) + def test_branched2(self, fakecurrev, fakesmtp, fakecreate, fakesubproc): """Second branched compose some days later should create an event. """ CONSUMER(_fakemsg(BRANCHED2)) @@ -285,8 +359,8 @@ class TestRelvalConsumerPostBranch: # for the CID cross-check that was added in fedfind 4 @mock.patch('fedfind.release.Production.cid', ALPHA1) @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetsame) - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.NightlyEvent(None, '25', 'Branched', '20160629.n.0')) - def test_alpha1(self, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, '25', 'Branched', '20160629.n.0')) + def test_alpha1(self, fakecurrev, fakesmtp, fakecreate, fakesubproc): """First Alpha candidate should produce an event even though it's for the same date and package set as BRANCHED2. """ @@ -301,8 +375,8 @@ class TestRelvalConsumerPostBranch: @mock.patch('fedfind.release.Production.cid', ALPHA2) @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetsame) @mock.patch('wikitcms.event.ComposeEvent.creation_date', '20160629') - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.ComposeEvent(None, '25', 'Alpha', '1.1')) - def test_alpha2(self, fakecompexists, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.ComposeEvent(None, '25', 'Alpha', '1.1')) + def test_alpha2(self, fakecurrev, fakecompexists, fakesmtp, fakecreate, fakesubproc): """Second Alpha candidate should produce an event even though it's for the same date and package set as ALPHA1 (somewhat unrealistic, but it's what ought to happen). @@ -313,8 +387,8 @@ class TestRelvalConsumerPostBranch: @mock.patch('fedfind.release.Compose.exists', return_value=True) @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetdifferent) @mock.patch('wikitcms.event.ComposeEvent.creation_date', '20160629') - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.ComposeEvent(None, '25', 'Alpha', '1.2')) - def test_branched3(self, fakecompexists, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.ComposeEvent(None, '25', 'Alpha', '1.2')) + def test_branched3(self, fakecurrev, fakecompexists, fakesmtp, fakecreate, fakesubproc): """Branched nightly shortly after candidate compose should not create event even if package set is different. """ @@ -325,8 +399,8 @@ class TestRelvalConsumerPostBranch: @mock.patch('fedfind.release.Compose.exists', return_value=True) @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetsame) @mock.patch('wikitcms.event.ComposeEvent.creation_date', '20160629') - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.ComposeEvent(None, '25', 'Alpha', '1.2')) - def test_branched4_same(self, fakecompexists, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.ComposeEvent(None, '25', 'Alpha', '1.2')) + def test_branched4_same(self, fakecurrev, fakecompexists, fakesmtp, fakecreate, fakesubproc): """Branched nightly a few days later with same package set should not create event... """ @@ -337,8 +411,8 @@ class TestRelvalConsumerPostBranch: @mock.patch('fedfind.release.Compose.exists', return_value=True) @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetolder) @mock.patch('wikitcms.event.ComposeEvent.creation_date', '20160629') - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.ComposeEvent(None, '25', 'Alpha', '1.2')) - def test_branched4_older(self, fakecompexists, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.ComposeEvent(None, '25', 'Alpha', '1.2')) + def test_branched4_older(self, fakecurrev, fakecompexists, fakesmtp, fakecreate, fakesubproc): """...nor should same few-days-later Branched nightly with *older* packages... """ @@ -349,8 +423,8 @@ class TestRelvalConsumerPostBranch: @mock.patch('fedfind.release.Compose.exists', return_value=True) @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetdifferent) @mock.patch('wikitcms.event.ComposeEvent.creation_date', '20160629') - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.ComposeEvent(None, '25', 'Alpha', '1.2')) - def test_branched4_newer(self, fakecompexists, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.ComposeEvent(None, '25', 'Alpha', '1.2')) + def test_branched4_newer(self, fakecurrev, fakecompexists, fakesmtp, fakecreate, fakesubproc): """...but same few-days-later Branched nightly with newer packages should create event. """ @@ -360,8 +434,8 @@ class TestRelvalConsumerPostBranch: @mock.patch('fedfind.release.Production.label', 'Alpha-1.3') @mock.patch('fedfind.release.Production.cid', ALPHA3) @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetdifferent) - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.NightlyEvent(None, '25', 'Branched', '20160705.n.0')) - def test_alpha3(self, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, '25', 'Branched', '20160705.n.0')) + def test_alpha3(self, fakecurrev, fakesmtp, fakecreate, fakesubproc): """Another Alpha candidate came along! Event should be created even though it's only been one day. """ @@ -371,8 +445,8 @@ class TestRelvalConsumerPostBranch: @mock.patch('fedfind.release.Compose.exists', return_value=True) @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetdifferent) @mock.patch('wikitcms.event.ComposeEvent.creation_date', '20160706') - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.ComposeEvent(None, '25', 'Alpha', '1.3')) - def test_branched5(self, fakecompexists, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.ComposeEvent(None, '25', 'Alpha', '1.3')) + def test_branched5(self, fakecurrev, fakecompexists, fakesmtp, fakecreate, fakesubproc): """OK, say Alpha 1.3 went out as Alpha. Now another Branched comes along. This isn't testing anything new but I wanna go from Branched to Beta then Beta to Final. We should get an event @@ -382,8 +456,8 @@ class TestRelvalConsumerPostBranch: assert fakecreate.call_args[1]['check'] is True @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetdifferent) - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.NightlyEvent(None, '25', 'Branched', '20160710.n.0')) - def test_rawhide5(self, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, '25', 'Branched', '20160710.n.0')) + def test_rawhide5(self, fakecurrev, fakesmtp, fakecreate, fakesubproc): """Meanwhile, a Rawhide compose shows up (this is a thing that happens all the time). We should NOT create any event for it - we never create events for the release after the next (i.e. for @@ -396,8 +470,8 @@ class TestRelvalConsumerPostBranch: @mock.patch('fedfind.release.Production.label', 'Beta-1.1') @mock.patch('fedfind.release.Production.cid', BETA1) @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetdifferent) - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.NightlyEvent(None, '25', 'Branched', '20160710.n.0')) - def test_beta1(self, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, '25', 'Branched', '20160710.n.0')) + def test_beta1(self, fakecurrev, fakesmtp, fakecreate, fakesubproc): """OK, here comes Beta. We should get an event, of course.""" CONSUMER(_fakemsg(BETA1)) assert fakecreate.call_args[1]['check'] is True @@ -407,8 +481,8 @@ class TestRelvalConsumerPostBranch: @mock.patch('fedfind.release.Compose.exists', return_value=True) @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetdifferent) @mock.patch('wikitcms.event.ComposeEvent.creation_date', '20160714') - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.ComposeEvent(None, '25', 'Beta', '1.1')) - def test_final1(self, fakecompexists, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.ComposeEvent(None, '25', 'Beta', '1.1')) + def test_final1(self, fakecurrev, fakecompexists, fakesmtp, fakecreate, fakesubproc): """Finally, here comes Final! Testing going straight from one candidate compose to another milestone candidate compose, though this is unlikely ever to happen. We should get an event. @@ -420,8 +494,8 @@ class TestRelvalConsumerPostBranch: @mock.patch('fedfind.release.Compose.exists', return_value=True) @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetdifferent) @mock.patch('wikitcms.event.ComposeEvent.creation_date', '20160721') - @mock.patch('wikitcms.wiki.Wiki.current_event', wikitcms.event.ComposeEvent(None, '25', 'RC', '1.1')) - def test_atomic1(self, fakecompexists, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.ComposeEvent(None, '25', 'RC', '1.1')) + def test_atomic1(self, fakecurrev, fakecompexists, fakesmtp, fakecreate, fakesubproc): """We may get two-week Atomic composes for the release starting up before it goes final; make sure we don't get events for these. """ @@ -430,8 +504,8 @@ class TestRelvalConsumerPostBranch: assert fakesmtp.call_count == 0 @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetdifferent) - @mock.patch('wikitcms.wiki.Wiki.current_modular_event', wikitcms.event.NightlyEvent(None, '27', 'Branched', '20171001.n.0', modular=True)) - def test_modular_branched1(self, fakesmtp, fakecreate, fakesubproc): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, '27', 'Branched', '20171001.n.0', dist="Fedora-Modular")) + def test_modular_branched1(self, fakecurrev, fakesmtp, fakecreate, fakesubproc): """Now a Modular compose shows up! We should NOT get an event, because we don't do events for modular composes any more. """ @@ -439,6 +513,61 @@ class TestRelvalConsumerPostBranch: assert fakecreate.call_count == 0 assert fakesmtp.call_count == 0 + @mock.patch('fedfind.release.IoTNightly.cid', IOT1) + @mock.patch("fedfind.release.IoTNightly.label", "RC-20160621.0") + @mock.patch('fedfind.release.Compose.exists', return_value=True) + @mock.patch("wikitcms.wiki.Wiki.get_current_event", return_value=None) + def test_iot1(self, fakecurrev, fakecompexists, fakesmtp, fakecreate, fakesubproc): + """An IoT compose shows up, and we have never done an IoT event + before, so get_current_event returns None. We should create an + event in this case. + """ + CONSUMER(_fakemsg(IOT1)) + assert fakecreate.call_args[1]["check"] is True + assert fakecreate.call_args[0][0].dist == "Fedora-IoT" + smtp = fakesmtp.return_value + assert smtp.sendmail.call_args[0][0] == "rawhide@fedoraproject.org" + assert smtp.sendmail.call_args[0][1] == ["test-announce@lists.fedoraproject.org"] + assert smtp.sendmail.call_args[0][2] == IOT1MAIL + + @mock.patch('fedfind.release.IoTNightly.cid', IOT2) + @mock.patch("fedfind.release.IoTNightly.label", "RC-20160625.0") + @mock.patch('fedfind.release.Compose.exists', return_value=True) + @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetsame) + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, "25", "Branched", "20160621.n.0", dist="Fedora-IoT")) + def test_iot2_same(self, fakecurrev, fakecompexists, fakesmtp, fakecreate, fakesubproc): + """A second IoT compose shows up a few days later, with the + same packages. We should not create an event. + """ + CONSUMER(_fakemsg(IOT2)) + assert fakecreate.call_count == 0 + assert fakesmtp.call_count == 0 + + @mock.patch('fedfind.release.IoTNightly.cid', IOT2) + @mock.patch("fedfind.release.IoTNightly.label", "RC-20160625.0") + @mock.patch('fedfind.release.Compose.exists', return_value=True) + @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetdifferent) + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, "25", "Branched", "20160621.n.0", dist="Fedora-IoT")) + def test_iot2_different(self, fakecurrev, fakecompexists, fakesmtp, fakecreate, fakesubproc): + """But if it showed up with different packages, we should. + """ + CONSUMER(_fakemsg(IOT2)) + assert fakecreate.call_args[1]["check"] is True + assert fakecreate.call_args[0][0].dist == "Fedora-IoT" + + @mock.patch('fedfind.release.IoTNightly.cid', IOT3) + @mock.patch("fedfind.release.IoTNightly.label", "RC-20160714.0") + @mock.patch('fedfind.release.Compose.exists', return_value=True) + @mock.patch('fedfind.release.Pungi4Release.get_package_nvras', _fakegetsame) + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, "25", "Branched", "20160625.n.0", dist="Fedora-IoT")) + def test_iot3_same(self, fakecurrev, fakecompexists, fakesmtp, fakecreate, fakesubproc): + """A third IoT compose shows up some time later, with the + same packages. We should create an event. + """ + CONSUMER(_fakemsg(IOT3)) + assert fakecreate.call_args[1]["check"] is True + assert fakecreate.call_args[0][0].dist == "Fedora-IoT" + def test_badcid(self, fakesmtp, fakecreate, fakesubproc): """On a non-parseable compose ID, we should log errors and raise the fedora_messaging Drop exception. @@ -448,8 +577,8 @@ class TestRelvalConsumerPostBranch: 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): + @mock.patch('wikitcms.wiki.Wiki.get_current_event', return_value=wikitcms.event.NightlyEvent(None, '25', 'Rawhide', '20160620.n.0')) + def test_testconsumer(self, fakecurrev, fakesmtp, fakecreate, fakesubproc): """Creating second Branched nightly again with test consumer, to make sure that works. """