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
=== modified file 'lib/lp/archiveuploader/nascentupload.py'
--- lib/lp/archiveuploader/nascentupload.py 2011-09-29 04:12:59 +0000
+++ lib/lp/archiveuploader/nascentupload.py 2011-10-20 12:15:28 +0000
@@ -178,6 +178,7 @@
178 # before doing component verifications because the component178 # before doing component verifications because the component
179 # actually comes from overrides for packages that are not NEW.179 # actually comes from overrides for packages that are not NEW.
180 self.find_and_apply_overrides()180 self.find_and_apply_overrides()
181 self._overrideDDEBSs()
181182
182 # Override archive location if necessary.183 # Override archive location if necessary.
183 self.overrideArchive()184 self.overrideArchive()
@@ -365,9 +366,23 @@
365 "Orphaned debug packages: %s" % ', '.join(366 "Orphaned debug packages: %s" % ', '.join(
366 '%s %s (%s)' % d for d in unmatched_ddebs))367 '%s %s (%s)' % d for d in unmatched_ddebs))
367368
369 def _overrideDDEBSs(self):
370 """Make sure that any DDEBs in the upload have the same overrides
371 as their counterpart DEBs. This method needs to be called *after*
372 _matchDDEBS.
373
374 This is required so that domination can supersede both files in
375 lockstep.
376 """
377 for uploaded_file in self.changes.files:
378 if isinstance(uploaded_file, DdebBinaryUploadFile):
379 if uploaded_file.deb_file is not None:
380 self._overrideBinaryFile(uploaded_file,
381 uploaded_file.deb_file)
368 #382 #
369 # Helpers for warnings and rejections383 # Helpers for warnings and rejections
370 #384 #
385
371 def run_and_check_error(self, callable):386 def run_and_check_error(self, callable):
372 """Run the given callable and process errors and warnings.387 """Run the given callable and process errors and warnings.
373388
@@ -697,7 +712,9 @@
697 override.binarypackagerelease.title,712 override.binarypackagerelease.title,
698 override.distroarchseries.architecturetag,713 override.distroarchseries.architecturetag,
699 override.pocket.name))714 override.pocket.name))
715 self._overrideBinaryFile(uploaded_file, override)
700716
717 def _overrideBinaryFile(self, uploaded_file, override):
701 uploaded_file.component_name = override.component.name718 uploaded_file.component_name = override.component.name
702 uploaded_file.section_name = override.section.name719 uploaded_file.section_name = override.section.name
703 # Both, changesfiles and nascentuploadfile local maps, reffer to720 # Both, changesfiles and nascentuploadfile local maps, reffer to
704721
=== modified file 'lib/lp/archiveuploader/tests/data/suite/debug_1.0-1/debug-bin-dbgsym_1.0-1_i386.ddeb'
705Binary 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 differ722Binary 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
=== modified file 'lib/lp/archiveuploader/tests/data/suite/debug_1.0-1/debug_1.0-1_i386.changes'
--- lib/lp/archiveuploader/tests/data/suite/debug_1.0-1/debug_1.0-1_i386.changes 2009-10-11 05:25:10 +0000
+++ lib/lp/archiveuploader/tests/data/suite/debug_1.0-1/debug_1.0-1_i386.changes 2011-10-20 12:15:28 +0000
@@ -16,10 +16,10 @@
16 * Testing debug binaries16 * Testing debug binaries
17Checksums-Sha1: 17Checksums-Sha1:
18 91556113ad38eb35d2fe03d27ae646e0ed487a3d 654 debug-bin_1.0-1_i386.deb18 91556113ad38eb35d2fe03d27ae646e0ed487a3d 654 debug-bin_1.0-1_i386.deb
19 d120be63a4535e31ec08657cc4d3018cc8b62d54 668 debug-bin-dbgsym_1.0-1_i386.ddeb19 0dbf774a1c46ba6c115790d69466a8ccde9de2e4 648 debug-bin-dbgsym_1.0-1_i386.ddeb
20Checksums-Sha256: 20Checksums-Sha256:
21 5ca0ce3d3bfde3cc698d9ad4b027663abecb958bea641d29ac3bf8333fd3ebad 654 debug-bin_1.0-1_i386.deb21 5ca0ce3d3bfde3cc698d9ad4b027663abecb958bea641d29ac3bf8333fd3ebad 654 debug-bin_1.0-1_i386.deb
22 9c0013badb1bb78fa1ccbf1508398cbf51904f7242d8931f4994c1aa18519b63 668 debug-bin-dbgsym_1.0-1_i386.ddeb22 232cec57f6e35995d8715633ba1302d35a0ff9bb69d27399aa18f18b69c5acc0 648 debug-bin-dbgsym_1.0-1_i386.ddeb
23Files: 23Files:
24 48b4eed5980c754cc74a06ffc4372f64 654 devel optional debug-bin_1.0-1_i386.deb24 48b4eed5980c754cc74a06ffc4372f64 654 devel optional debug-bin_1.0-1_i386.deb
25 ac5c44025ffc026485b22722e0f13804 668 devel optional debug-bin-dbgsym_1.0-1_i386.ddeb25 2491341743bc6466f83765eb67d42f0b 648 devel extra debug-bin-dbgsym_1.0-1_i386.ddeb
2626
=== modified file 'lib/lp/archiveuploader/tests/test_nascentupload.py'
--- lib/lp/archiveuploader/tests/test_nascentupload.py 2010-12-22 01:08:48 +0000
+++ lib/lp/archiveuploader/tests/test_nascentupload.py 2011-10-20 12:15:28 +0000
@@ -6,6 +6,7 @@
6__metaclass__ = type6__metaclass__ = type
77
8from testtools import TestCase8from testtools import TestCase
9from testtools.matchers import MatchesStructure
910
10from canonical.testing.layers import LaunchpadZopelessLayer11from canonical.testing.layers import LaunchpadZopelessLayer
11from lp.archiveuploader.changesfile import determine_file_class_and_name12from lp.archiveuploader.changesfile import determine_file_class_and_name
@@ -32,13 +33,15 @@
32 self.changes = FakeChangesFile()33 self.changes = FakeChangesFile()
33 self.upload = NascentUpload(self.changes, None, DevNullLogger())34 self.upload = NascentUpload(self.changes, None, DevNullLogger())
3435
35 def addFile(self, filename):36 def addFile(self, filename, comp_and_section='main/devel',
37 priority='extra'):
36 """Add a file of the right type to the upload."""38 """Add a file of the right type to the upload."""
37 package, cls = determine_file_class_and_name(filename)39 package, cls = determine_file_class_and_name(filename)
38 file = cls(40 file = cls(
39 filename, None, 100, 'devel', 'extra', package, '666',41 filename, None, 100, comp_and_section, priority, package, '666',
40 self.changes, None, self.upload.logger)42 self.changes, None, self.upload.logger)
41 self.changes.files.append(file)43 self.changes.files.append(file)
44 return file
4245
43 def assertMatchDDEBErrors(self, error_list):46 def assertMatchDDEBErrors(self, error_list):
44 self.assertEquals(47 self.assertEquals(
@@ -83,3 +86,20 @@
83 self.addFile('libblah-dbgsym_1.0_amd64.ddeb')86 self.addFile('libblah-dbgsym_1.0_amd64.ddeb')
84 self.assertMatchDDEBErrors(87 self.assertMatchDDEBErrors(
85 ['Orphaned debug packages: libblah-dbgsym 666 (amd64)'])88 ['Orphaned debug packages: libblah-dbgsym 666 (amd64)'])
89
90
91class TestOverrideDDEBs(TestMatchDDEBs):
92
93 def test_DDEBsGetOverrideFromDEBs(self):
94 # Test the basic case ensuring that DDEB files always match the
95 # DEB's overrides.
96 deb = self.addFile("foo_1.0_i386.deb", "main/devel", "extra")
97 ddeb = self.addFile(
98 "foo-dbgsym_1.0_i386.ddeb", "universe/web", "low")
99 self.assertMatchDDEBErrors([])
100 self.upload._overrideDDEBSs()
101
102 self.assertThat(
103 ddeb,
104 MatchesStructure.fromExample(
105 deb, "component_name", "section_name", "priority_name"))
86106
=== modified file 'lib/lp/archiveuploader/tests/test_uploadprocessor.py'
--- lib/lp/archiveuploader/tests/test_uploadprocessor.py 2011-09-29 06:59:03 +0000
+++ lib/lp/archiveuploader/tests/test_uploadprocessor.py 2011-10-20 12:15:28 +0000
@@ -32,8 +32,15 @@
32from canonical.launchpad.webapp.errorlog import ErrorReportingUtility32from canonical.launchpad.webapp.errorlog import ErrorReportingUtility
33from canonical.testing.layers import LaunchpadZopelessLayer33from canonical.testing.layers import LaunchpadZopelessLayer
34from lp.app.errors import NotFoundError34from lp.app.errors import NotFoundError
35from lp.archiveuploader.nascentupload import NascentUpload
36from lp.archiveuploader.nascentuploadfile import DdebBinaryUploadFile
37from lp.archiveuploader.tests import (
38 datadir,
39 getPolicy,
40 )
35from lp.archiveuploader.uploadpolicy import (41from lp.archiveuploader.uploadpolicy import (
36 AbstractUploadPolicy,42 AbstractUploadPolicy,
43 ArchiveUploadType,
37 findPolicyByName,44 findPolicyByName,
38 IArchiveUploadPolicy,45 IArchiveUploadPolicy,
39 )46 )
@@ -57,7 +64,10 @@
57from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet64from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet
58from lp.registry.model.sourcepackagename import SourcePackageName65from lp.registry.model.sourcepackagename import SourcePackageName
59from lp.services.features.testing import FeatureFixture66from lp.services.features.testing import FeatureFixture
60from lp.services.log.logger import BufferLogger67from lp.services.log.logger import (
68 BufferLogger,
69 DevNullLogger,
70 )
61from lp.services.mail import stub71from lp.services.mail import stub
62from lp.soyuz.enums import (72from lp.soyuz.enums import (
63 ArchivePermissionType,73 ArchivePermissionType,
@@ -174,7 +184,7 @@
174 if builds is None:184 if builds is None:
175 builds = self.options.builds185 builds = self.options.builds
176186
177 def getPolicy(distro, build):187 def getUploadPolicy(distro, build):
178 self.options.distro = distro.name188 self.options.distro = distro.name
179 policy = findPolicyByName(self.options.context)189 policy = findPolicyByName(self.options.context)
180 if builds:190 if builds:
@@ -186,8 +196,8 @@
186196
187 upload_processor = UploadProcessor(197 upload_processor = UploadProcessor(
188 self.options.base_fsroot, self.options.dryrun,198 self.options.base_fsroot, self.options.dryrun,
189 self.options.nomails, builds, self.options.keep, getPolicy, txn,199 self.options.nomails, builds, self.options.keep, getUploadPolicy,
190 self.log)200 txn, self.log)
191 self.switchToUploader()201 self.switchToUploader()
192 return upload_processor202 return upload_processor
193203
@@ -1228,7 +1238,7 @@
1228 # Housekeeping so the next test won't fail.1238 # Housekeeping so the next test won't fail.
1229 shutil.rmtree(upload_dir)1239 shutil.rmtree(upload_dir)
12301240
1231 def disabled_per_bug_825486_testPartnerUploadToNonReleaseOrProposedPocket(self):1241 def disabled_testPartnerUploadToNonReleaseOrProposedPocket(self):
1232 # XXX: bug 825486 robertcollins 2011-08-13 this test is broken.1242 # XXX: bug 825486 robertcollins 2011-08-13 this test is broken.
1233 """Test partner upload pockets.1243 """Test partner upload pockets.
12341244
@@ -1927,6 +1937,29 @@
1927 self.assertEqual(len(stub.test_emails), 0)1937 self.assertEqual(len(stub.test_emails), 0)
1928 self.assertNoNewOops(last_oops)1938 self.assertNoNewOops(last_oops)
19291939
1940 def test_ddeb_upload_overrides(self):
1941 # DDEBs should always be overridden to the same values as their
1942 # counterpart DEB's.
1943 policy = getPolicy(
1944 name="sync", distro="ubuntu", distroseries="hoary")
1945 policy.accepted_type = ArchiveUploadType.BINARY_ONLY
1946 uploader = NascentUpload.from_changesfile_path(
1947 datadir("suite/debug_1.0-1/debug_1.0-1_i386.changes"),
1948 policy, DevNullLogger())
1949 uploader.process()
1950
1951 # The package data on disk that we just uploaded has a different
1952 # priority setting between the deb and the ddeb. We can now assert
1953 # that the process() method above overrode the ddeb.
1954 for uploaded_file in uploader.changes.files:
1955 if isinstance(uploaded_file, DdebBinaryUploadFile):
1956 ddeb = uploaded_file
1957 else:
1958 deb = uploaded_file
1959
1960 self.assertEqual("optional", ddeb.priority_name)
1961 self.assertEqual(deb.priority_name, ddeb.priority_name)
1962
19301963
1931class TestBuildUploadProcessor(TestUploadProcessorBase):1964class TestBuildUploadProcessor(TestUploadProcessorBase):
1932 """Test that processing build uploads works."""1965 """Test that processing build uploads works."""