← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~twom/launchpad:oci-show-cancelled-builds-correctly into launchpad:master

 

Tom Wardill has proposed merging ~twom/launchpad:oci-show-cancelled-builds-correctly into launchpad:master.

Commit message:
Show CANCELLING builds as a failed Set correctly.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/407096
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:oci-show-cancelled-builds-correctly into launchpad:master.
diff --git a/lib/lp/oci/browser/tests/test_ocirecipe.py b/lib/lp/oci/browser/tests/test_ocirecipe.py
index 408c032..4a36517 100644
--- a/lib/lp/oci/browser/tests/test_ocirecipe.py
+++ b/lib/lp/oci/browser/tests/test_ocirecipe.py
@@ -1442,6 +1442,56 @@ class TestOCIRecipeView(BaseTestOCIRecipeView):
             "This OCI recipe contains Public information",
             extract_text(privacy_tag))
 
+    def test_index_cancelling_build(self):
+        oci_project = self.factory.makeOCIProject(
+            pillar=self.distroseries.distribution)
+        [ref] = self.factory.makeGitRefs(
+            owner=self.person, target=self.person, name="recipe-repository",
+            paths=["refs/heads/v1.0-20.04"])
+        recipe = self.makeRecipe(
+            processor_names=["amd64", "386"],
+            build_file="Dockerfile", git_ref=ref,
+            oci_project=oci_project, registrant=self.person, owner=self.person)
+        build_request = recipe.requestBuilds(self.person)
+        builds = recipe.requestBuildsFromJob(self.person, build_request)
+        job = removeSecurityProxy(build_request).job
+        removeSecurityProxy(job).builds = builds
+
+        for build in builds:
+            removeSecurityProxy(build).updateStatus(
+                    BuildStatus.BUILDING, builder=None,
+                    date_started=build.date_created)
+            removeSecurityProxy(build).updateStatus(
+                BuildStatus.CANCELLING, builder=None,
+                date_finished=build.date_started + timedelta(minutes=30))
+
+        browser = self.getViewBrowser(build_request.recipe)
+        login_person(self.person)
+        self.assertTextMatchesExpressionIgnoreWhitespace("""\
+            .*
+            There were build failures.
+            No registry upload requested.
+            a moment ago
+            in 30 minutes
+            \\(estimated\\)
+            amd64
+            Cancelling build
+            386
+            Cancelling build
+            amd64
+            386
+            in 30 minutes
+            \\(estimated\\)
+            .*
+            """,
+            extract_text(find_main_content(browser.contents)))
+
+        # Check portlet on side menu.
+        privacy_tag = find_tag_by_id(browser.contents, "privacy")
+        self.assertTextMatchesExpressionIgnoreWhitespace(
+            "This OCI recipe contains Public information",
+            extract_text(privacy_tag))
+
     def test_index_for_private_recipe_shows_banner(self):
         recipe = self.factory.makeOCIRecipe(
             registrant=self.person, owner=self.person,
diff --git a/lib/lp/oci/model/ocirecipe.py b/lib/lp/oci/model/ocirecipe.py
index 5e491a7..392455a 100644
--- a/lib/lp/oci/model/ocirecipe.py
+++ b/lib/lp/oci/model/ocirecipe.py
@@ -972,7 +972,8 @@ class OCIRecipeSet:
         building = collect_builds(BuildStatus.BUILDING,
                                   BuildStatus.UPLOADING)
         successful = collect_builds(BuildStatus.FULLYBUILT)
-        cancelled = collect_builds(BuildStatus.CANCELLED)
+        cancelled = collect_builds(BuildStatus.CANCELLING,
+                                   BuildStatus.CANCELLED)
 
         # Note: the BuildStatus DBItems are used here to summarize the
         # status of a set of builds:s