Merge lp:~julian-edwards/launchpad/ddeb-override-lockstep into lp:launchpad

Proposed by Julian Edwards
Status: Merged
Approved by: Данило Шеган
Approved revision: no longer in the source branch.
Merged at revision: 14180
Proposed branch: lp:~julian-edwards/launchpad/ddeb-override-lockstep
Merge into: lp:launchpad
Diff against target: 207 lines (+80/-10)
4 files modified
lib/lp/archiveuploader/nascentupload.py (+17/-0)
lib/lp/archiveuploader/tests/data/suite/debug_1.0-1/debug_1.0-1_i386.changes (+3/-3)
lib/lp/archiveuploader/tests/test_nascentupload.py (+22/-2)
lib/lp/archiveuploader/tests/test_uploadprocessor.py (+38/-5)
To merge this branch: bzr merge lp:~julian-edwards/launchpad/ddeb-override-lockstep
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Review via email: mp+79799@code.launchpad.net

Commit message

[r=danilo][bug=747558][incr] At upload time, override DDEB files so they are the same as their DEB counterparts. This ensures that domination will work.

Description of the change

= Summary =
At upload time, override DDEB files so they are the same as their DEB counterparts. This ensures that domination will work.

== Pre-implementation notes ==
See comments on bug 747558

== Implementation details ==
Add a new method to the upload processor, "_overrideDDEBSs", that ensures that
any DDEBs in the upload are overridden to have the same
component/section/priority as their counterpart DEBS. This method is then called
from process().

There are new unit tests for both of these changes. There's also some lint
fixed.

== Tests ==
bin/test -cvv test_nascentupload TestOverrideDDEBs
bin/test -cvv test_test_uploadprocessor test_ddeb_upload_overrides

== Demo and Q/A ==
Upload some packages that create DDEBs in a PPA and check their overrides.

= Launchpad lint =

Ignore this bogus lint.

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/archiveuploader/nascentupload.py
  lib/lp/archiveuploader/tests/test_nascentupload.py
  lib/lp/archiveuploader/tests/data/suite/debug_1.0-1/debug_1.0-1_i386.changes
  lib/lp/archiveuploader/tests/test_uploadprocessor.py

./lib/lp/archiveuploader/tests/data/suite/debug_1.0-1/debug_1.0-1_i386.changes
      11: Line has trailing whitespace.
      13: Line has trailing whitespace.
      17: Line has trailing whitespace.
      20: Line has trailing whitespace.
      21: Line exceeds 78 characters.
      22: Line exceeds 78 characters.
      23: Line has trailing whitespace.
      25: Line exceeds 78 characters.

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

The branch looks great.

I wonder if "overriding" component, section and priority means that ddebs will end up in the PPA as well? If they will, will it affect default allocated space to PPAs (i.e. some might hit the limit sooner, or might start hitting the limit once this is rolled out)?

review: Approve
Revision history for this message
Данило Шеган (danilo) wrote :

Btw, it would be nice to exclude .changes files from the linter (I hit that myself in my branch). Just saying...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archiveuploader/nascentupload.py'
2--- lib/lp/archiveuploader/nascentupload.py 2011-09-29 04:12:59 +0000
3+++ lib/lp/archiveuploader/nascentupload.py 2011-10-20 12:15:28 +0000
4@@ -178,6 +178,7 @@
5 # before doing component verifications because the component
6 # actually comes from overrides for packages that are not NEW.
7 self.find_and_apply_overrides()
8+ self._overrideDDEBSs()
9
10 # Override archive location if necessary.
11 self.overrideArchive()
12@@ -365,9 +366,23 @@
13 "Orphaned debug packages: %s" % ', '.join(
14 '%s %s (%s)' % d for d in unmatched_ddebs))
15
16+ def _overrideDDEBSs(self):
17+ """Make sure that any DDEBs in the upload have the same overrides
18+ as their counterpart DEBs. This method needs to be called *after*
19+ _matchDDEBS.
20+
21+ This is required so that domination can supersede both files in
22+ lockstep.
23+ """
24+ for uploaded_file in self.changes.files:
25+ if isinstance(uploaded_file, DdebBinaryUploadFile):
26+ if uploaded_file.deb_file is not None:
27+ self._overrideBinaryFile(uploaded_file,
28+ uploaded_file.deb_file)
29 #
30 # Helpers for warnings and rejections
31 #
32+
33 def run_and_check_error(self, callable):
34 """Run the given callable and process errors and warnings.
35
36@@ -697,7 +712,9 @@
37 override.binarypackagerelease.title,
38 override.distroarchseries.architecturetag,
39 override.pocket.name))
40+ self._overrideBinaryFile(uploaded_file, override)
41
42+ def _overrideBinaryFile(self, uploaded_file, override):
43 uploaded_file.component_name = override.component.name
44 uploaded_file.section_name = override.section.name
45 # Both, changesfiles and nascentuploadfile local maps, reffer to
46
47=== modified file 'lib/lp/archiveuploader/tests/data/suite/debug_1.0-1/debug-bin-dbgsym_1.0-1_i386.ddeb'
48Binary files lib/lp/archiveuploader/tests/data/suite/debug_1.0-1/debug-bin-dbgsym_1.0-1_i386.ddeb 2009-10-11 05:25:10 +0000 and lib/lp/archiveuploader/tests/data/suite/debug_1.0-1/debug-bin-dbgsym_1.0-1_i386.ddeb 2011-10-20 12:15:28 +0000 differ
49=== modified file 'lib/lp/archiveuploader/tests/data/suite/debug_1.0-1/debug_1.0-1_i386.changes'
50--- lib/lp/archiveuploader/tests/data/suite/debug_1.0-1/debug_1.0-1_i386.changes 2009-10-11 05:25:10 +0000
51+++ lib/lp/archiveuploader/tests/data/suite/debug_1.0-1/debug_1.0-1_i386.changes 2011-10-20 12:15:28 +0000
52@@ -16,10 +16,10 @@
53 * Testing debug binaries
54 Checksums-Sha1:
55 91556113ad38eb35d2fe03d27ae646e0ed487a3d 654 debug-bin_1.0-1_i386.deb
56- d120be63a4535e31ec08657cc4d3018cc8b62d54 668 debug-bin-dbgsym_1.0-1_i386.ddeb
57+ 0dbf774a1c46ba6c115790d69466a8ccde9de2e4 648 debug-bin-dbgsym_1.0-1_i386.ddeb
58 Checksums-Sha256:
59 5ca0ce3d3bfde3cc698d9ad4b027663abecb958bea641d29ac3bf8333fd3ebad 654 debug-bin_1.0-1_i386.deb
60- 9c0013badb1bb78fa1ccbf1508398cbf51904f7242d8931f4994c1aa18519b63 668 debug-bin-dbgsym_1.0-1_i386.ddeb
61+ 232cec57f6e35995d8715633ba1302d35a0ff9bb69d27399aa18f18b69c5acc0 648 debug-bin-dbgsym_1.0-1_i386.ddeb
62 Files:
63 48b4eed5980c754cc74a06ffc4372f64 654 devel optional debug-bin_1.0-1_i386.deb
64- ac5c44025ffc026485b22722e0f13804 668 devel optional debug-bin-dbgsym_1.0-1_i386.ddeb
65+ 2491341743bc6466f83765eb67d42f0b 648 devel extra debug-bin-dbgsym_1.0-1_i386.ddeb
66
67=== modified file 'lib/lp/archiveuploader/tests/test_nascentupload.py'
68--- lib/lp/archiveuploader/tests/test_nascentupload.py 2010-12-22 01:08:48 +0000
69+++ lib/lp/archiveuploader/tests/test_nascentupload.py 2011-10-20 12:15:28 +0000
70@@ -6,6 +6,7 @@
71 __metaclass__ = type
72
73 from testtools import TestCase
74+from testtools.matchers import MatchesStructure
75
76 from canonical.testing.layers import LaunchpadZopelessLayer
77 from lp.archiveuploader.changesfile import determine_file_class_and_name
78@@ -32,13 +33,15 @@
79 self.changes = FakeChangesFile()
80 self.upload = NascentUpload(self.changes, None, DevNullLogger())
81
82- def addFile(self, filename):
83+ def addFile(self, filename, comp_and_section='main/devel',
84+ priority='extra'):
85 """Add a file of the right type to the upload."""
86 package, cls = determine_file_class_and_name(filename)
87 file = cls(
88- filename, None, 100, 'devel', 'extra', package, '666',
89+ filename, None, 100, comp_and_section, priority, package, '666',
90 self.changes, None, self.upload.logger)
91 self.changes.files.append(file)
92+ return file
93
94 def assertMatchDDEBErrors(self, error_list):
95 self.assertEquals(
96@@ -83,3 +86,20 @@
97 self.addFile('libblah-dbgsym_1.0_amd64.ddeb')
98 self.assertMatchDDEBErrors(
99 ['Orphaned debug packages: libblah-dbgsym 666 (amd64)'])
100+
101+
102+class TestOverrideDDEBs(TestMatchDDEBs):
103+
104+ def test_DDEBsGetOverrideFromDEBs(self):
105+ # Test the basic case ensuring that DDEB files always match the
106+ # DEB's overrides.
107+ deb = self.addFile("foo_1.0_i386.deb", "main/devel", "extra")
108+ ddeb = self.addFile(
109+ "foo-dbgsym_1.0_i386.ddeb", "universe/web", "low")
110+ self.assertMatchDDEBErrors([])
111+ self.upload._overrideDDEBSs()
112+
113+ self.assertThat(
114+ ddeb,
115+ MatchesStructure.fromExample(
116+ deb, "component_name", "section_name", "priority_name"))
117
118=== modified file 'lib/lp/archiveuploader/tests/test_uploadprocessor.py'
119--- lib/lp/archiveuploader/tests/test_uploadprocessor.py 2011-09-29 06:59:03 +0000
120+++ lib/lp/archiveuploader/tests/test_uploadprocessor.py 2011-10-20 12:15:28 +0000
121@@ -32,8 +32,15 @@
122 from canonical.launchpad.webapp.errorlog import ErrorReportingUtility
123 from canonical.testing.layers import LaunchpadZopelessLayer
124 from lp.app.errors import NotFoundError
125+from lp.archiveuploader.nascentupload import NascentUpload
126+from lp.archiveuploader.nascentuploadfile import DdebBinaryUploadFile
127+from lp.archiveuploader.tests import (
128+ datadir,
129+ getPolicy,
130+ )
131 from lp.archiveuploader.uploadpolicy import (
132 AbstractUploadPolicy,
133+ ArchiveUploadType,
134 findPolicyByName,
135 IArchiveUploadPolicy,
136 )
137@@ -57,7 +64,10 @@
138 from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet
139 from lp.registry.model.sourcepackagename import SourcePackageName
140 from lp.services.features.testing import FeatureFixture
141-from lp.services.log.logger import BufferLogger
142+from lp.services.log.logger import (
143+ BufferLogger,
144+ DevNullLogger,
145+ )
146 from lp.services.mail import stub
147 from lp.soyuz.enums import (
148 ArchivePermissionType,
149@@ -174,7 +184,7 @@
150 if builds is None:
151 builds = self.options.builds
152
153- def getPolicy(distro, build):
154+ def getUploadPolicy(distro, build):
155 self.options.distro = distro.name
156 policy = findPolicyByName(self.options.context)
157 if builds:
158@@ -186,8 +196,8 @@
159
160 upload_processor = UploadProcessor(
161 self.options.base_fsroot, self.options.dryrun,
162- self.options.nomails, builds, self.options.keep, getPolicy, txn,
163- self.log)
164+ self.options.nomails, builds, self.options.keep, getUploadPolicy,
165+ txn, self.log)
166 self.switchToUploader()
167 return upload_processor
168
169@@ -1228,7 +1238,7 @@
170 # Housekeeping so the next test won't fail.
171 shutil.rmtree(upload_dir)
172
173- def disabled_per_bug_825486_testPartnerUploadToNonReleaseOrProposedPocket(self):
174+ def disabled_testPartnerUploadToNonReleaseOrProposedPocket(self):
175 # XXX: bug 825486 robertcollins 2011-08-13 this test is broken.
176 """Test partner upload pockets.
177
178@@ -1927,6 +1937,29 @@
179 self.assertEqual(len(stub.test_emails), 0)
180 self.assertNoNewOops(last_oops)
181
182+ def test_ddeb_upload_overrides(self):
183+ # DDEBs should always be overridden to the same values as their
184+ # counterpart DEB's.
185+ policy = getPolicy(
186+ name="sync", distro="ubuntu", distroseries="hoary")
187+ policy.accepted_type = ArchiveUploadType.BINARY_ONLY
188+ uploader = NascentUpload.from_changesfile_path(
189+ datadir("suite/debug_1.0-1/debug_1.0-1_i386.changes"),
190+ policy, DevNullLogger())
191+ uploader.process()
192+
193+ # The package data on disk that we just uploaded has a different
194+ # priority setting between the deb and the ddeb. We can now assert
195+ # that the process() method above overrode the ddeb.
196+ for uploaded_file in uploader.changes.files:
197+ if isinstance(uploaded_file, DdebBinaryUploadFile):
198+ ddeb = uploaded_file
199+ else:
200+ deb = uploaded_file
201+
202+ self.assertEqual("optional", ddeb.priority_name)
203+ self.assertEqual(deb.priority_name, ddeb.priority_name)
204+
205
206 class TestBuildUploadProcessor(TestUploadProcessorBase):
207 """Test that processing build uploads works."""