示例#1
0
    def test_get_build_batches(self):
        pkg1 = Modulemd.ComponentRpm(name="pkg1", rationale="rationale")
        pkg2 = Modulemd.ComponentRpm(name="pkg2", rationale="rationale")
        pkg3 = Modulemd.ComponentRpm(name="pkg3", rationale="rationale", buildorder=1)
        pkg4 = Modulemd.ComponentRpm(name="pkg4", rationale="rationale")
        pkg4.set_buildorder(-20) # https://github.com/fedora-modularity/libmodulemd/issues/77#issuecomment-418198410
        pkg5 = Modulemd.ComponentRpm(name="pkg5", rationale="rationale", buildorder=50)

        # Test trivial usage
        assert ModuleBuildFacade.get_build_batches({}) == []

        # Test multiple components with same buildorder
        rpms = {"pkg1": pkg1, "pkg2": pkg2}
        expected_batches = [{"pkg1": pkg1, "pkg2": pkg2}]
        assert ModuleBuildFacade.get_build_batches(rpms) == expected_batches

        # Test component with buildorder
        rpms = {"pkg3": pkg3, "pkg1": pkg1, "pkg2": pkg2}
        expected_batches = [{"pkg1": pkg1, "pkg2": pkg2}, {"pkg3": pkg3}]
        assert ModuleBuildFacade.get_build_batches(rpms) == expected_batches

        # Test negative buildorder
        rpms = {"pkg1": pkg1, "pkg2": pkg2, "pkg4": pkg4}
        expected_batches = [{"pkg4": pkg4}, {"pkg1": pkg1, "pkg2": pkg2}]
        assert ModuleBuildFacade.get_build_batches(rpms) == expected_batches

        # Test various buildorders at once
        rpms = {"pkg5": pkg5, "pkg3": pkg3, "pkg2": pkg2, "pkg4": pkg4, "pkg1":pkg1}
        expected_batches = [{"pkg4": pkg4}, {"pkg1": pkg1, "pkg2": pkg2}, {"pkg3": pkg3}, {"pkg5": pkg5}]
        assert ModuleBuildFacade.get_build_batches(rpms) == expected_batches
示例#2
0
    def test_buildorder_issue_599(self):
        pkg1 = Modulemd.ComponentRpm(name="jss", rationale="JSS packages")
        pkg2 = Modulemd.ComponentRpm(name="tomcatjss",
                                     rationale="TomcatJSS packages",
                                     buildorder=10)
        pkg3 = Modulemd.ComponentRpm(name="ldapjdk",
                                     rationale="LDAP JDK packages",
                                     buildorder=10)
        pkg4 = Modulemd.ComponentRpm(name="pki-core",
                                     rationale="PKI Core packages",
                                     buildorder=20)
        pkg5 = Modulemd.ComponentRpm(name="dogtag-pki",
                                     rationale="Dogtag PKI packages",
                                     buildorder=20)

        rpms = {
            "jss": pkg1,
            "tomcatjss": pkg2,
            "ldapjdk": pkg3,
            "pki-core": pkg4,
            "dogtag-pki": pkg5
        }
        batches = ModuleBuildFacade.get_build_batches(rpms)

        assert len(batches) == 3
        assert batches[0] == {"jss": pkg1}
        assert batches[1] == {"tomcatjss": pkg2, "ldapjdk": pkg3}
        assert batches[2] == {"pki-core": pkg4, "dogtag-pki": pkg5}
示例#3
0
    def test_add_builds_batches(self, f_users, f_coprs, f_mock_chroots, f_builds, f_modules, f_db):
        pkg1 = Modulemd.ComponentRpm(name="foo", rationale="foo package")
        pkg2 = Modulemd.ComponentRpm(name="bar", rationale="bar package", buildorder=10)
        pkg3 = Modulemd.ComponentRpm(name="baz", rationale="baz package", buildorder=10)

        generator = ModulemdGenerator(name="testmodule", stream="master", version=123, summary="some summary")
        facade = ModuleBuildFacade(self.u1, self.c1, generator.generate(), "testmodule.yaml")
        facade.add_builds({"foo": pkg1, "bar": pkg2, "baz": pkg3}, self.m1)

        b1, b2, b3 = self.m1.builds
        assert b1.batch != b2.batch == b3.batch
        assert b2.batch.blocked_by == b1.batch
示例#4
0
    def test_components(self):
        for version in modulestream_versions:
            stream = Modulemd.ModuleStream.new(version)

            # Add an RPM component to a stream
            rpm_comp = Modulemd.ComponentRpm(name="rpmcomponent")
            stream.add_component(rpm_comp)
            assert "rpmcomponent" in stream.get_rpm_component_names()
            retrieved_comp = stream.get_rpm_component("rpmcomponent")
            assert retrieved_comp
            assert retrieved_comp.props.name == "rpmcomponent"

            # Add a Module component to a stream
            mod_comp = Modulemd.ComponentModule(name="modulecomponent")
            stream.add_component(mod_comp)
            assert "modulecomponent" in stream.get_module_component_names()
            retrieved_comp = stream.get_module_component("modulecomponent")
            assert retrieved_comp
            assert retrieved_comp.props.name == "modulecomponent"

            # Remove an RPM component from a stream
            stream.remove_rpm_component("rpmcomponent")

            # Remove a Module component from a stream
            stream.remove_module_component("modulecomponent")
示例#5
0
 def add_component(self, package_name, build, chroot, rationale, buildorder=1):
     ref = str(chroot.git_hash) if chroot else ""
     distgit_url = self.config["DIST_GIT_URL"].replace("/cgit", "/git")
     url = os.path.join(distgit_url, build.copr.full_name, "{}.git".format(build.package.name))
     component = Modulemd.ComponentRpm(name=str(package_name), rationale=rationale,
                                       repository=url, ref=ref, buildorder=1)
     self.mmd.add_rpm_component(component)
示例#6
0
    def test_issue77(self):
        # This would crash on a type constraint accepting a signed value
        component = Modulemd.ComponentRpm(name="pkg1",
                                          rationale="Just because",
                                          buildorder=-1)
        assert component.props.buildorder == -1

        component.props.buildorder = -2
        assert component.get_buildorder() == -2

        component.set_buildorder(5)
        assert component.props.buildorder == 5