Merge lp:~thumper/launchpad/fix-upgrade-branch-failure into lp:launchpad

Proposed by Tim Penhey
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 11251
Proposed branch: lp:~thumper/launchpad/fix-upgrade-branch-failure
Merge into: lp:launchpad
Diff against target: 58 lines (+14/-2)
2 files modified
database/schema/security.cfg (+2/-2)
lib/lp/code/model/tests/test_branchjob.py (+12/-0)
To merge this branch: bzr merge lp:~thumper/launchpad/fix-upgrade-branch-failure
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+31114@code.launchpad.net

Commit message

Add insert permissions for the job and branch job table so upgrade jobs can create scan jobs if needed.

Description of the change

Recently the upgrade job code was updated to use the branchChanged method call rather than requestMirror.

This works in all cases, except where someone pushes a new revision to the branch while the upgrade is happening. If this happens, a scan job will be created as part of the branchChanged call. This then results in a new job and branchjob row, so we need to add insert permissions for those two tables.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

it looks ok except on line 45 you have 2 lines of VWS, in a class only one line between methods please

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'database/schema/security.cfg'
2--- database/schema/security.cfg 2010-07-27 05:04:59 +0000
3+++ database/schema/security.cfg 2010-07-28 03:44:50 +0000
4@@ -1707,8 +1707,8 @@
5 type=user
6 groups=script
7 public.branch = SELECT, UPDATE
8-public.branchjob = SELECT
9-public.job = SELECT, UPDATE
10+public.branchjob = SELECT, INSERT
11+public.job = SELECT, INSERT, UPDATE
12
13 [send-branch-mail]
14 type=user
15
16=== modified file 'lib/lp/code/model/tests/test_branchjob.py'
17--- lib/lp/code/model/tests/test_branchjob.py 2010-06-11 03:52:02 +0000
18+++ lib/lp/code/model/tests/test_branchjob.py 2010-07-28 03:44:50 +0000
19@@ -20,6 +20,7 @@
20 from bzrlib.transport import get_transport
21 from canonical.testing import DatabaseFunctionalLayer, LaunchpadZopelessLayer
22 from sqlobject import SQLObjectNotFound
23+from storm.locals import Store
24 import transaction
25 from zope.component import getUtility
26 from zope.security.proxy import removeSecurityProxy
27@@ -258,6 +259,7 @@
28 'Bazaar-NG Knit Repository Format 1')
29
30 job = BranchUpgradeJob.create(db_branch)
31+ self.becomeDbUser(config.upgrade_branches.dbuser)
32 job.run()
33 new_branch = Branch.open(tree.branch.base)
34 self.assertEqual(
35@@ -289,6 +291,7 @@
36 source_branch_transport.clone('backup.bzr'))
37
38 job = BranchUpgradeJob.create(db_branch)
39+ self.becomeDbUser(config.upgrade_branches.dbuser)
40 job.run()
41
42 new_branch = Branch.open(tree.branch.base)
43@@ -296,6 +299,15 @@
44 new_branch.repository._format.get_format_string(),
45 'Bazaar repository format 2a (needs bzr 1.16 or later)\n')
46
47+ def test_db_user_can_request_scan(self):
48+ # The database user that does the upgrade needs to be able to request
49+ # a scan of the branch.
50+ branch = self.factory.makeAnyBranch()
51+ self.becomeDbUser(config.upgrade_branches.dbuser)
52+ # Scan jobs are created by the branchChanged method.
53+ branch.branchChanged('', 'new-id', None, None, None)
54+ Store.of(branch).flush()
55+
56
57 class TestRevisionMailJob(TestCaseWithFactory):
58 """Tests for BranchDiffJob."""