#1293 When no architecture is set in Koji tag, fallback to conf.arches
Merged 4 years ago by jkaluza. Opened 4 years ago by jkaluza.
jkaluza/fm-orchestrator arches  into  master

@@ -1322,4 +1322,6 @@ 

          tag = koji_session.getTag(module.koji_tag)

          if not tag:

              raise ValueError("Unknown Koji tag %r." % module.koji_tag)

+         if not tag["arches"]:

+             return []

          return tag["arches"].split(" ")

@@ -319,6 +319,17 @@ 

          r = module_build_service.utils.get_build_arches(mmd, conf)

          assert r == ["ppc64le"]

  

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

+     def test_get_build_arches_no_arch_set(self, ClientSession):

+         """

+         When no architecture is set in Koji tag, fallback to conf.arches.

+         """

+         session = ClientSession.return_value

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

+         mmd = load_mmd_file(path.join(BASE_DIR, "..", "staged_data", "formatted_testmodule.yaml"))
cqi commented 4 years ago

Call read_staged_data to read this yaml file instead?

Probably it should be good to comment out this line why this module yaml file can be used for this test.

+         r = module_build_service.utils.get_build_arches(mmd, conf)

+         assert set(r) == set(conf.arches)

+ 

      @patch(

          "module_build_service.config.Config.allowed_privileged_module_names",

          new_callable=mock.PropertyMock,

no initial comment

Tested on staging, fixes the issue when Koji tag is empty.

In which cases GenericBuilder.get_module_build_arches would return ['']? Can we name value [''] or let GenericBuilder.get_module_build_arches return a false value when arches is ['']? The latter should be a better choice.

rebased onto c9d2b77

4 years ago

@cqi: that's good point. I've updated the code so KojiModuleBuilder.get_module_build_arches() returns an empty list if list of arches of Koji tag is set to "".

Call read_staged_data to read this yaml file instead?

Probably it should be good to comment out this line why this module yaml file can be used for this test.

I like @cqi's suggestion, but it's not a blocker.

:thumbsup:

I will merge that as it is... all the tests in that file use the same approach as I used and I want to deploy this fix soon :).

Pull-Request has been merged by jkaluza

4 years ago