From d01f911bd1b1e243631cad9fddc2f5199f3d1629 Mon Sep 17 00:00:00 2001 From: Qixiang Wan Date: Jan 16 2020 19:39:45 +0000 Subject: Rename `handler.repos.done` argument name "repo_tag" to "tag_name" This to make it same as the `tag_name` argument in `handlers.tags.tagged`, so we can handle it easily while inspecting the function signatures. --- diff --git a/module_build_service/scheduler/consumer.py b/module_build_service/scheduler/consumer.py index f863f54..ecc9daa 100644 --- a/module_build_service/scheduler/consumer.py +++ b/module_build_service/scheduler/consumer.py @@ -204,7 +204,7 @@ class MBSConsumer(fedmsg.consumers.FedmsgConsumer): if event == events.KOJI_REPO_CHANGE: return ( ON_REPO_CHANGE_HANDLER, - models.ModuleBuild.get_by_tag(db_session, event_info["repo_tag"]) + models.ModuleBuild.get_by_tag(db_session, event_info["tag_name"]) ) if event == events.KOJI_TAG_CHANGE: diff --git a/module_build_service/scheduler/handlers/repos.py b/module_build_service/scheduler/handlers/repos.py index 3771056..72c8c92 100644 --- a/module_build_service/scheduler/handlers/repos.py +++ b/module_build_service/scheduler/handlers/repos.py @@ -15,20 +15,20 @@ logging.basicConfig(level=logging.DEBUG) @celery_app.task @events.mbs_event_handler() -def done(msg_id, repo_tag): +def done(msg_id, tag_name): """Called whenever koji rebuilds a repo, any repo. :param str msg_id: the original id of the message being handled which is received from the message bus. - :param str repo_tag: the tag name from which the repo is generated. + :param str tag_name: the tag name from which the repo is generated. """ # First, find our ModuleBuild associated with this repo, if any. - if conf.system in ("koji", "test") and not repo_tag.endswith("-build"): - log.debug("Tag %r does not end with '-build' suffix, ignoring", repo_tag) + if conf.system in ("koji", "test") and not tag_name.endswith("-build"): + log.debug("Tag %r does not end with '-build' suffix, ignoring", tag_name) return - tag = repo_tag[:-6] if repo_tag.endswith("-build") else repo_tag - module_build = models.ModuleBuild.get_by_tag(db_session, repo_tag) + tag = tag_name[:-6] if tag_name.endswith("-build") else tag_name + module_build = models.ModuleBuild.get_by_tag(db_session, tag_name) if not module_build: log.debug("No module build found associated with koji tag %r" % tag) return diff --git a/module_build_service/scheduler/parser.py b/module_build_service/scheduler/parser.py index 987ec6d..49be676 100644 --- a/module_build_service/scheduler/parser.py +++ b/module_build_service/scheduler/parser.py @@ -92,7 +92,7 @@ class FedmsgMessageParser(MessageParser): return { "msg_id": msg_id, "event": events.KOJI_REPO_CHANGE, - "repo_tag": msg_inner_msg.get("tag") + "tag_name": msg_inner_msg.get("tag") } if event == "tag": diff --git a/tests/test_build/test_build.py b/tests/test_build/test_build.py index 8163e11..add92e9 100644 --- a/tests/test_build/test_build.py +++ b/tests/test_build/test_build.py @@ -1825,7 +1825,7 @@ class TestBuild(BaseTestBuild): events_info = [{ "msg_id": "a faked internal message", "event": events.KOJI_REPO_CHANGE, - "repo_tag": module.koji_tag + "-build" + "tag_name": module.koji_tag + "-build" }] db_session.expire_all() # Stop after processing the seeded message diff --git a/tests/test_messaging.py b/tests/test_messaging.py index d0159d1..1e85c73 100644 --- a/tests/test_messaging.py +++ b/tests/test_messaging.py @@ -74,4 +74,4 @@ class TestFedmsgMessaging: parser = FedmsgMessageParser(messaging.known_fedmsg_services) event_info = parser.parse(buildsys_tag_msg) - assert event_info["repo_tag"] == "module-f0f7e44f3c6cccab-build" + assert event_info["tag_name"] == "module-f0f7e44f3c6cccab-build" diff --git a/tests/test_scheduler/test_consumer.py b/tests/test_scheduler/test_consumer.py index 5a92c88..2d7b0c5 100644 --- a/tests/test_scheduler/test_consumer.py +++ b/tests/test_scheduler/test_consumer.py @@ -76,4 +76,4 @@ class TestConsumer: event_info = process_message.call_args[0][0] assert event_info["event"] == events.KOJI_REPO_CHANGE assert event_info["msg_id"] == msg["body"]["msg_id"] - assert event_info["repo_tag"] == msg["body"]["msg"]["tag"] + assert event_info["tag_name"] == msg["body"]["msg"]["tag"] diff --git a/tests/test_scheduler/test_repo_done.py b/tests/test_scheduler/test_repo_done.py index f701cbb..07b562c 100644 --- a/tests/test_scheduler/test_repo_done.py +++ b/tests/test_scheduler/test_repo_done.py @@ -21,7 +21,7 @@ class TestRepoDone: get_by_tag.return_value = None module_build_service.scheduler.handlers.repos.done( msg_id="no matches for this...", - repo_tag="2016-some-nonexistent-build") + tag_name="2016-some-nonexistent-build") @mock.patch( "module_build_service.builder.KojiModuleBuilder." @@ -58,7 +58,7 @@ class TestRepoDone: module_build_service.scheduler.handlers.repos.done( msg_id="some_msg_id", - repo_tag="module-testmodule-master-20170109091357-7c29193d-build") + tag_name="module-testmodule-master-20170109091357-7c29193d-build") build_fn.assert_called_once_with( artifact_name="tangerine", source=( @@ -118,7 +118,7 @@ class TestRepoDone: module_build_service.scheduler.handlers.repos.done( msg_id="some_msg_id", - repo_tag="module-testmodule-master-20170109091357-7c29193d-build") + tag_name="module-testmodule-master-20170109091357-7c29193d-build") finalizer.assert_called_once() @@ -158,7 +158,7 @@ class TestRepoDone: module_build_service.scheduler.handlers.repos.done( msg_id="some_msg_id", - repo_tag="module-testmodule-master-20170109091357-7c29193d-build") + tag_name="module-testmodule-master-20170109091357-7c29193d-build") build_fn.assert_called_once_with( artifact_name="tangerine", @@ -185,7 +185,7 @@ class TestRepoDone: module_build_service.scheduler.handlers.repos.done( msg_id="some_msg_id", - repo_tag="module-testmodule-master-20170109091357-7c29193d-build") + tag_name="module-testmodule-master-20170109091357-7c29193d-build") mock_log_info.assert_called_with( "Ignoring repo regen, because not all components are tagged." @@ -224,7 +224,7 @@ class TestRepoDone: module_build_service.scheduler.handlers.repos.done( msg_id="some_msg_id", - repo_tag="module-testmodule-master-20170109091357-7c29193d-build") + tag_name="module-testmodule-master-20170109091357-7c29193d-build") module_build = module_build_service.models.ModuleBuild.get_by_id(db_session, 2) assert module_build.state == module_build_service.models.BUILD_STATES["failed"]