Merge lp:~jtv/launchpad/bug-435699 into lp:launchpad/db-devel

Proposed by Jeroen T. Vermeulen
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jtv/launchpad/bug-435699
Merge into: lp:launchpad/db-devel
Diff against target: 82 lines
2 files modified
lib/lp/translations/model/potemplate.py (+4/-0)
lib/lp/translations/tests/test_autoapproval.py (+32/-8)
To merge this branch: bzr merge lp:~jtv/launchpad/bug-435699
Reviewer Review Type Date Requested Status
Brad Crittenden (community) release-critical Approve
Michael Nelson (community) code Approve
Review via email: mp+12338@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

= Bug 435699 =

To fix crashes in the translations auto-approver last cycle, I rewrote
POTemplateSet.getPOTemplateByPathAndOrigin. Where the old version would
crash if multiple templates matched (which happened rarely, fortunately)
the new version detected the condition and logged it.

Now, post-rollout, I find that it logs far too much. As it turns out,
the new version forgets to match on distroseries, so any template that
exists unchanged between Ubuntu releases will seem to have multiple
matches!

This branch fixes that. A test broke in the process, but that seems to
be from using a fixed name for a package, and then not _passing_ the
distroseries argument to getPOTemplateByPathAndOrigin. To stay faithful
to the known interface, which does not require the distroseries argument
(even if it's probably always given in practice), I fixed it by using a
unique name for the package.

What I test for is not the logging, but the more serious consequence of
the condition that's beeing seen (and logged) where it isn't supposed to
be: multiple matches mean that templates are not found, and so uploads
are not approved.

Test:
{{{
./bin/test test_autoapproval
}}}

No lint.

Jeroen

Revision history for this message
Michael Nelson (michael.nelson) wrote :
Download full text (6.0 KiB)

Hi Jeroen,

r=me

Thanks for the details in the MP!

> = Bug 435699 =
>
> To fix crashes in the translations auto-approver last cycle, I rewrote
> POTemplateSet.getPOTemplateByPathAndOrigin. Where the old version would
> crash if multiple templates matched (which happened rarely, fortunately)
> the new version detected the condition and logged it.
>
> Now, post-rollout, I find that it logs far too much. As it turns out,
> the new version forgets to match on distroseries, so any template that
> exists unchanged between Ubuntu releases will seem to have multiple
> matches!

OK - at first I thought - why's this an rc? But yes, with the info in your
last para - it makes more sense!

>
> This branch fixes that. A test broke in the process, but that seems to
> be from using a fixed name for a package, and then not _passing_ the
> distroseries argument to getPOTemplateByPathAndOrigin. To stay faithful
> to the known interface, which does not require the distroseries argument
> (even if it's probably always given in practice), I fixed it by using a
> unique name for the package.
>
> What I test for is not the logging, but the more serious consequence of
> the condition that's beeing seen (and logged) where it isn't supposed to
> be: multiple matches mean that templates are not found, and so uploads
> are not approved.
>
> Test:
> {{{
> ./bin/test test_autoapproval
> }}}
>
> No lint.
>
>
> Jeroen

> === modified file 'lib/lp/translations/model/potemplate.py'
> --- lib/lp/translations/model/potemplate.py 2009-09-17 04:51:07 +0000
> +++ lib/lp/translations/model/potemplate.py 2009-09-24 09:48:24 +0000
> @@ -1225,6 +1225,10 @@
> POTemplate.from_sourcepackagename == sourcepackagename,
> POTemplate.sourcepackagename == sourcepackagename))
>
> + if distroseries:
> + conditions = And(
> + conditions, POTemplate.distroseries == distroseries)
> +

