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

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: 1118e9fda5545306cfd189064dcfa7a67264b61c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~twom/launchpad:oci-show-cancelled-builds-correctly
Merge into: launchpad:master
Diff against target: 75 lines (+52/-1)
2 files modified
lib/lp/oci/browser/tests/test_ocirecipe.py (+50/-0)
lib/lp/oci/model/ocirecipe.py (+2/-1)
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+407096@code.launchpad.net

Commit message

Show CANCELLING builds as a failed Set correctly.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/oci/browser/tests/test_ocirecipe.py b/lib/lp/oci/browser/tests/test_ocirecipe.py
2index 408c032..4a36517 100644
3--- a/lib/lp/oci/browser/tests/test_ocirecipe.py
4+++ b/lib/lp/oci/browser/tests/test_ocirecipe.py
5@@ -1442,6 +1442,56 @@ class TestOCIRecipeView(BaseTestOCIRecipeView):
6 "This OCI recipe contains Public information",
7 extract_text(privacy_tag))
8
9+ def test_index_cancelling_build(self):
10+ oci_project = self.factory.makeOCIProject(
11+ pillar=self.distroseries.distribution)
12+ [ref] = self.factory.makeGitRefs(
13+ owner=self.person, target=self.person, name="recipe-repository",
14+ paths=["refs/heads/v1.0-20.04"])
15+ recipe = self.makeRecipe(
16+ processor_names=["amd64", "386"],
17+ build_file="Dockerfile", git_ref=ref,
18+ oci_project=oci_project, registrant=self.person, owner=self.person)
19+ build_request = recipe.requestBuilds(self.person)
20+ builds = recipe.requestBuildsFromJob(self.person, build_request)
21+ job = removeSecurityProxy(build_request).job
22+ removeSecurityProxy(job).builds = builds
23+
24+ for build in builds:
25+ removeSecurityProxy(build).updateStatus(
26+ BuildStatus.BUILDING, builder=None,
27+ date_started=build.date_created)
28+ removeSecurityProxy(build).updateStatus(
29+ BuildStatus.CANCELLING, builder=None,
30+ date_finished=build.date_started + timedelta(minutes=30))
31+
32+ browser = self.getViewBrowser(build_request.recipe)
33+ login_person(self.person)
34+ self.assertTextMatchesExpressionIgnoreWhitespace("""\
35+ .*
36+ There were build failures.
37+ No registry upload requested.
38+ a moment ago
39+ in 30 minutes
40+ \\(estimated\\)
41+ amd64
42+ Cancelling build
43+ 386
44+ Cancelling build
45+ amd64
46+ 386
47+ in 30 minutes
48+ \\(estimated\\)
49+ .*
50+ """,
51+ extract_text(find_main_content(browser.contents)))
52+
53+ # Check portlet on side menu.
54+ privacy_tag = find_tag_by_id(browser.contents, "privacy")
55+ self.assertTextMatchesExpressionIgnoreWhitespace(
56+ "This OCI recipe contains Public information",
57+ extract_text(privacy_tag))
58+
59 def test_index_for_private_recipe_shows_banner(self):
60 recipe = self.factory.makeOCIRecipe(
61 registrant=self.person, owner=self.person,
62diff --git a/lib/lp/oci/model/ocirecipe.py b/lib/lp/oci/model/ocirecipe.py
63index 5e491a7..392455a 100644
64--- a/lib/lp/oci/model/ocirecipe.py
65+++ b/lib/lp/oci/model/ocirecipe.py
66@@ -972,7 +972,8 @@ class OCIRecipeSet:
67 building = collect_builds(BuildStatus.BUILDING,
68 BuildStatus.UPLOADING)
69 successful = collect_builds(BuildStatus.FULLYBUILT)
70- cancelled = collect_builds(BuildStatus.CANCELLED)
71+ cancelled = collect_builds(BuildStatus.CANCELLING,
72+ BuildStatus.CANCELLED)
73
74 # Note: the BuildStatus DBItems are used here to summarize the
75 # status of a set of builds:s

Subscribers

People subscribed via source and target branches

to status/vote changes: