def setup_method(self, test_method):
     self.fn = module_build_service.scheduler.handlers.modules.init
     testmodule_yml_path = read_staged_data("testmodule_init")
     mmd = load_mmd(testmodule_yml_path)
     # Set the name and stream
     mmd = mmd.copy("testmodule", "1")
     scmurl = "git://pkgs.domain.local/modules/testmodule?#620ec77"
     clean_database()
     ModuleBuild.create(db_session, conf, "testmodule", "1", 3,
                        mmd_to_str(mmd), scmurl, "mprahl")
 def test_init_includedmodule(self, get_build_arches, mocked_scm,
                              mocked_mod_allow_repo):
     FakeSCM(mocked_scm, "includedmodules", ["testmodule_init.yaml"])
     includedmodules_yml_path = read_staged_data("includedmodules")
     mmd = load_mmd(includedmodules_yml_path)
     # Set the name and stream
     mmd = mmd.copy("includedmodules", "1")
     scmurl = "git://pkgs.domain.local/modules/includedmodule?#da95886"
     ModuleBuild.create(db_session, conf, "includemodule", "1", 3,
                        mmd_to_str(mmd), scmurl, "mprahl")
     self.fn(msg_id="msg-id-1",
             module_build_id=3,
             module_build_state="init")
     build = ModuleBuild.get_by_id(db_session, 3)
     assert build.state == 1
     assert build.name == "includemodule"
     batches = {}
     for comp_build in build.component_builds:
         batches[comp_build.package] = comp_build.batch
     assert batches["perl-List-Compare"] == 2
     assert batches["perl-Tangerine"] == 2
     assert batches["foo"] == 2
     assert batches["tangerine"] == 3
     assert batches["file"] == 4
     # Test that the RPMs are properly merged in xmd
     xmd_rpms = {
         "perl-List-Compare": {
             "ref": "4f26aeafdb"
         },
         "perl-Tangerine": {
             "ref": "4f26aeafdb"
         },
         "tangerine": {
             "ref": "4f26aeafdb"
         },
         "foo": {
             "ref": "93dea37599"
         },
         "file": {
             "ref": "a2740663f8"
         },
     }
     assert build.mmd().get_xmd()["mbs"]["rpms"] == xmd_rpms
Beispiel #3
0
    def _create_module_with_filters(self, db_session, batch, state):
        mmd = load_mmd(read_staged_data("testmodule-with-filters"))
        # Set the name and stream
        mmd = mmd.copy("mbs-testmodule", "test")
        mmd.set_xmd({
            "mbs": {
                "rpms": {
                    "ed": {
                        "ref": "01bf8330812fea798671925cc537f2f29b0bd216"
                    },
                    "mksh": {
                        "ref": "f70fd11ddf96bce0e2c64309706c29156b39141d"
                    },
                },
                "buildrequires": {
                    "host": {
                        "version": "20171024133034",
                        "filtered_rpms": [],
                        "stream": "master",
                        "ref": "6df253bb3c53e84706c01b8ab2d5cac24f0b6d45",
                        "context": "00000000",
                    },
                    "platform": {
                        "version": "20171028112959",
                        "filtered_rpms": [],
                        "stream": "master",
                        "ref": "4f7787370a931d57421f9f9555fc41c3e31ff1fa",
                        "context": "00000000",
                    },
                },
                "scmurl": "file:///testdir",
                "commit": "5566bc792ec7a03bb0e28edd1b104a96ba342bd8",
                "requires": {
                    "platform": {
                        "version": "20171028112959",
                        "filtered_rpms": [],
                        "stream": "master",
                        "ref": "4f7787370a931d57421f9f9555fc41c3e31ff1fa",
                        "context": "00000000",
                    }
                },
            }
        })
        module = ModuleBuild.create(
            db_session,
            conf,
            name="mbs-testmodule",
            stream="test",
            version="20171027111452",
            modulemd=mmd_to_str(mmd),
            scmurl="file:///testdir",
            username="******",
        )
        module.koji_tag = "module-mbs-testmodule-test-20171027111452"
        module.batch = batch
        db_session.add(module)
        db_session.commit()

        comp_builds = [
            {
                "module_id":
                module.id,
                "state":
                state,
                "package":
                "ed",
                "format":
                "rpms",
                "scmurl": ("https://src.fedoraproject.org/rpms/ed"
                           "?#01bf8330812fea798671925cc537f2f29b0bd216"),
                "batch":
                2,
                "ref":
                "01bf8330812fea798671925cc537f2f29b0bd216",
            },
            {
                "module_id":
                module.id,
                "state":
                state,
                "package":
                "mksh",
                "format":
                "rpms",
                "scmurl": ("https://src.fedoraproject.org/rpms/mksh"
                           "?#f70fd11ddf96bce0e2c64309706c29156b39141d"),
                "batch":
                3,
                "ref":
                "f70fd11ddf96bce0e2c64309706c29156b39141d",
            },
        ]

        for build in comp_builds:
            db_session.add(ComponentBuild(**build))
        db_session.commit()

        return module