#1524 Gracefully handle builds without a koji tag
Merged 4 years ago by mprahl. Opened 4 years ago by lucarval.
lucarval/fm-orchestrator fix-build-without-koji-tag  into  master

@@ -1336,6 +1336,9 @@ 

              the module build in the build system.

          :return: list of architectures

          """

+         if not module.koji_tag:

+             log.warning("No Koji tag associated with module %r", module)

+             return []

          koji_session = KojiModuleBuilder.get_session(conf, login=False)

          tag = koji_session.getTag(module.koji_tag)

          if not tag:

@@ -934,6 +934,35 @@ 

          ret = KojiModuleBuilder.get_module_build_arches(module_build)

          assert " ".join(ret) == arches

  

+     @patch.dict("sys.modules", krbV=MagicMock())

+     @patch("module_build_service.builder.KojiModuleBuilder.KojiClientSession")

+     def test_get_module_build_arches_with_archless_tag(self, ClientSession):

+         module_build = module_build_service.models.ModuleBuild.get_by_id(db_session, 2)

+         session = ClientSession.return_value

+         session.getTag.return_value = {"arches": ""}

+         ret = KojiModuleBuilder.get_module_build_arches(module_build)

+         assert ret == []

+ 

+     @patch.dict("sys.modules", krbV=MagicMock())

+     @patch("module_build_service.builder.KojiModuleBuilder.KojiClientSession")

+     def test_get_module_build_arches_without_tag(self, ClientSession):

+         module_build = module_build_service.models.ModuleBuild.get_by_id(db_session, 2)

+         module_build.koji_tag = None

+         session = ClientSession.return_value

+         ret = KojiModuleBuilder.get_module_build_arches(module_build)

+         assert ret == []

+         session.getTag.assert_not_called()

+         session.assert_not_called()

+ 

+     @patch.dict("sys.modules", krbV=MagicMock())

+     @patch("module_build_service.builder.KojiModuleBuilder.KojiClientSession")

+     def test_get_module_build_arches_with_unknown_tag(self, ClientSession):

+         module_build = module_build_service.models.ModuleBuild.get_by_id(db_session, 2)

+         session = ClientSession.return_value

+         session.getTag.return_value = None

+         with pytest.raises(ValueError, match="Unknown Koji tag .*"):

+             KojiModuleBuilder.get_module_build_arches(module_build)

+ 

  

  class TestGetDistTagSRPM:

      """Test KojiModuleBuilder.get_disttag_srpm"""

no initial comment

Can you use the match keyword argument in the pytest.raises function instead?

Build #627 failed (commit: 767be4615f90b6e66537ed3b261b2249b9d1e511).
Rebase or make new commits to rebuild.

2 new commits added

  • Gracefully handle builds without a koji tag
  • Increase get_module_build_arches test coverage
4 years ago

Can you use the match keyword argument in the pytest.raises function instead?

Cool! I didn't know about it. All set.

Commit f487da1 fixes this pull-request

Pull-Request has been merged by mprahl

4 years ago

Pull-Request has been merged by mprahl

4 years ago

Build #628 failed (commit: 618eb3a).
Rebase or make new commits to rebuild.