Merge lp://qastaging/~gmb/launchpad/dont-piss-the-losas-off-bug-596877 into lp://qastaging/launchpad/db-devel
Status: | Merged |
---|---|
Merged at revision: | 9700 |
Proposed branch: | lp://qastaging/~gmb/launchpad/dont-piss-the-losas-off-bug-596877 |
Merge into: | lp://qastaging/launchpad/db-devel |
Diff against target: |
656 lines (+299/-89) 12 files modified
lib/canonical/launchpad/security.py (+11/-0) lib/lp/bugs/browser/bugtracker.py (+24/-2) lib/lp/bugs/browser/tests/test_bugtracker_views.py (+29/-0) lib/lp/bugs/configure.zcml (+2/-1) lib/lp/bugs/doc/bugtracker.txt (+10/-60) lib/lp/bugs/interfaces/bugtracker.py (+5/-4) lib/lp/bugs/model/bugtracker.py (+13/-8) lib/lp/bugs/scripts/checkwatches/core.py (+2/-1) lib/lp/bugs/stories/bugtracker/xx-reschedule-all-watches.txt (+94/-0) lib/lp/bugs/tests/test_bugtracker.py (+97/-11) lib/lp/testing/factory.py (+3/-2) lib/lp/testing/sampledata.py (+9/-0) |
To merge this branch: | bzr merge lp://qastaging/~gmb/launchpad/dont-piss-the-losas-off-bug-596877 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella (community) | Approve | ||
Robert Collins (community) | Needs Information | ||
Review via email: mp+30186@code.qastaging.launchpad.net |
Commit message
A button, visible to admins and LP developers, has been added to the BugTracker +edit page to allow all of a tracker's watches to be rescheduled en masse.
Description of the change
A button to reschedule all watches
=======
This branch adds a button to the BugTracker +edit page which will
allow a user with sufficient privileges to reschedule all the watches on
a given BugTracker[1]. This is useful in situations where a bug tracker
has not been updated for a long period of time, so all the watches are
out of date. In the past we've done this by asking a LOSA to run some
SQL, but since that's a drain on their time and ours, a button seemed
more useful.
One of the problems associated with a large number of out-of-date
watches, however, is that checkwatches attempts to burn through them all
at once. This can lead to us adding a great deal of load to the remote
server, which is generally a Bad Thing and can get Launchpad blocked
from communicating with the upstream bug tracker (at the very least).
In order to obviate this problem, we have in the past used SQL that
would randomise the next_check time for each bug watch within a range of
up to twenty-four hours. This would then take some of the strain off the
remote server since checkwatches wouldn't be trying to update everything
as quickly as possible. It seemed sensible to use this same SQL when
creating the reschedule button. Note that 24 hours is the optimal
maximum time frame in which to schedule watches; anything longer means
that watches remain unchecked whilst other watches go out of date and
need to be checked again, potentially creating further load issues.
Finally, I cleaned up some lint in this branch, but I'm not wholly
certain that the new linter isn't getting some things wrong about our
coding standards.
Changes made
------------
lib/lp/
~~~~~~~
- I've added an exception, UserCannotReset
when a user attempts to all watches on a bug tracker without
permission.
- I've added a user_can_
This returns True if the user is either a Launchpad Admin or is a
member of ~launchpad.
- I've added a method, resetBugTracker
This calls BugTracker.
method so that it could be tested properly in view tests rather than
putting all the implementation in the body of the action.
- I've added a reschedule_
BugTrackerEd
reschedule and user_can_
determine whether the reschedule button shows up on the +edit page.
- I've added a rescheduleAction() method / action to
BugTrackerEd
info notification to the page stating that all watches have been
updated. Note that it makes no attempt to catch
UserCannotRe
the OOPS machinery as they are indicative of someone trying to craft
an HTTP POST to reschedule watches.
lib/lp/
~~~~~~~
- I've added tests to cover the resetBugTracker
BugTrackerEd
resetBugTrac
and that it also checks that the user is allowed to reset a bug
tracker's watches.
lib/lp/
~~~~~~~
- I've updated the ZCML and moved BugTracker.
launchpad.Admin section and into launchpad.Edit (hence the need for
stricter checking of permissions in
BugTrackerEd
to allow Launchpad Developers to reset watches.
lib/lp/
~~~~~~~
- I've updated the existing tests for BugTracker.
cover the new randomisation-
refactor the whole of bugtracker.txt into unittest format, but
decided against it for reasons of space and sanity.
- I've fixed a bunch of lint issues with the doctest.
lib/lp/
~~~~~~~
- I've updated BugTracker.
to a random time between now and one day in the future, rather than
just setting it to now as it used to.
- I've also fixed a minor typo.
lib/lp/
~~~~~~~
- This pagetest covers the Reschedule all watches button which will now
appear on the BugTracker +edit page when it is viewed by admins or LP
developers.
lib/lp/
~~~~~~~
- I updated makeBugTracker() so that it now accepts name and title
arguments.
lib/lp/
~~~~~~~
- I added constants for ADMIN_EMAIL (foo.bar@) and USER_EMAIL(test@).
Test commands
-------------
`bin/test -cvv -t /bugtracker.txt -t xx-reschedule-
-t test_bugtracker
Shouldn't the permission check be in the model? the LBYP idiom seems likely to miss things...