mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-10 16:44:59 +08:00
Generate buildsys.repo.done locally
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user