From 9bd16beeeff56077896695b5af21545997a26b9c Mon Sep 17 00:00:00 2001 From: mprahl Date: Aug 04 2018 00:45:00 +0000 Subject: Store the component's build ID and use that to identify the build when acting on a tag message This resolves an issue where the component name is different than the package being tagged due to a macro such as those used for SCLs. --- diff --git a/module_build_service/builder/KojiModuleBuilder.py b/module_build_service/builder/KojiModuleBuilder.py index 4ffcff3..06c0fd8 100644 --- a/module_build_service/builder/KojiModuleBuilder.py +++ b/module_build_service/builder/KojiModuleBuilder.py @@ -610,6 +610,7 @@ chmod 644 %buildroot/etc/rpm/macros.zz-modules component_build.state = koji.BUILD_STATES['COMPLETE'] component_build.nvr = build['nvr'] component_build.task_id = build['task_id'] + component_build.build_id = build['build_id'] component_build.state_reason = 'Found existing build' nvr_dict = kobo.rpmlib.parse_nvr(component_build.nvr) # Trigger a completed build message @@ -630,7 +631,8 @@ chmod 644 %buildroot/etc/rpm/macros.zz-modules log.info('The build being skipped isn\'t tagged in the "{0}" tag. Will send a ' 'message to the tag handler'.format(tag)) further_work.append(module_build_service.messaging.KojiTagChange( - 'recover_orphaned_artifact: fake message', tag, component_build.package)) + 'recover_orphaned_artifact: fake message', tag, component_build.package, + component_build.build_id)) return further_work def build(self, artifact_name, source): diff --git a/module_build_service/messaging.py b/module_build_service/messaging.py index 18ee92c..54a464a 100644 --- a/module_build_service/messaging.py +++ b/module_build_service/messaging.py @@ -157,7 +157,8 @@ class FedmsgMessageParser(MessageParser): elif category == 'buildsys' and event == 'tag': tag = msg_inner_msg.get('tag') artifact = msg_inner_msg.get('name') - msg_obj = KojiTagChange(msg_id, tag, artifact) + build_id = msg_inner_msg.get('build_id') + msg_obj = KojiTagChange(msg_id, tag, artifact, build_id) elif category == 'mbs' and object == 'module' and \ subobject == 'state' and event == 'change': @@ -209,10 +210,11 @@ class KojiTagChange(BaseMessage): :param tag: the name of tag (e.g. module-123456789-build) :param artifact: the name of tagged artifact (e.g. module-build-macros) """ - def __init__(self, msg_id, tag, artifact): + def __init__(self, msg_id, tag, artifact, build_id): super(KojiTagChange, self).__init__(msg_id) self.tag = tag self.artifact = artifact + self.build_id = build_id class KojiRepoChange(BaseMessage): diff --git a/module_build_service/migrations/versions/c702c2d26a8b_component_build_id.py b/module_build_service/migrations/versions/c702c2d26a8b_component_build_id.py new file mode 100644 index 0000000..b7971d5 --- /dev/null +++ b/module_build_service/migrations/versions/c702c2d26a8b_component_build_id.py @@ -0,0 +1,24 @@ +"""Add the component build_id column + +Revision ID: c702c2d26a8b +Revises: 9d5e6938588f +Create Date: 2018-08-03 15:28:38.493950 + +""" + +# revision identifiers, used by Alembic. +revision = 'c702c2d26a8b' +down_revision = '9d5e6938588f' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + with op.batch_alter_table('component_builds') as b: + b.add_column(sa.Column('build_id', sa.Integer(), nullable=True)) + + +def downgrade(): + with op.batch_alter_table('component_builds') as b: + b.drop_column('build_id') diff --git a/module_build_service/models.py b/module_build_service/models.py index d0e8f01..13bd69d 100644 --- a/module_build_service/models.py +++ b/module_build_service/models.py @@ -658,7 +658,8 @@ class ComponentBuild(MBSBase): scmurl = db.Column(db.String, nullable=False) # XXX: Consider making this a proper ENUM format = db.Column(db.String, nullable=False) - task_id = db.Column(db.Integer) # This is the id of the build in koji + build_id = db.Column(db.Integer) # This is the id of the build in Koji + task_id = db.Column(db.Integer) # This is the id of the build task in Koji # This is the commit hash that component was built with ref = db.Column(db.String, nullable=True) # XXX: Consider making this a proper ENUM (or an int) @@ -708,12 +709,18 @@ class ComponentBuild(MBSBase): return session.query(cls).filter_by( package=component_name, module_id=module_id).first() + @classmethod + def from_component_build_id(cls, session, build_id, module_id): + return session.query(cls).filter_by( + build_id=build_id, module_id=module_id).first() + def state_trace(self, component_id): return ComponentBuildTrace.query.filter_by( component_id=component_id).order_by(ComponentBuildTrace.state_time).all() def json(self): retval = { + 'build_id': self.build_id, 'id': self.id, 'package': self.package, 'format': self.format, @@ -758,8 +765,9 @@ class ComponentBuild(MBSBase): return json def __repr__(self): - return "" % ( - self.package, self.module_id, self.state, self.task_id, self.batch, self.state_reason) + return ("") % (self.package, self.module_id, self.state, self.build_id, + self.task_id, self.batch, self.state_reason) class ComponentBuildTrace(MBSBase): diff --git a/module_build_service/scheduler/handlers/components.py b/module_build_service/scheduler/handlers/components.py index 291ff1f..0bbf1a7 100644 --- a/module_build_service/scheduler/handlers/components.py +++ b/module_build_service/scheduler/handlers/components.py @@ -62,6 +62,7 @@ def _finalize(config, session, msg, state): component_build.state = state component_build.nvr = nvr component_build.state_reason = state_reason + component_build.build_id = msg.build_id session.commit() parent = component_build.module_build diff --git a/module_build_service/scheduler/handlers/tags.py b/module_build_service/scheduler/handlers/tags.py index 732d4de..e8e4b78 100644 --- a/module_build_service/scheduler/handlers/tags.py +++ b/module_build_service/scheduler/handlers/tags.py @@ -44,8 +44,8 @@ def tagged(config, session, msg): return # Find tagged component. - component = models.ComponentBuild.from_component_name( - session, msg.artifact, module_build.id) + component = models.ComponentBuild.from_component_build_id( + session, msg.build_id, module_build.id) if not component: log.error("No component %s in module %r", msg.artifact, module_build) return diff --git a/module_build_service/utils/reuse.py b/module_build_service/utils/reuse.py index 826cad9..b35467b 100644 --- a/module_build_service/utils/reuse.py +++ b/module_build_service/utils/reuse.py @@ -58,13 +58,14 @@ def reuse_component(component, previous_component_build, component.state_reason = \ 'Reused component from previous module build' component.nvr = previous_component_build.nvr + component.build_id = previous_component_build.build_id nvr_dict = kobo.rpmlib.parse_nvr(component.nvr) # Add this message to further_work so that the reused # component will be tagged properly return [ module_build_service.messaging.KojiBuildChange( msg_id='reuse_component: fake msg', - build_id=None, + build_id=component.build_id, task_id=component.task_id, build_new_state=previous_component_build.state, build_name=component.package, diff --git a/tests/__init__.py b/tests/__init__.py index cf2a1d3..4d122ef 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -149,6 +149,7 @@ def _populate_data(session, data_size=10, contexts=False): ('git://pkgs.domain.local/rpms/nginx?' '#ga95886c8a443b36a9ce31abda1f9bed22f2f8c3') component_one_build_one.format = 'rpms' + component_one_build_one.build_id = 2345 + index component_one_build_one.task_id = 12312345 + index component_one_build_one.state = koji.BUILD_STATES['COMPLETE'] component_one_build_one.nvr = 'nginx-1.10.1-2.{0}'.format(build_one_component_release) @@ -163,6 +164,7 @@ def _populate_data(session, data_size=10, contexts=False): ('/tmp/module_build_service-build-macrosWZUPeK/SRPMS/' 'module-build-macros-0.1-1.module_nginx_1_2.src.rpm') component_two_build_one.format = 'rpms' + component_two_build_one.build_id = 4356 + index component_two_build_one.task_id = 12312321 + index component_two_build_one.state = koji.BUILD_STATES['COMPLETE'] component_two_build_one.nvr = \ @@ -200,6 +202,7 @@ def _populate_data(session, data_size=10, contexts=False): ('git://pkgs.domain.local/rpms/postgresql?' '#dc95586c4a443b26a9ce38abda1f9bed22f2f8c3') component_one_build_two.format = 'rpms' + component_one_build_two.build_id = 345345 + index component_one_build_two.task_id = 2433433 + index component_one_build_two.state = koji.BUILD_STATES['COMPLETE'] component_one_build_two.nvr = 'postgresql-9.5.3-4.{0}'.format(build_two_component_release) @@ -214,6 +217,7 @@ def _populate_data(session, data_size=10, contexts=False): ('/tmp/module_build_service-build-macrosWZUPeK/SRPMS/' 'module-build-macros-0.1-1.module_postgresql_1_2.src.rpm') component_two_build_two.format = 'rpms' + component_two_build_two.build_id = 567567 + index component_two_build_two.task_id = 47383993 + index component_two_build_two.state = koji.BUILD_STATES['COMPLETE'] component_two_build_two.nvr = \ @@ -250,6 +254,7 @@ def _populate_data(session, data_size=10, contexts=False): ('git://pkgs.domain.local/rpms/rubygem-rails?' '#dd55886c4a443b26a9ce38abda1f9bed22f2f8c3') component_one_build_three.format = 'rpms' + component_one_build_three.build_id = 345353 + index component_one_build_three.task_id = 2433433 + index component_one_build_three.state = koji.BUILD_STATES['FAILED'] component_one_build_three.nvr = \ @@ -263,6 +268,7 @@ def _populate_data(session, data_size=10, contexts=False): ('/tmp/module_build_service-build-macrosWZUPeK/SRPMS/' 'module-build-macros-0.1-1.module_testmodule_1_2.src.rpm') component_two_build_three.format = 'rpms' + component_two_build_three.build_id = 83732 + index component_two_build_three.task_id = 47383993 + index component_two_build_three.state = koji.BUILD_STATES['COMPLETE'] component_two_build_three.nvr = \ @@ -431,6 +437,7 @@ def reuse_component_init_data(): ('git://pkgs.fedoraproject.org/rpms/perl-Tangerine' '?#4ceea43add2366d8b8c5a622a2fb563b625b9abf') component_one_build_one.format = 'rpms' + component_one_build_one.build_id = 23456 component_one_build_one.task_id = 90276227 component_one_build_one.state = koji.BUILD_STATES['COMPLETE'] component_one_build_one.nvr = \ @@ -446,6 +453,7 @@ def reuse_component_init_data(): ('git://pkgs.fedoraproject.org/rpms/perl-List-Compare' '?#76f9d8c8e87eed0aab91034b01d3d5ff6bd5b4cb') component_two_build_one.format = 'rpms' + component_two_build_one.build_id = 23457 component_two_build_one.task_id = 90276228 component_two_build_one.state = koji.BUILD_STATES['COMPLETE'] component_two_build_one.nvr = \ @@ -461,6 +469,7 @@ def reuse_component_init_data(): ('git://pkgs.fedoraproject.org/rpms/tangerine' '?#fbed359411a1baa08d4a88e0d12d426fbf8f602c') component_three_build_one.format = 'rpms' + component_three_build_one.build_id = 23458 component_three_build_one.task_id = 90276315 component_three_build_one.state = koji.BUILD_STATES['COMPLETE'] component_three_build_one.nvr = \ @@ -476,6 +485,7 @@ def reuse_component_init_data(): ('/tmp/module_build_service-build-macrosqr4AWH/SRPMS/module-build-' 'macros-0.1-1.module_testmodule_master_20170109091357.src.rpm') component_four_build_one.format = 'rpms' + component_four_build_one.build_id = 23459 component_four_build_one.task_id = 90276181 component_four_build_one.state = koji.BUILD_STATES['COMPLETE'] component_four_build_one.nvr = \ @@ -542,6 +552,7 @@ def reuse_component_init_data(): ('/tmp/module_build_service-build-macrosqr4AWH/SRPMS/module-build-' 'macros-0.1-1.module_testmodule_master_20170219191323.src.rpm') component_four_build_two.format = 'rpms' + component_four_build_two.build_id = 456789 component_four_build_two.task_id = 90276186 component_four_build_two.state = koji.BUILD_STATES['COMPLETE'] component_four_build_two.nvr = \ diff --git a/tests/test_build/test_build.py b/tests/test_build/test_build.py index bd3b11b..0a96273 100644 --- a/tests/test_build/test_build.py +++ b/tests/test_build/test_build.py @@ -103,6 +103,7 @@ class FakeModuleBuilder(GenericBuilder): on_cancel_cb = None on_buildroot_add_artifacts_cb = None on_tag_artifacts_cb = None + component_ids = {} @module_build_service.utils.validate_koji_tag('tag_name') def __init__(self, owner, module, config, tag_name, components): @@ -120,6 +121,7 @@ class FakeModuleBuilder(GenericBuilder): FakeModuleBuilder.on_tag_artifacts_cb = None FakeModuleBuilder.DEFAULT_GROUPS = None FakeModuleBuilder.backend = 'test' + FakeModuleBuilder.component_ids = {} def buildroot_connect(self, groups): default_groups = FakeModuleBuilder.DEFAULT_GROUPS or { @@ -155,15 +157,10 @@ class FakeModuleBuilder(GenericBuilder): FakeModuleBuilder.on_buildroot_add_artifacts_cb(self, artifacts, install) if self.backend == 'test': for nvr in artifacts: - # buildroot_add_artifacts received a list of NVRs, but the tag message expects the - # component name. At this point, the NVR may not be set if we are trying to reuse - # all components, so we can't search the database. We must parse the package name - # from the nvr and then tag it in the build tag. Kobo doesn't work when parsing - # the NVR of a component with a module dist-tag, so we must manually do it. - package_name = nvr.split('.module')[0].rsplit('-', 2)[0] + component = models.ComponentBuild.query.filter_by(nvr=nvr).first() # When INSTANT_COMPLETE is on, the components are already in the build tag if self.INSTANT_COMPLETE is False: - self._send_tag(package_name, dest_tag=False) + self._send_tag(component, dest_tag=False) elif self.backend == 'testlocal': self._send_repo_done() @@ -178,8 +175,8 @@ class FakeModuleBuilder(GenericBuilder): for nvr in artifacts: # tag_artifacts received a list of NVRs, but the tag message expects the # component name - artifact = models.ComponentBuild.query.filter_by(nvr=nvr).first().package - self._send_tag(artifact, dest_tag=dest_tag) + component = models.ComponentBuild.query.filter_by(nvr=nvr).first() + self._send_tag(component, dest_tag=dest_tag) @property def koji_session(self): @@ -202,15 +199,20 @@ class FakeModuleBuilder(GenericBuilder): ) module_build_service.scheduler.consumer.work_queue_put(msg) - def _send_tag(self, artifact, dest_tag=True): + def _send_tag(self, component, dest_tag=True): if dest_tag: tag = self.tag_name else: tag = self.tag_name + "-build" + + if not FakeModuleBuilder.component_ids.get(component.package): + FakeModuleBuilder.component_ids[component.package] = component.build_id + msg = module_build_service.messaging.KojiTagChange( msg_id='a faked internal message', tag=tag, - artifact=artifact + artifact=component.package, + build_id=FakeModuleBuilder.component_ids[component.package] ) module_build_service.scheduler.consumer.work_queue_put(msg) @@ -230,7 +232,10 @@ class FakeModuleBuilder(GenericBuilder): def build(self, artifact_name, source): print("Starting building artifact %s: %s" % (artifact_name, source)) - build_id = randint(1000, 9999999) + # Make sure we have consistent component IDs on every message + if artifact_name not in FakeModuleBuilder.component_ids: + FakeModuleBuilder.component_ids[artifact_name] = randint(1000, 9999999) + build_id = FakeModuleBuilder.component_ids[artifact_name] if FakeModuleBuilder.on_build_cb: FakeModuleBuilder.on_build_cb(self, artifact_name, source) @@ -264,17 +269,21 @@ class FakeModuleBuilder(GenericBuilder): component_build.state = koji.BUILD_STATES['COMPLETE'] component_build.nvr = nvr component_build.task_id = component_build.id + 51234 + if component_build.package not in FakeModuleBuilder.component_ids: + FakeModuleBuilder.component_ids[component_build.package] = component_build.id + 123 + component_build.build_id = FakeModuleBuilder.component_ids[component_build.package] component_build.state_reason = 'Found existing build' nvr_dict = kobo.rpmlib.parse_nvr(component_build.nvr) # Send a message stating the build is complete msgs.append(module_build_service.messaging.KojiBuildChange( - 'recover_orphaned_artifact: fake message', randint(1, 9999999), + 'recover_orphaned_artifact: fake message', component_build.build_id, component_build.task_id, koji.BUILD_STATES['COMPLETE'], component_build.package, nvr_dict['version'], nvr_dict['release'], component_build.module_build.id)) # Send a message stating that the build was tagged in the build tag msgs.append(module_build_service.messaging.KojiTagChange( 'recover_orphaned_artifact: fake message', - component_build.module_build.koji_tag + '-build', component_build.package)) + component_build.module_build.koji_tag + '-build', component_build.package, + component_build.build_id)) return msgs def finalize(self): diff --git a/tests/test_scheduler/test_tag_tagged.py b/tests/test_scheduler/test_tag_tagged.py index c863943..cd11419 100644 --- a/tests/test_scheduler/test_tag_tagged.py +++ b/tests/test_scheduler/test_tag_tagged.py @@ -45,7 +45,7 @@ class TestTagTagged: """ from_tag_change_event.return_value = None msg = module_build_service.messaging.KojiTagChange( - 'no matches for this...', '2016-some-nonexistent-build', "artifact") + 'no matches for this...', '2016-some-nonexistent-build', "artifact", 12345) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) @@ -56,7 +56,8 @@ class TestTagTagged: msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c-build', - "artifact") + "artifact", + 12345) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) @@ -85,28 +86,35 @@ class TestTagTagged: # Set previous components as COMPLETE and tagged. module_build.batch = 1 + i = 0 for c in module_build.up_to_current_batch(): c.state = koji.BUILD_STATES["COMPLETE"] c.tagged = True c.tagged_in_final = True + c.build_id = 456790 + i + i += 1 module_build.batch = 2 for c in module_build.current_batch(): c.state = koji.BUILD_STATES["COMPLETE"] + c.build_id = 456790 + i + i += 1 db.session.commit() # Tag the first component to the buildroot. msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c-build', - "perl-Tangerine") + "perl-Tangerine", + 456791) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) # Tag the first component to the final tag. msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c', - "perl-Tangerine") + "perl-Tangerine", + 456791) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) @@ -118,7 +126,8 @@ class TestTagTagged: msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c-build', - "perl-List-Compare") + "perl-List-Compare", + 456792) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) @@ -130,7 +139,8 @@ class TestTagTagged: msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c', - "perl-List-Compare") + "perl-List-Compare", + 456792) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) @@ -172,20 +182,23 @@ class TestTagTagged: component = module_build_service.models.ComponentBuild.query\ .filter_by(package='perl-Tangerine', module_id=module_build.id).one() component.state = koji.BUILD_STATES["BUILDING"] + component.build_id = 123456 db.session.commit() # Tag the perl-List-Compare component to the buildroot. msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c-build', - "perl-Tangerine") + "perl-Tangerine", + 123456) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) # Tag the perl-List-Compare component to final tag. msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c', - "perl-Tangerine") + "perl-Tangerine", + 123456) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) @@ -226,9 +239,11 @@ class TestTagTagged: module_build.batch = 2 component = module_build_service.models.ComponentBuild.query\ .filter_by(package='perl-Tangerine', module_id=module_build.id).one() + component.build_id = 456791 component.state = koji.BUILD_STATES["FAILED"] component = module_build_service.models.ComponentBuild.query\ .filter_by(package='perl-List-Compare', module_id=module_build.id).one() + component.build_id = 456792 component.state = koji.BUILD_STATES["COMPLETE"] db.session.commit() @@ -236,14 +251,16 @@ class TestTagTagged: msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c-build', - "perl-List-Compare") + "perl-List-Compare", + 456792) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) # Tag the perl-List-Compare component to final tag. msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c', - "perl-List-Compare") + "perl-List-Compare", + 456792) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) @@ -290,6 +307,14 @@ class TestTagTagged: module_id=3, package='module-build-macros').one() mbm.tagged = False db.session.add(mbm) + pt = module_build_service.models.ComponentBuild.query.filter_by( + module_id=3, package='perl-Tangerine').one() + pt.build_id = 456791 + db.session.add(pt) + plc = module_build_service.models.ComponentBuild.query.filter_by( + module_id=3, package='perl-List-Compare').one() + plc.build_id = 456792 + db.session.add(plc) for c in module_build.current_batch(): c.state = koji.BUILD_STATES["COMPLETE"] db.session.commit() @@ -298,14 +323,16 @@ class TestTagTagged: msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c-build', - "perl-Tangerine") + "perl-Tangerine", + 456791) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) # Tag the first component to the final tag. msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c', - "perl-Tangerine") + "perl-Tangerine", + 456791) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) @@ -317,14 +344,16 @@ class TestTagTagged: msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c-build', - "perl-List-Compare") + "perl-List-Compare", + 456792) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) # Tag the second component to final tag. msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c', - "perl-List-Compare") + "perl-List-Compare", + 456792) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) @@ -336,14 +365,16 @@ class TestTagTagged: msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c', - "module-build-macros") + "module-build-macros", + 456789) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) # Tag the component from first batch to the buildroot. msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c-build', - "module-build-macros") + "module-build-macros", + 456789) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) @@ -397,16 +428,19 @@ class TestTagTagged: component.build_time_only = True component.tagged = False component.tagged_in_final = False + component.build_id = 456791 component = module_build_service.models.ComponentBuild.query\ .filter_by(package='perl-List-Compare', module_id=module_build.id).one() component.state = koji.BUILD_STATES["COMPLETE"] + component.build_id = 456792 db.session.commit() # Tag the perl-Tangerine component to the buildroot. msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c-build', - "perl-Tangerine") + "perl-Tangerine", + 456791) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) assert not koji_session.newRepo.called @@ -414,14 +448,16 @@ class TestTagTagged: msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c-build', - "perl-List-Compare") + "perl-List-Compare", + 456792) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) # Tag the perl-List-Compare component to final tag. msg = module_build_service.messaging.KojiTagChange( 'id', 'module-testmodule-master-20170219191323-c40c156c', - "perl-List-Compare") + "perl-List-Compare", + 456792) module_build_service.scheduler.handlers.tags.tagged( config=conf, session=db.session, msg=msg) diff --git a/tests/test_views/test_views.py b/tests/test_views/test_views.py index 72f7976..abe1c96 100644 --- a/tests/test_views/test_views.py +++ b/tests/test_views/test_views.py @@ -441,6 +441,7 @@ class TestViews: def test_query_component_build(self): rv = self.client.get('/module-build-service/1/component-builds/1') data = json.loads(rv.data) + assert data['build_id'] == 2345 assert data['id'] == 1 assert data['format'] == 'rpms' assert data['module_build'] == 2 @@ -453,6 +454,7 @@ class TestViews: def test_query_component_build_short(self): rv = self.client.get('/module-build-service/1/component-builds/1?short=True') data = json.loads(rv.data) + assert data['build_id'] == 2345 assert data['id'] == 1 assert data['format'] == 'rpms' assert data['module_build'] == 2 @@ -465,6 +467,7 @@ class TestViews: def test_query_component_build_verbose(self): rv = self.client.get('/module-build-service/1/component-builds/3?verbose=true') data = json.loads(rv.data) + assert data['build_id'] == 345345 assert data['id'] == 3 assert data['format'] == 'rpms' assert data['module_build'] == 3