Merge lp:~michael.nelson/launchpad/db-devel-import-fix-20100827 into lp:launchpad/db-devel

Proposed by Michael Nelson
Status: Merged
Merged at revision: 9707
Proposed branch: lp:~michael.nelson/launchpad/db-devel-import-fix-20100827
Merge into: lp:launchpad/db-devel
Diff against target: 283 lines (+2/-267)
2 files modified
lib/lp/archiveuploader/tests/test_securityuploads.py.THIS (+0/-263)
lib/lp/soyuz/tests/test_binarypackagerelease.py (+2/-4)
To merge this branch: bzr merge lp:~michael.nelson/launchpad/db-devel-import-fix-20100827
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+33876@code.launchpad.net

Description of the change

Overview
========

Fixes an import error on db-devel:

https://lpbuildbot.canonical.com/builders/lucid_db_lp/builds/139/steps/shell_7/logs/summary

which looks like the result of a db-devel specific change that therefore wasn't updated by the soyuz.enums changes that were merged from devel.

Test with:
bin/test -vvm test_binarypackagerelease

To post a comment you must log in.
Revision history for this message
Abel Deuring (adeuring) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'lib/lp/archiveuploader/tests/test_securityuploads.py.THIS'
2--- lib/lp/archiveuploader/tests/test_securityuploads.py.THIS 2010-08-26 15:28:34 +0000
3+++ lib/lp/archiveuploader/tests/test_securityuploads.py.THIS 1970-01-01 00:00:00 +0000
4@@ -1,263 +0,0 @@
5-# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
6-# GNU Affero General Public License version 3 (see the file LICENSE).
7-
8-"""Test security uploads use-cases."""
9-
10-__metaclass__ = type
11-
12-import os
13-
14-from zope.component import getUtility
15-
16-from canonical.launchpad.interfaces import (
17- IDistributionSet,
18- )
19-from lp.archiveuploader.tests.test_uploadprocessor import (
20- TestUploadProcessorBase,
21- )
22-from lp.registry.interfaces.pocket import PackagePublishingPocket
23-from lp.soyuz.enums import PackageUploadStatus
24-from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
25-from lp.soyuz.model.processor import ProcessorFamily
26-
27-
28-class TestStagedBinaryUploadBase(TestUploadProcessorBase):
29- name = 'baz'
30- version = '1.0-1'
31- distribution_name = None
32- distroseries_name = None
33- pocket = None
34- policy = 'buildd'
35- no_mails = True
36-
37- @property
38- def distribution(self):
39- return getUtility(IDistributionSet)[self.distribution_name]
40-
41- @property
42- def distroseries(self):
43- return self.distribution[self.distroseries_name]
44-
45- @property
46- def package_name(self):
47- return "%s_%s" % (self.name, self.version)
48-
49- @property
50- def source_dir(self):
51- return self.package_name
52-
53- @property
54- def source_changesfile(self):
55- return "%s_source.changes" % self.package_name
56-
57- @property
58- def binary_dir(self):
59- return "%s_binary" % self.package_name
60-
61- def getBinaryChangesfileFor(self, archtag):
62- return "%s_%s.changes" % (self.package_name, archtag)
63-
64- def setUp(self):
65- """Setup environment for staged binaries upload via security policy.
66-
67- 1. Setup queue directory and other basic attributes
68- 2. Override policy options to get security policy and not send emails
69- 3. Setup a common UploadProcessor with the overridden options
70- 4. Store number of build present before issuing any upload
71- 5. Upload the source package via security policy
72- 6. Clean log messages.
73- 7. Commit transaction, so the upload source can be seen.
74- """
75- super(TestStagedBinaryUploadBase, self).setUp()
76- self.options.context = self.policy
77- self.options.nomails = self.no_mails
78- # Set up the uploadprocessor with appropriate options and logger
79- self.uploadprocessor = self.getUploadProcessor(self.layer.txn)
80- self.builds_before_upload = BinaryPackageBuild.select().count()
81- self.source_queue = None
82- self._uploadSource()
83- self.log.lines = []
84- self.layer.txn.commit()
85-
86- def assertBuildsCreated(self, amount):
87- """Assert that a given 'amount' of build records was created."""
88- builds_count = BinaryPackageBuild.select().count()
89- self.assertEqual(
90- self.builds_before_upload + amount, builds_count)
91-
92- def _prepareUpload(self, upload_dir):
93- """Place a copy of the upload directory into incoming queue."""
94- os.system("cp -a %s %s" %
95- (os.path.join(self.test_files_dir, upload_dir),
96- os.path.join(self.queue_folder, "incoming")))
97-
98- def _uploadSource(self):
99- """Upload and Accept (if necessary) the base source."""
100- self._prepareUpload(self.source_dir)
101- self.uploadprocessor.processChangesFile(
102- os.path.join(self.queue_folder, "incoming", self.source_dir),
103- self.source_changesfile)
104- queue_item = self.uploadprocessor.last_processed_upload.queue_root
105- self.assertTrue(
106- queue_item is not None,
107- "Source Upload Failed\nGot: %s" % "\n".join(self.log.lines))
108- acceptable_statuses = [
109- PackageUploadStatus.NEW,
110- PackageUploadStatus.UNAPPROVED,
111- ]
112- if queue_item.status in acceptable_statuses:
113- queue_item.setAccepted()
114- # Store source queue item for future use.
115- self.source_queue = queue_item
116-
117- def _uploadBinary(self, archtag):
118- """Upload the base binary.
119-
120- Ensure it got processed and has a respective queue record.
121- Return the IBuild attached to upload.
122- """
123- self._prepareUpload(self.binary_dir)
124- self.uploadprocessor.processChangesFile(
125- os.path.join(self.queue_folder, "incoming", self.binary_dir),
126- self.getBinaryChangesfileFor(archtag))
127- queue_item = self.uploadprocessor.last_processed_upload.queue_root
128- self.assertTrue(
129- queue_item is not None,
130- "Binary Upload Failed\nGot: %s" % "\n".join(self.log.lines))
131- self.assertEqual(queue_item.builds.count(), 1)
132- return queue_item.builds[0].build
133-
134- def _createBuild(self, archtag):
135- """Create a build record attached to the base source."""
136- spr = self.source_queue.sources[0].sourcepackagerelease
137- build = spr.createBuild(
138- distro_arch_series=self.distroseries[archtag],
139- pocket=self.pocket, archive=self.distroseries.main_archive)
140- self.layer.txn.commit()
141- return build
142-
143-
144-class TestStagedSecurityUploads(TestStagedBinaryUploadBase):
145- """Test how security uploads behave inside Soyuz.
146-
147- Security uploads still coming from dak system, we have special upload
148- policy which allows source and binary uploads.
149-
150- An upload of a source and its binaries does not necessary need
151- to happen in the same batch, and Soyuz is prepared to cope with it.
152-
153- The only mandatory condition is to process the sources first.
154-
155- This class will start to tests all known/possible cases using a test
156- (empty) upload and its binary.
157-
158- * 'lib/lp/archivepublisher/tests/data/suite/baz_1.0-1/'
159- * 'lib/lp/archivepublisher/tests/data/suite/baz_1.0-1_binary/'
160- """
161- name = 'baz'
162- version = '1.0-1'
163- distribution_name = 'ubuntu'
164- distroseries_name = 'warty'
165- pocket = PackagePublishingPocket.SECURITY
166- policy = 'security'
167- no_mails = True
168-
169- def setUp(self):
170- """Setup base class and create the required new distroarchseries."""
171- super(TestStagedSecurityUploads, self).setUp()
172- distribution = getUtility(IDistributionSet).getByName(
173- self.distribution_name)
174- distroseries = distribution[self.distroseries.name]
175- proc_family = ProcessorFamily.selectOneBy(name='amd64')
176- distroseries.newArch(
177- 'amd64', proc_family, True, distribution.owner)
178-
179- def testBuildCreation(self):
180- """Check if the builds get created for a binary security uploads.
181-
182- That is the usual case, security binary uploads come after the
183- not published (accepted) source but in the same batch.
184-
185- NascentUpload should create appropriate builds attached to the
186- correct source for the incoming binaries.
187- """
188- build_used = self._uploadBinary('i386')
189-
190- self.assertBuildsCreated(1)
191- self.assertEqual(
192- u'i386 build of baz 1.0-1 in ubuntu warty SECURITY',
193- build_used.title)
194- self.assertEqual('FULLYBUILT', build_used.status.name)
195-
196- build_used = self._uploadBinary('amd64')
197-
198- self.assertBuildsCreated(2)
199- self.assertEqual(
200- u'amd64 build of baz 1.0-1 in ubuntu warty SECURITY',
201- build_used.title)
202-
203- self.assertEqual('FULLYBUILT', build_used.status.name)
204-
205- def testBuildLookup(self):
206- """Check if an available build gets used when it is appropriate.
207-
208- It happens when the security source upload got already published
209- when the binary uploads arrive.
210- The queue-build has already created build records for it and
211- NascentUpload should identify this condition and used them instead
212- of creating new ones.
213- Also verify that builds for another architecture does not got
214- erroneously attached.
215- """
216- build_right_candidate = self._createBuild('i386')
217- build_wrong_candidate = self._createBuild('hppa')
218- build_used = self._uploadBinary('i386')
219-
220- self.assertEqual(build_right_candidate.id, build_used.id)
221- self.assertNotEqual(build_wrong_candidate.id, build_used.id)
222- self.assertBuildsCreated(2)
223- self.assertEqual(
224- u'i386 build of baz 1.0-1 in ubuntu warty SECURITY',
225- build_used.title)
226- self.assertEqual('FULLYBUILT', build_used.status.name)
227-
228- def testCorrectBuildPassedViaCommandLine(self):
229- """Check if command-line build argument gets attached correctly.
230-
231- It's also possible to pass an specific buildid via the command-line
232- to be attached to the current upload.
233-
234- This is only used in 'buildd' policy and does not produce very useful
235- results in 'security', however we want to check if it, at least,
236- does not 'break the system' entirely.
237- """
238- build_candidate = self._createBuild('i386')
239- self.options.buildid = str(build_candidate.id)
240- self.uploadprocessor = self.getUploadProcessor(self.layer.txn)
241-
242- build_used = self._uploadBinary('i386')
243-
244- self.assertEqual(build_candidate.id, build_used.id)
245- self.assertBuildsCreated(1)
246- self.assertEqual(
247- u'i386 build of baz 1.0-1 in ubuntu warty SECURITY',
248- build_used.title)
249-
250- self.assertEqual('FULLYBUILT', build_used.status.name)
251-
252- def testWrongBuildPassedViaCommandLine(self):
253- """Check if a misapplied passed buildid is correctly identified.
254-
255- When we identify misapplied build, either by getting it from command
256- line or by a failure in lookup methods the upload is rejected before
257- anything wrong gets into the DB.
258- """
259- build_candidate = self._createBuild('hppa')
260- self.options.buildid = str(build_candidate.id)
261- self.uploadprocessor = self.getUploadProcessor(self.layer.txn)
262-
263- self.assertRaises(AssertionError, self._uploadBinary, 'i386')
264-
265- self.assertLogContains(
266- "UploadError: Attempt to upload binaries specifying build %d, "
267- "where they don't fit.\n" % (build_candidate.id, ))
268
269=== modified file 'lib/lp/soyuz/tests/test_binarypackagerelease.py'
270--- lib/lp/soyuz/tests/test_binarypackagerelease.py 2010-08-21 13:56:34 +0000
271+++ lib/lp/soyuz/tests/test_binarypackagerelease.py 2010-08-27 08:12:47 +0000
272@@ -6,10 +6,8 @@
273 __metaclass__ = type
274
275 from canonical.testing import LaunchpadFunctionalLayer
276-from lp.soyuz.interfaces.binarypackagerelease import (
277- BinaryPackageFormat,
278- IBinaryPackageRelease,
279- )
280+from lp.soyuz.enums import BinaryPackageFormat
281+from lp.soyuz.interfaces.binarypackagerelease import IBinaryPackageRelease
282 from lp.soyuz.interfaces.publishing import PackagePublishingPriority
283 from lp.testing import TestCaseWithFactory
284

Subscribers

People subscribed via source and target branches

to status/vote changes: