diff --git a/module_build_service/messaging.py b/module_build_service/messaging.py index 267ecdd4..0d163cb2 100644 --- a/module_build_service/messaging.py +++ b/module_build_service/messaging.py @@ -298,6 +298,18 @@ class CoprBuildEnd(KojiBuildChange): self.copr = copr +class CoprRepoDone(object): + """There is actually no repo.done message in Copr + This is a class for constructing buildsys.repo.done + and triggering it locally""" + def __init__(self, copr): + self.copr = copr + + def publish(self): + msg = {"tag": "{}-build".format(self.copr)} + publish("repo.done", msg, conf, "buildsys") + + class MBSModule(BaseMessage): """ A class that inherits from BaseMessage to provide a message object for a module event generated by module_build_service diff --git a/module_build_service/scheduler/handlers/components.py b/module_build_service/scheduler/handlers/components.py index 52665043..a04a69ce 100644 --- a/module_build_service/scheduler/handlers/components.py +++ b/module_build_service/scheduler/handlers/components.py @@ -30,7 +30,7 @@ import module_build_service.pdc import koji -from module_build_service import models, log +from module_build_service import models, log, messaging logging.basicConfig(level=logging.DEBUG) @@ -111,6 +111,13 @@ def _finalize(config, session, msg, state): builder.tag_artifacts(built_components_in_batch) session.commit() + + # Start of new batch is triggered by buildys.repo.done message. + # However in Copr there is no such thing. Therefore, + # since the batch is done, we can state that repo is done + if config.system == "copr": + messaging.CoprRepoDone(msg.copr).publish() + elif (any([c.state != koji.BUILD_STATES['BUILDING'] for c in unbuilt_components_in_batch])): # We are not in the middle of the batch building and diff --git a/tests/test_messaging.py b/tests/test_messaging.py index 97043f55..c13a3132 100644 --- a/tests/test_messaging.py +++ b/tests/test_messaging.py @@ -23,7 +23,7 @@ import unittest from module_build_service import messaging, conf -from mock import patch, PropertyMock +from mock import patch, PropertyMock, ANY class TestFedmsgMessaging(unittest.TestCase): @@ -90,3 +90,10 @@ class TestFedmsgMessaging(unittest.TestCase): self.assertEqual(msg.build_release, '1.20150203.git.c8504a8a.fc21') self.assertEqual(msg.state_reason, 'build end: user:fatka copr:mutt-kz build:100 ip:172.16.3.3 pid:12010 status:1') + + @patch("module_build_service.messaging.publish") + def test_copr_repo_done(self, publish): + messaging.CoprRepoDone('someprojectname').publish() + self.assertTrue(publish.called) + repo_change_msg = {'tag': 'someprojectname-build'} + publish.assert_called_with("repo.done", repo_change_msg, ANY, "buildsys")