← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] ~ruinedyourlife/launchpad:requesting-subset-of-arch-craft-builds into launchpad:master

 


Diff comments:

> diff --git a/lib/lp/crafts/tests/test_craftrecipe.py b/lib/lp/crafts/tests/test_craftrecipe.py
> index eac12e9..aaa2316 100644
> --- a/lib/lp/crafts/tests/test_craftrecipe.py
> +++ b/lib/lp/crafts/tests/test_craftrecipe.py
> @@ -1497,6 +1497,130 @@ class TestCraftRecipeWebservice(TestCaseWithFactory):
>              ),
>          )
>  
> +    def test_requestBuilds_with_architectures(self):
> +        # when a subset of architectures are requested, we only build them
> +        # not all listed in the sourcecraft.yaml file
> +        distroseries = self.factory.makeDistroSeries(
> +            distribution=getUtility(ILaunchpadCelebrities).ubuntu,
> +            registrant=self.person,
> +        )
> +        amd640 = self.factory.makeProcessor(
> +            name="amd640", supports_virtualized=True
> +        )
> +        risc500 = self.factory.makeProcessor(
> +            name="risc500", supports_virtualized=True
> +        )
> +        s400x = self.factory.makeProcessor(
> +            name="s400x", supports_virtualized=True
> +        )
> +        processors = [amd640, risc500, s400x]
> +        for processor in processors:
> +            self.makeBuildableDistroArchSeries(
> +                distroseries=distroseries,
> +                architecturetag=processor.name,
> +                processor=processor,
> +                owner=self.person,
> +            )
> +        [git_ref] = self.factory.makeGitRefs()
> +        recipe = self.makeCraftRecipe(git_ref=git_ref)
> +        now = get_transaction_timestamp(IStore(distroseries))
> +        # api_base = "http://api.launchpad.test/devel";

Is it a debug comment that has to be removed?

> +        # amd640_api_url = api_base  api_url(amd640)
> +        response = self.webservice.named_post(
> +            recipe["self_link"],
> +            "requestBuilds",
> +            channels={"sourcecraft": "edge"},
> +            architectures=[api_url(amd640), api_url(risc500)],
> +        )
> +        self.assertEqual(201, response.status)
> +        build_request_url = response.getHeader("Location")
> +        build_request = self.webservice.get(build_request_url).jsonBody()
> +        self.assertThat(
> +            build_request,
> +            ContainsDict(
> +                {
> +                    "date_requested": AfterPreprocessing(
> +                        iso8601.parse_date, GreaterThan(now)
> +                    ),
> +                    "date_finished": Is(None),
> +                    "recipe_link": Equals(recipe["self_link"]),
> +                    "status": Equals("Pending"),
> +                    "error_message": Is(None),
> +                    "builds_collection_link": Equals(
> +                        build_request_url + "/builds"
> +                    ),
> +                }
> +            ),
> +        )
> +        self.assertEqual([], self.getCollectionLinks(build_request, "builds"))
> +        with person_logged_in(self.person):
> +            sourcecraft_yaml = f"""
> +                name: ruff
> +                license: MIT
> +                version: 0.4.9
> +                summary: An extremely fast Python linter, written in Rust.
> +                description: Ruff aims to be orders of magnitude faster...
> +                base: ubuntu@{distroseries.version}
> +                platforms:
> +                """
> +            for processor in processors:
> +                sourcecraft_yaml += f"""
> +                    {processor.name}:
> +                        build-on: [{processor.name}]
> +                        build-for: {processor.name}
> +                    """
> +            self.useFixture(GitHostingFixture(blob=sourcecraft_yaml))
> +            [job] = getUtility(ICraftRecipeRequestBuildsJobSource).iterReady()
> +            with dbuser(config.ICraftRecipeRequestBuildsJobSource.dbuser):
> +                JobRunner([job]).runAll()
> +        date_requested = iso8601.parse_date(build_request["date_requested"])
> +        now = get_transaction_timestamp(IStore(distroseries))
> +        build_request = self.webservice.get(
> +            build_request["self_link"]
> +        ).jsonBody()
> +        self.assertThat(
> +            build_request,
> +            ContainsDict(
> +                {
> +                    "date_requested": AfterPreprocessing(
> +                        iso8601.parse_date, Equals(date_requested)
> +                    ),
> +                    "date_finished": AfterPreprocessing(
> +                        iso8601.parse_date,
> +                        MatchesAll(GreaterThan(date_requested), LessThan(now)),
> +                    ),
> +                    "recipe_link": Equals(recipe["self_link"]),
> +                    "status": Equals("Completed"),
> +                    "error_message": Is(None),
> +                    "builds_collection_link": Equals(
> +                        build_request_url + "/builds"
> +                    ),
> +                }
> +            ),
> +        )
> +        builds = self.webservice.get(
> +            build_request["builds_collection_link"]
> +        ).jsonBody()["entries"]
> +        with person_logged_in(self.person):
> +            self.assertThat(
> +                builds,
> +                MatchesSetwise(
> +                    *(
> +                        ContainsDict(
> +                            {
> +                                "recipe_link": Equals(recipe["self_link"]),
> +                                "archive_link": Equals(
> +                                    self.getURL(distroseries.main_archive)
> +                                ),
> +                                "arch_tag": Equals(processor.name),
> +                                "channels": Equals({"sourcecraft": "edge"}),
> +                            }
> +                        )
> +                        for processor in (amd640, risc500)  # requested arches
> +                    )
> +                ),
> +            )
> +
>      def test_getBuilds(self):
>          # The builds, completed_builds, and pending_builds properties are as
>          # expected.


-- 
https://code.launchpad.net/~ruinedyourlife/launchpad/+git/launchpad/+merge/474360
Your team Launchpad code reviewers is requested to review the proposed merge of ~ruinedyourlife/launchpad:requesting-subset-of-arch-craft-builds into launchpad:master.



References