You probably already know, but just in case, another way to do this
is to use a list of extra expressions and just append to it (rather than
wrapping further conditions in And exprs (for eg., Archive.getBuildCounters()).

> store = IStore(POTemplate)
> matches = helpers.shortlist(store.find(POTemplate, conditions))
>
>
> === modified file 'lib/lp/translations/tests/test_autoapproval.py'
> --- lib/lp/translations/tests/test_autoapproval.py 2009-09-15 05:25:13 +0000
> +++ lib/lp/translations/tests/test_autoapproval.py 2009-09-24 09:48:24 +0000
> @@ -272,6 +272,12 @@
> self.producttemplate2 = product_subset.new(
> 'test2', 'test2', 'test.pot', self.product.owner)
>
> + def _makeTemplateForDistroSeries(self, distroseries, name):
> + """Create a template in the given `DistroSeries`."""
> + distro_subset = POTemplateSubset(
> + distroseries=distroseries, sourcepackagename=self.packagename)
> + return distro_subset.new(name, name, 'test.pot', self.distro.owner)
> +

Great.

> def _setUpDistro(self):
> """Set up a `Distribution` with two templates."""
> self.distro = self.factory.makeDistribution()
> @@ -279,13 +285,10 @@
> distri...

Read more...

review: Approve (code)
Revision history for this message
Brad Crittenden (bac) :
review: Approve (release-critical)
Revision history for this message
Brad Crittenden (bac) wrote :

Please add the additional comments as we discussed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/model/potemplate.py'
2--- lib/lp/translations/model/potemplate.py 2009-09-17 04:51:07 +0000
3+++ lib/lp/translations/model/potemplate.py 2009-09-24 15:05:26 +0000
4@@ -1225,6 +1225,10 @@
5 POTemplate.from_sourcepackagename == sourcepackagename,
6 POTemplate.sourcepackagename == sourcepackagename))
7
8+ if distroseries:
9+ conditions = And(
10+ conditions, POTemplate.distroseries == distroseries)
11+
12 store = IStore(POTemplate)
13 matches = helpers.shortlist(store.find(POTemplate, conditions))
14
15
16=== modified file 'lib/lp/translations/tests/test_autoapproval.py'
17--- lib/lp/translations/tests/test_autoapproval.py 2009-09-15 05:25:13 +0000
18+++ lib/lp/translations/tests/test_autoapproval.py 2009-09-24 15:05:26 +0000
19@@ -272,6 +272,12 @@
20 self.producttemplate2 = product_subset.new(
21 'test2', 'test2', 'test.pot', self.product.owner)
22
23+ def _makeTemplateForDistroSeries(self, distroseries, name):
24+ """Create a template in the given `DistroSeries`."""
25+ distro_subset = POTemplateSubset(
26+ distroseries=distroseries, sourcepackagename=self.packagename)
27+ return distro_subset.new(name, name, 'test.pot', self.distro.owner)
28+
29 def _setUpDistro(self):
30 """Set up a `Distribution` with two templates."""
31 self.distro = self.factory.makeDistribution()
32@@ -279,13 +285,10 @@
33 distribution=self.distro)
34 self.packagename = SourcePackageNameSet().new('package')
35 self.from_packagename = SourcePackageNameSet().new('from')
36- distro_subset = POTemplateSubset(
37- distroseries=self.distroseries,
38- sourcepackagename=self.packagename)
39- self.distrotemplate1 = distro_subset.new(
40- 'test1', 'test1', 'test.pot', self.distro.owner)
41- self.distrotemplate2 = distro_subset.new(
42- 'test2', 'test2', 'test.pot', self.distro.owner)
43+ self.distrotemplate1 = self._makeTemplateForDistroSeries(
44+ self.distroseries, 'test1')
45+ self.distrotemplate2 = self._makeTemplateForDistroSeries(
46+ self.distroseries, 'test2')
47
48 def test_ByPathAndOrigin_product_duplicate(self):
49 # When multiple templates match for a product series,
50@@ -311,11 +314,32 @@
51 'test.pot', sourcepackagename=self.from_packagename)
52 self.assertEqual(None, guessed_template)
53
54+ def test_ByPathAndOrigin_similar_between_distroseries(self):
55+ # getPOTemplateByPathAndOrigin disregards templates from other
56+ # distroseries.
57+ self._setUpDistro()
58+ other_series = self.factory.makeDistroRelease(
59+ distribution=self.distro)
60+ other_template = self._makeTemplateForDistroSeries(
61+ other_series, 'test1')
62+ self.distrotemplate1.iscurrent = False
63+ self.distrotemplate2.iscurrent = True
64+ self.distrotemplate1.from_sourcepackagename = None
65+ self.distrotemplate2.from_sourcepackagename = None
66+ guessed_template = self.templateset.getPOTemplateByPathAndOrigin(
67+ 'test.pot', distroseries=self.distroseries,
68+ sourcepackagename=self.packagename)
69+ self.assertEqual(self.distrotemplate2, guessed_template)
70+
71 def test_ByPathAndOrigin_preferred_match(self):
72 # getPOTemplateByPathAndOrigin prefers from_sourcepackagename
73 # matches over sourcepackagename matches.
74 self._setUpDistro()
75- match_package = SourcePackageNameSet().new('match-package')
76+ # Use unique name for this package, since the search does not
77+ # pass a distroseries and so might pick one of the same name up
78+ # from elsewhere.
79+ match_package = SourcePackageNameSet().new(
80+ self.factory.getUniqueString())
81 self.distrotemplate1.sourcepackagename = match_package
82 self.distrotemplate2.from_sourcepackagename = match_package
83

Subscribers

People subscribed via source and target branches

to status/vote changes: