Merge lp:~al-maisan/launchpad/oops-526969 into lp:launchpad

Proposed by Muharem Hrnjadovic
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~al-maisan/launchpad/oops-526969
Merge into: lp:launchpad
Diff against target: 110 lines (+62/-1)
4 files modified
lib/lp/soyuz/browser/build.py (+13/-0)
lib/lp/soyuz/browser/tests/build-views.txt (+24/-0)
lib/lp/soyuz/stories/soyuz/xx-build-record.txt (+24/-0)
lib/lp/soyuz/templates/build-index.pt (+1/-1)
To merge this branch: bzr merge lp:~al-maisan/launchpad/oops-526969
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) code Approve
Review via email: mp+20056@code.launchpad.net

Commit message

Dispatch time estimations are only shown for pending builds that are *not* suspended.

To post a comment you must log in.
Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

Hello,

since the build farm was generalized the binary builds became somewhat
schizophrenic.
In order to figure out whether a dispatch time estimate is available for a
build we now need to look at

    Build.buildstate *and* Job.status

These need to carry the values BuildStatus.NEEDSBUILD and JobStatus.WAITING
respectively.

The branch at hand revises the main build template to do so.

Tests to run:

    bin/test --v -t build-views -t xx-build-record

No "make lint" changes or errors.

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Looks fine, and the TAL ends up cleaner as well. The new tests check for the effect of the Job's status; the other half of the check is covered by existing tests.

Land it.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/browser/build.py'
2--- lib/lp/soyuz/browser/build.py 2009-12-11 13:01:12 +0000
3+++ lib/lp/soyuz/browser/build.py 2010-02-24 14:35:31 +0000
4@@ -36,6 +36,7 @@
5 from canonical.launchpad.webapp.batching import BatchNavigator
6 from canonical.launchpad.webapp.interfaces import ICanonicalUrlData
7 from lazr.delegates import delegates
8+from lp.services.job.interfaces.job import JobStatus
9
10
11 class BuildUrl:
12@@ -198,6 +199,18 @@
13
14 return files
15
16+ @property
17+ def dispatch_time_estimate_available(self):
18+ """True if a dispatch time estimate is available for this build.
19+
20+ The build must be in state NEEDSBUILD and the associated job must be
21+ in state WAITING.
22+ """
23+ return (
24+ self.context.buildstate == BuildStatus.NEEDSBUILD and
25+ self.context.buildqueue_record.job.status == JobStatus.WAITING)
26+
27+
28 class BuildRetryView(BuildView):
29 """View class for retrying `IBuild`s"""
30
31
32=== modified file 'lib/lp/soyuz/browser/tests/build-views.txt'
33--- lib/lp/soyuz/browser/tests/build-views.txt 2009-12-24 01:41:54 +0000
34+++ lib/lp/soyuz/browser/tests/build-views.txt 2010-02-24 14:35:31 +0000
35@@ -372,3 +372,27 @@
36 i386
37
38
39+== Dispatch time estimates ==
40+
41+A dispatch time estimate is available for pending binary builds that have not
42+been suspended.
43+
44+ >>> from lp.services.job.interfaces.job import JobStatus
45+ >>> pending_build = ubuntu.getBuildRecords(
46+ ... build_state=BuildStatus.NEEDSBUILD)[0]
47+
48+ >>> view = create_initialized_view(pending_build, name="+index")
49+ >>> view.dispatch_time_estimate_available
50+ True
51+ >>> view.context.buildstate == BuildStatus.NEEDSBUILD
52+ True
53+ >>> view.context.buildqueue_record.job.status == JobStatus.WAITING
54+ True
55+
56+If we suspend the binary build job, however, no estimate is available.
57+
58+ >>> view.context.buildqueue_record.job.suspend()
59+ >>> view.context.buildqueue_record.job.status == JobStatus.SUSPENDED
60+ True
61+ >>> view.dispatch_time_estimate_available
62+ False
63
64=== modified file 'lib/lp/soyuz/stories/soyuz/xx-build-record.txt'
65--- lib/lp/soyuz/stories/soyuz/xx-build-record.txt 2010-01-11 23:43:59 +0000
66+++ lib/lp/soyuz/stories/soyuz/xx-build-record.txt 2010-02-24 14:35:31 +0000
67@@ -72,6 +72,30 @@
68 Pocket: Release
69 Component: main
70
71+Let's disable the job associated with the build. This has the side effect
72+that a dispatch time estimation will not be available for the build in
73+question.
74+
75+ >>> build.buildqueue_record.job.suspend()
76+ >>> anon_browser.open(build_url)
77+ >>> print extract_text(find_main_content(anon_browser.contents))
78+ i386 build of testing 1.0 in ubuntutest breezy-autotest RELEASE
79+ ...
80+ Build status
81+ Needs building
82+ Build details
83+ Source: testing - 1.0
84+ Archive: Primary Archive for Ubuntu Test
85+ Series: Breezy Badger Autotest
86+ Architecture: i386
87+ Pocket: Release
88+ Component: main
89+
90+Re-enable the build in order to avioid subsequent test breakage.
91+
92+ >>> build.buildqueue_record.job.resume()
93+ >>> anon_browser.open(build_url)
94+
95 The 'Build details' section exists for all status and contains links
96 to all the relevant entities involed in this build.
97
98
99=== modified file 'lib/lp/soyuz/templates/build-index.pt'
100--- lib/lp/soyuz/templates/build-index.pt 2010-02-10 10:11:46 +0000
101+++ lib/lp/soyuz/templates/build-index.pt 2010-02-24 14:35:31 +0000
102@@ -146,7 +146,7 @@
103 Missing build dependencies: <em
104 tal:content="context/dependencies">x, y, z</em>
105 </li>
106- <tal:pending condition="context/buildstate/enumvalue:NEEDSBUILD">
107+ <tal:pending condition="view/dispatch_time_estimate_available">
108 <li tal:define="eta context/buildqueue_record/getEstimatedJobStartTime;">
109 Start <tal:eta
110 replace="eta/fmt:approximatedate">in 3 hours</tal:eta>