Merge lp:~jtv/launchpad/bug-572497 into lp:launchpad

Proposed by Jeroen T. Vermeulen on 2010-04-30
Status: Merged
Approved by: Michael Hudson-Doyle on 2010-05-03
Approved revision: no longer in the source branch.
Merge reported by: Jeroen T. Vermeulen
Merged at revision: not available
Proposed branch: lp:~jtv/launchpad/bug-572497
Merge into: lp:launchpad
Diff against target: 139 lines (+30/-1)
2 files modified
database/schema/security.cfg (+1/-1)
lib/lp/translations/tests/test_translationbuildapprover.py (+29/-0)
To merge this branch: bzr merge lp:~jtv/launchpad/bug-572497
Reviewer Review Type Date Requested Status
Björn Tillenius (community) release-critical Approve on 2010-05-03
Michael Hudson-Doyle Approve on 2010-05-03
Canonical Launchpad Engineering code 2010-04-30 Pending
Review via email: mp+24514@code.launchpad.net

Commit Message

Allow "fiera" db user to approve translation templates.

Description of the Change

= Bug 572497 =

We've finally gotten the build farm (formerly Soyuz) to dispatch a translation templates build job to a build farm slave; the slave to check out a bzr branch, run intltool on it to generate templates, roll the templates into a tarball, and send it back to the master; and the master to receive the tarball, upload it to the translations import queue, and attempt to approve the resulting entries.

That's where we ran into a database privilege problem—the database user in question is not allowed to read POTemplate. This is a newer addition: the uploads also go straight into approval, which requires read access to some extra tables.

Luckily we have a dedicated database group containing all the permissions needed for this (and a few more, but nothing that could possibly hurt).

I still need tests for this, so am filing this as Work In Progress for now. I can't invoke the build farm from the test suite, so it won't be too realistic. But I can add a unit test that runs the approval code we use here under the fiera database user.

To Q/A, go through the steps in https://dev.launchpad.net/Translations/GenerateTemplatesOnTestServers and verify that (1) the templates get generated and uploaded and make it into approval; and (2) don't strand there with a permissions error (see /srv/launchpad.net/dogfood-logs/buildd-manager.log). If all is well, your templates should appear in your productseries' translations import queue.

Jeroen

To post a comment you must log in.
Jeroen T. Vermeulen (jtv) wrote :

Okay, I've updated the test to run as the real database user. This reproduces the problem, and "make schema" then fixes the test.

Michael Hudson-Doyle (mwhudson) wrote :

Looks fine to me.

