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
=== modified file 'lib/lp/soyuz/browser/build.py'
--- lib/lp/soyuz/browser/build.py 2009-12-11 13:01:12 +0000
+++ lib/lp/soyuz/browser/build.py 2010-02-24 14:35:31 +0000
@@ -36,6 +36,7 @@
36from canonical.launchpad.webapp.batching import BatchNavigator36from canonical.launchpad.webapp.batching import BatchNavigator
37from canonical.launchpad.webapp.interfaces import ICanonicalUrlData37from canonical.launchpad.webapp.interfaces import ICanonicalUrlData
38from lazr.delegates import delegates38from lazr.delegates import delegates
39from lp.services.job.interfaces.job import JobStatus
3940
4041
41class BuildUrl:42class BuildUrl:
@@ -198,6 +199,18 @@
198199
199 return files200 return files
200201
202 @property
203 def dispatch_time_estimate_available(self):
204 """True if a dispatch time estimate is available for this build.
205
206 The build must be in state NEEDSBUILD and the associated job must be
207 in state WAITING.
208 """
209 return (
210 self.context.buildstate == BuildStatus.NEEDSBUILD and
211 self.context.buildqueue_record.job.status == JobStatus.WAITING)
212
213
201class BuildRetryView(BuildView):214class BuildRetryView(BuildView):
202 """View class for retrying `IBuild`s"""215 """View class for retrying `IBuild`s"""
203216
204217
=== modified file 'lib/lp/soyuz/browser/tests/build-views.txt'
--- lib/lp/soyuz/browser/tests/build-views.txt 2009-12-24 01:41:54 +0000
+++ lib/lp/soyuz/browser/tests/build-views.txt 2010-02-24 14:35:31 +0000
@@ -372,3 +372,27 @@
372 i386372 i386
373373
374374
375== Dispatch time estimates ==
376
377A dispatch time estimate is available for pending binary builds that have not
378been suspended.
379
380 >>> from lp.services.job.interfaces.job import JobStatus
381 >>> pending_build = ubuntu.getBuildRecords(
382 ... build_state=BuildStatus.NEEDSBUILD)[0]
383
384 >>> view = create_initialized_view(pending_build, name="+index")
385 >>> view.dispatch_time_estimate_available
386 True
387 >>> view.context.buildstate == BuildStatus.NEEDSBUILD
388 True
389 >>> view.context.buildqueue_record.job.status == JobStatus.WAITING
390 True
391
392If we suspend the binary build job, however, no estimate is available.
393
394 >>> view.context.buildqueue_record.job.suspend()
395 >>> view.context.buildqueue_record.job.status == JobStatus.SUSPENDED
396 True
397 >>> view.dispatch_time_estimate_available
398 False
375399
=== modified file 'lib/lp/soyuz/stories/soyuz/xx-build-record.txt'
--- lib/lp/soyuz/stories/soyuz/xx-build-record.txt 2010-01-11 23:43:59 +0000
+++ lib/lp/soyuz/stories/soyuz/xx-build-record.txt 2010-02-24 14:35:31 +0000
@@ -72,6 +72,30 @@
72 Pocket: Release72 Pocket: Release
73 Component: main73 Component: main
7474
75Let's disable the job associated with the build. This has the side effect
76that a dispatch time estimation will not be available for the build in
77question.
78
79 >>> build.buildqueue_record.job.suspend()
80 >>> anon_browser.open(build_url)
81 >>> print extract_text(find_main_content(anon_browser.contents))
82 i386 build of testing 1.0 in ubuntutest breezy-autotest RELEASE
83 ...
84 Build status
85 Needs building
86 Build details
87 Source: testing - 1.0
88 Archive: Primary Archive for Ubuntu Test
89 Series: Breezy Badger Autotest
90 Architecture: i386
91 Pocket: Release
92 Component: main
93
94Re-enable the build in order to avioid subsequent test breakage.
95
96 >>> build.buildqueue_record.job.resume()
97 >>> anon_browser.open(build_url)
98
75The 'Build details' section exists for all status and contains links99The 'Build details' section exists for all status and contains links
76to all the relevant entities involed in this build.100to all the relevant entities involed in this build.
77101
78102
=== modified file 'lib/lp/soyuz/templates/build-index.pt'
--- lib/lp/soyuz/templates/build-index.pt 2010-02-10 10:11:46 +0000
+++ lib/lp/soyuz/templates/build-index.pt 2010-02-24 14:35:31 +0000
@@ -146,7 +146,7 @@
146 Missing build dependencies: <em146 Missing build dependencies: <em
147 tal:content="context/dependencies">x, y, z</em>147 tal:content="context/dependencies">x, y, z</em>
148 </li>148 </li>
149 <tal:pending condition="context/buildstate/enumvalue:NEEDSBUILD">149 <tal:pending condition="view/dispatch_time_estimate_available">
150 <li tal:define="eta context/buildqueue_record/getEstimatedJobStartTime;">150 <li tal:define="eta context/buildqueue_record/getEstimatedJobStartTime;">
151 Start <tal:eta151 Start <tal:eta
152 replace="eta/fmt:approximatedate">in 3 hours</tal:eta>152 replace="eta/fmt:approximatedate">in 3 hours</tal:eta>