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

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 10622
Proposed branch: lp:~jtv/launchpad/db-bug-790084
Merge into: lp:launchpad/db-devel
Diff against target: 69 lines (+19/-1)
3 files modified
lib/lp/registry/interfaces/distroseriesdifference.py (+3/-0)
lib/lp/soyuz/model/packagecopyjob.py (+6/-1)
lib/lp/soyuz/tests/test_packagecopyjob.py (+10/-0)
To merge this branch: bzr merge lp:~jtv/launchpad/db-bug-790084
Reviewer Review Type Date Requested Status
Henning Eggers (community) Approve
Review via email: mp+62845@code.launchpad.net

Commit message

[r=henninge][bug=790084] Attach package sync error only to the right DSD.

Description of the change

= Summary =

When an asynchronous package copy requested from a DistroSeriesDifference fails with a CannotCopy exception, it leaves a note in the form of a DistroSeriesDifferenceComment. But it's currently doing that on all DSDs for the same distroseries.

== Proposed fix ==

I neglected to filter the DSDs by source package name. Easy fix.

== Pre-implementation notes ==

Failed to have one. I'm bad.

== Implementation details ==

I had to add IDistroSeriesDifference.source_package_name_id, in order to give the model code access to the attribute on objects as returned by the ISourcePackageNameSet utility. Matching on id is the right thing to do here because checking source_package_name attributes will cause individual SourcePackageName attributes to be fetched for lots of irrelevant DSDs.

== Tests ==

{{{
./bin/test -vvc lp.soyuz.tests.test_packagecopyjob -t findMatchingDSDs
}}}

== Demo and Q/A ==

Request an asynchronous sync that will fail with a CannotCopy exception. Presently amsn is a usable example. Make sure that cronscripts/process-job-source-groups.py is run:

{{{
./cronscripts/process-job-source-groups.py MAIN -vvv -e IMembershipNotificationJobSource -e IPersonMergeJobSource -e IQuestionEmailJobSource
}}}

The failure should leave a note on its DSD entry on +localpackagediffs, but not on the entries for other packages.

= Launchpad lint =

Oops, I missed a spot which I shall fix forthwith:

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/soyuz/model/packagecopyjob.py
  lib/lp/registry/interfaces/distroseriesdifference.py
  lib/lp/soyuz/tests/test_packagecopyjob.py

./lib/lp/soyuz/tests/test_packagecopyjob.py
     423: local variable 'other_dsd' is assigned to but never used

To post a comment you must log in.
Revision history for this message
Henning Eggers (henninge) wrote :

Thanks. ;-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/interfaces/distroseriesdifference.py'
2--- lib/lp/registry/interfaces/distroseriesdifference.py 2011-05-26 09:07:28 +0000
3+++ lib/lp/registry/interfaces/distroseriesdifference.py 2011-05-30 07:58:10 +0000
4@@ -68,6 +68,8 @@
5 "The distribution series which identifies the parent series "
6 "with the difference.")))
7
8+ source_package_name_id = Int(
9+ title=u"Source package name id", required=True, readonly=True)
10 source_package_name = Reference(
11 ISourcePackageName,
12 title=_("Source package name"), required=True, readonly=True,
13@@ -234,6 +236,7 @@
14 cannot be requested.
15 """
16
17+
18 class IDistroSeriesDifferenceAdmin(Interface):
19 """Difference attributes requiring launchpad.Admin."""
20
21
22=== modified file 'lib/lp/soyuz/model/packagecopyjob.py'
23--- lib/lp/soyuz/model/packagecopyjob.py 2011-05-29 21:18:09 +0000
24+++ lib/lp/soyuz/model/packagecopyjob.py 2011-05-30 07:58:10 +0000
25@@ -38,6 +38,7 @@
26 IDistroSeriesDifferenceSource,
27 )
28 from lp.registry.interfaces.pocket import PackagePublishingPocket
29+from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet
30 from lp.registry.model.distroseries import DistroSeries
31 from lp.registry.interfaces.distroseriesdifferencecomment import (
32 IDistroSeriesDifferenceCommentSource,
33@@ -291,10 +292,14 @@
34 # changed. We can however filter out DSDs that are from
35 # different distributions, based on the job's target archive.
36 source_distro_id = self.source_archive.distributionID
37+ package_ids = set(
38+ getUtility(ISourcePackageNameSet).queryByName(name).id
39+ for name, version in self.metadata["source_packages"])
40 return [
41 dsd
42 for dsd in candidates
43- if dsd.parent_series.distributionID == source_distro_id]
44+ if dsd.parent_series.distributionID == source_distro_id and
45+ dsd.source_package_name_id in package_ids]
46
47 def reportFailure(self, cannotcopy_exception):
48 """Attempt to report failure to the user."""
49
50=== modified file 'lib/lp/soyuz/tests/test_packagecopyjob.py'
51--- lib/lp/soyuz/tests/test_packagecopyjob.py 2011-05-27 02:48:33 +0000
52+++ lib/lp/soyuz/tests/test_packagecopyjob.py 2011-05-30 07:58:10 +0000
53@@ -418,6 +418,16 @@
54
55 self.assertContentEqual([], naked_job.findMatchingDSDs())
56
57+ def test_findMatchingDSDs_ignores_other_packages(self):
58+ # findMatchingDSDs does not return DSDs that are similar to the
59+ # information in the job, but are for different packages.
60+ dsd = self.factory.makeDistroSeriesDifference()
61+ self.factory.makeDistroSeriesDifference(
62+ derived_series=dsd.derived_series,
63+ parent_series=dsd.parent_series)
64+ naked_job = removeSecurityProxy(self.makeJob(dsd))
65+ self.assertContentEqual([dsd], naked_job.findMatchingDSDs())
66+
67
68 class TestPlainPackageCopyJobPrivileges(TestCaseWithFactory, LocalTestHelper):
69 """Test that `PlainPackageCopyJob` has the privileges it needs.

Subscribers

People subscribed via source and target branches

to status/vote changes: