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

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: 1377be46fd645b65e6f1e72ad6e83ad2c722f4be
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: 110 lines (+80/-1)
2 files modified
lib/lp/oci/browser/tests/test_ocirecipe.py (+78/-0)
lib/lp/oci/model/ocirecipe.py (+2/-1)
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+407035@code.launchpad.net

Commit message

Show cancelled builds as failed in the buildset

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 913b849..408c032 100644
3--- a/lib/lp/oci/browser/tests/test_ocirecipe.py
4+++ b/lib/lp/oci/browser/tests/test_ocirecipe.py
5@@ -1364,6 +1364,84 @@ class TestOCIRecipeView(BaseTestOCIRecipeView):
6 "This OCI recipe contains Public information",
7 extract_text(privacy_tag))
8
9+ def test_index_cancelled_build(self):
10+ oci_project = self.factory.makeOCIProject(
11+ pillar=self.distroseries.distribution)
12+ oci_project_display = oci_project.display_name
13+ [ref] = self.factory.makeGitRefs(
14+ owner=self.person, target=self.person, name="recipe-repository",
15+ paths=["refs/heads/v1.0-20.04"])
16+ recipe = self.makeRecipe(
17+ processor_names=["amd64", "386"],
18+ build_file="Dockerfile", git_ref=ref,
19+ oci_project=oci_project, registrant=self.person, owner=self.person)
20+ build_request = recipe.requestBuilds(self.person)
21+ builds = recipe.requestBuildsFromJob(self.person, build_request)
22+ job = removeSecurityProxy(build_request).job
23+ removeSecurityProxy(job).builds = builds
24+
25+ for build in builds:
26+ removeSecurityProxy(build).updateStatus(
27+ BuildStatus.BUILDING, builder=None,
28+ date_started=build.date_created)
29+ removeSecurityProxy(build).updateStatus(
30+ BuildStatus.CANCELLED, builder=None,
31+ date_finished=build.date_started + timedelta(minutes=30))
32+
33+ # We also need to account for builds that don't have a build_request
34+ build = self.makeBuild(
35+ recipe=recipe, status=BuildStatus.FULLYBUILT,
36+ duration=timedelta(minutes=30))
37+
38+ browser = self.getViewBrowser(build_request.recipe)
39+ login_person(self.person)
40+ self.assertTextMatchesExpressionIgnoreWhitespace("""\
41+ .*
42+ OCI recipe information
43+ Owner: Test Person
44+ OCI project: %s
45+ Source: ~test-person/\\+git/recipe-repository:v1.0-20.04
46+ Build file path: Dockerfile
47+ Build context directory: %s
48+ Build schedule: Built on request
49+ Official recipe:
50+ No
51+ Latest builds
52+ Build status
53+ Upload status
54+ When requested
55+ When complete
56+ There were build failures.
57+ No registry upload requested.
58+ a moment ago
59+ in 29 minutes
60+ amd64
61+ Cancelled build
62+ 386
63+ Cancelled build
64+ amd64
65+ in 29 minutes
66+ 386
67+ in 29 minutes
68+ All builds were built successfully.
69+ No registry upload requested.
70+ 1 hour ago
71+ 30 minutes ago
72+ 386
73+ Successfully built
74+ 386
75+ 30 minutes ago
76+ Recipe push rules
77+ This OCI recipe has no push rules defined yet.
78+ """ % (oci_project_display, recipe.build_path),
79+ extract_text(find_main_content(browser.contents)))
80+
81+ # Check portlet on side menu.
82+ privacy_tag = find_tag_by_id(browser.contents, "privacy")
83+ self.assertTextMatchesExpressionIgnoreWhitespace(
84+ "This OCI recipe contains Public information",
85+ extract_text(privacy_tag))
86+
87 def test_index_for_private_recipe_shows_banner(self):
88 recipe = self.factory.makeOCIRecipe(
89 registrant=self.person, owner=self.person,
90diff --git a/lib/lp/oci/model/ocirecipe.py b/lib/lp/oci/model/ocirecipe.py
91index adab5b9..5e491a7 100644
92--- a/lib/lp/oci/model/ocirecipe.py
93+++ b/lib/lp/oci/model/ocirecipe.py
94@@ -972,6 +972,7 @@ class OCIRecipeSet:
95 building = collect_builds(BuildStatus.BUILDING,
96 BuildStatus.UPLOADING)
97 successful = collect_builds(BuildStatus.FULLYBUILT)
98+ cancelled = collect_builds(BuildStatus.CANCELLED)
99
100 # Note: the BuildStatus DBItems are used here to summarize the
101 # status of a set of builds:s
102@@ -987,7 +988,7 @@ class OCIRecipeSet:
103 'status': BuildSetStatus.NEEDSBUILD,
104 'builds': needsbuild,
105 }
106- elif len(failed) != 0:
107+ elif len(failed) != 0 or len(cancelled) != 0:
108 return {
109 'status': BuildSetStatus.FAILEDTOBUILD,
110 'builds': failed,

Subscribers

People subscribed via source and target branches

to status/vote changes: