launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04823
[Merge] lp:~bac/launchpad/bug-836932 into lp:launchpad
Brad Crittenden has proposed merging lp:~bac/launchpad/bug-836932 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #836932 in Launchpad itself: "daily build recipe exceeded quota and logged an OOPS"
https://bugs.launchpad.net/launchpad/+bug/836932
For more details, see:
https://code.launchpad.net/~bac/launchpad/bug-836932/+merge/73435
= Summary =
The TooManyBuilds exception was not caught and caused an OOPS.
== Proposed fix ==
Catch the exception and show an error to the user.
== Pre-implementation notes ==
None.
== Implementation details ==
As above.
== Tests ==
bin/test -vvt test_request_daily_builds_action_over_quota
== Demo and Q/A ==
QA may be a problem. I'll update the MP with a QA plan before landing.
= Launchpad lint =
I'll fix these lint issues after review so it doesn't get cluttered.
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/code/browser/sourcepackagerecipe.py
lib/lp/code/browser/tests/test_sourcepackagerecipe.py
./lib/lp/code/browser/tests/test_sourcepackagerecipe.py
237: Line exceeds 78 characters.
482: Line exceeds 78 characters.
1100: Line exceeds 78 characters.
1130: Line exceeds 78 characters.
1152: Line exceeds 78 characters.
1165: Line exceeds 78 characters.
482: E501 line too long (80 characters)
594: E225 missing whitespace around operator
1041: E225 missing whitespace around operator
1100: E501 line too long (85 characters)
1130: E501 line too long (85 characters)
1165: E501 line too long (85 characters)
--
https://code.launchpad.net/~bac/launchpad/bug-836932/+merge/73435
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~bac/launchpad/bug-836932 into lp:launchpad.
=== modified file 'lib/lp/code/browser/sourcepackagerecipe.py'
--- lib/lp/code/browser/sourcepackagerecipe.py 2011-07-15 03:13:14 +0000
+++ lib/lp/code/browser/sourcepackagerecipe.py 2011-08-30 20:18:25 +0000
@@ -99,6 +99,7 @@
BuildAlreadyPending,
NoSuchBranch,
PrivateBranchRecipe,
+ TooManyBuilds,
TooNewRecipeFormat,
)
from lp.code.interfaces.branchtarget import IBranchTarget
@@ -135,7 +136,7 @@
class SourcePackageRecipeHierarchy(Hierarchy):
- """"Hierarchy for Source Package Recipe."""
+ """Hierarchy for Source Package Recipe."""
vhost_breadcrumb = False
@@ -541,7 +542,13 @@
@action('Build now', name='build')
def build_action(self, action, data):
recipe = self.context
- builds = recipe.performDailyBuild()
+ try:
+ builds = recipe.performDailyBuild()
+ except TooManyBuilds, e:
+ self.request.response.addErrorNotification(str(e))
+ self.next_url = canonical_url(recipe)
+ return
+
if self.request.is_ajax:
template = ViewPageTemplateFile(
"../templates/sourcepackagerecipe-builds.pt")
=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2011-07-08 15:01:37 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2011-08-30 20:18:25 +0000
@@ -23,6 +23,7 @@
from zope.security.proxy import removeSecurityProxy
from canonical.database.constants import UTC_NOW
+from canonical.launchpad.ftests import LaunchpadFormHarness
from canonical.launchpad.testing.pages import (
extract_text,
find_main_content,
@@ -43,6 +44,7 @@
from lp.code.browser.sourcepackagerecipe import (
SourcePackageRecipeEditView,
SourcePackageRecipeRequestBuildsView,
+ SourcePackageRecipeRequestDailyBuildView,
SourcePackageRecipeView,
)
from lp.code.browser.sourcepackagerecipebuild import (
@@ -1338,6 +1340,24 @@
set([2505]),
set(build.buildqueue_record.lastscore for build in builds))
+ def test_request_daily_builds_action_over_quota(self):
+ recipe = self.factory.makeSourcePackageRecipe(
+ owner=self.chef, daily_build_archive=self.ppa,
+ name=u'julia', is_stale=True, build_daily=True)
+ # Create some previous builds.
+ series = list(recipe.distroseries)[0]
+ for x in xrange(5):
+ build = recipe.requestBuild(
+ self.ppa, self.chef, series, PackagePublishingPocket.RELEASE)
+ removeSecurityProxy(build).status = BuildStatus.FULLYBUILT
+ harness = LaunchpadFormHarness(
+ recipe, SourcePackageRecipeRequestDailyBuildView)
+ harness.submit('build', {})
+ self.assertEqual(
+ 'You have exceeded your quota for recipe chef/julia '
+ 'for distroseries ubuntu warty',
+ harness.view.request.notifications[0].message)
+
def test_request_builds_page(self):
"""Ensure the +request-builds page is sane."""
recipe = self.makeRecipe()