review: Approve
Björn Tillenius (bjornt) :
review: Approve (release-critical)

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-04-21 19:41:18 +0000
3+++ database/schema/security.cfg 2010-05-03 04:46:27 +0000
4@@ -818,7 +818,7 @@
5
6 [fiera]
7 type=user
8-groups=script
9+groups=script,translations_approval
10 public.account = SELECT
11 public.archive = SELECT, UPDATE
12 public.archivearch = SELECT, UPDATE
13
14=== modified file 'lib/lp/translations/tests/test_translationbuildapprover.py'
15--- lib/lp/translations/tests/test_translationbuildapprover.py 2010-04-12 16:05:17 +0000
16+++ lib/lp/translations/tests/test_translationbuildapprover.py 2010-05-03 04:46:27 +0000
17@@ -5,10 +5,12 @@
18
19 __metaclass__ = type
20
21+import transaction
22 from unittest import TestLoader
23
24 from zope.component import getUtility
25
26+from canonical.config import config
27 from canonical.testing import LaunchpadZopelessLayer
28 from lp.translations.interfaces.translationimportqueue import (
29 ITranslationImportQueue, RosettaImportStatus)
30@@ -33,6 +35,11 @@
31 productseries=series))
32 for path in filenames]
33
34+ def _becomeBuilddMaster(self):
35+ """Switch db identity to the script that uses this approver."""
36+ transaction.commit()
37+ self.layer.switchDbUser(config.builddmaster.dbuser)
38+
39 def test_approve_all_new(self):
40 # A happy approval case, all new templates.
41 filenames = [
42@@ -41,6 +48,8 @@
43 'po-domain3/domain3.pot',
44 ]
45 series = self.factory.makeProductSeries()
46+
47+ self._becomeBuilddMaster()
48 approver = TranslationBuildApprover(filenames, productseries=series)
49 entries = self._makeApprovedEntries(series, approver, filenames)
50
51@@ -58,6 +67,8 @@
52 'po/eo.po',
53 ]
54 series = self.factory.makeProductSeries()
55+
56+ self._becomeBuilddMaster()
57 approver = TranslationBuildApprover(filenames, productseries=series)
58 entries = self._makeApprovedEntries(series, approver, filenames)
59
60@@ -79,6 +90,8 @@
61 productseries=series, name='domain2')
62 domain3_pot = self.factory.makePOTemplate(
63 productseries=series, name='domain3')
64+
65+ self._becomeBuilddMaster()
66 approver = TranslationBuildApprover(filenames, productseries=series)
67 entries = self._makeApprovedEntries(series, approver, filenames)
68
69@@ -102,6 +115,8 @@
70 productseries=series, name='domain1')
71 domain2_pot = self.factory.makePOTemplate(
72 productseries=series, name='domain2')
73+
74+ self._becomeBuilddMaster()
75 approver = TranslationBuildApprover(filenames, productseries=series)
76 entries = self._makeApprovedEntries(series, approver, filenames)
77
78@@ -120,6 +135,8 @@
79 ]
80 product = self.factory.makeProduct(name='fooproduct')
81 series = product.getSeries('trunk')
82+
83+ self._becomeBuilddMaster()
84 approver = TranslationBuildApprover(filenames, productseries=series)
85 entries = self._makeApprovedEntries(series, approver, filenames)
86
87@@ -133,6 +150,8 @@
88 ]
89 series = self.factory.makeProductSeries()
90 pot = self.factory.makePOTemplate(productseries=series)
91+
92+ self._becomeBuilddMaster()
93 approver = TranslationBuildApprover(filenames, productseries=series)
94 entries = self._makeApprovedEntries(series, approver, filenames)
95
96@@ -146,6 +165,8 @@
97 'mydomain/mydomain.pot',
98 ]
99 series = self.factory.makeProductSeries()
100+
101+ self._becomeBuilddMaster()
102 approver = TranslationBuildApprover(filenames, productseries=series)
103 entries = self._makeApprovedEntries(series, approver, filenames)
104
105@@ -162,6 +183,8 @@
106 series = self.factory.makeProductSeries()
107 self.factory.makePOTemplate(productseries=series)
108 self.factory.makePOTemplate(productseries=series)
109+
110+ self._becomeBuilddMaster()
111 approver = TranslationBuildApprover(filenames, productseries=series)
112 entries = self._makeApprovedEntries(series, approver, filenames)
113
114@@ -174,6 +197,8 @@
115 'po-domain2/domain2.pot',
116 ]
117 series = self.factory.makeProductSeries()
118+
119+ self._becomeBuilddMaster()
120 approver = TranslationBuildApprover(filenames, productseries=series)
121 entries = self._makeApprovedEntries(
122 series, approver, filenames + ['po-domain3/domain3.pot'])
123@@ -196,6 +221,8 @@
124 productseries=series, name='name1', path=filenames[0])
125 domain2_pot = self.factory.makePOTemplate(
126 productseries=series, name='name2', path=filenames[1])
127+
128+ self._becomeBuilddMaster()
129 approver = TranslationBuildApprover(filenames, productseries=series)
130 entries = self._makeApprovedEntries(series, approver, filenames)
131
132@@ -215,6 +242,8 @@
133 series = self.factory.makeProductSeries()
134 domain1_pot = self.factory.makePOTemplate(
135 productseries=series, name='domain1', path='po/foo.pot')
136+
137+ self._becomeBuilddMaster()
138 approver = TranslationBuildApprover(filenames, productseries=series)
139 entries = self._makeApprovedEntries(series, approver, filenames)
140