Merge lp:~cjwatson/launchpad/xenial-apt-tests into lp:launchpad
- xenial-apt-tests
- Merge into devel
Proposed by
Colin Watson
Status: | Merged |
---|---|
Merged at revision: | 18312 |
Proposed branch: | lp:~cjwatson/launchpad/xenial-apt-tests |
Merge into: | lp:launchpad |
Diff against target: |
385 lines (+119/-59) 7 files modified
lib/lp/archivepublisher/tests/test_ftparchive.py (+33/-12) lib/lp/archiveuploader/tagfiles.py (+5/-2) lib/lp/soyuz/doc/gina.txt (+0/-2) lib/lp/soyuz/doc/soyuz-upload.txt (+39/-19) lib/lp/soyuz/scripts/gina/archive.py (+16/-12) lib/lp/soyuz/tests/test_archivejob.py (+11/-5) lib/lp/soyuz/tests/test_packageupload.py (+15/-7) |
To merge this branch: | bzr merge lp:~cjwatson/launchpad/xenial-apt-tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant | code | Approve | |
Review via email: mp+314700@code.launchpad.net |
Commit message
Fix various test failures caused by xenial's new apt version.
Description of the change
To post a comment you must log in.
Revision history for this message
William Grant (wgrant) : | # |
review:
Approve
(code)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/lp/archivepublisher/tests/test_ftparchive.py' |
2 | --- lib/lp/archivepublisher/tests/test_ftparchive.py 2016-09-24 04:24:30 +0000 |
3 | +++ lib/lp/archivepublisher/tests/test_ftparchive.py 2017-01-14 00:21:20 +0000 |
4 | @@ -1,4 +1,4 @@ |
5 | -# Copyright 2009-2016 Canonical Ltd. This software is licensed under the |
6 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
7 | # GNU Affero General Public License version 3 (see the file LICENSE). |
8 | |
9 | """Tests for ftparchive.py""" |
10 | @@ -13,7 +13,15 @@ |
11 | from textwrap import dedent |
12 | import time |
13 | |
14 | -from testtools.matchers import LessThan |
15 | +from debian.deb822 import ( |
16 | + Packages, |
17 | + Sources, |
18 | + ) |
19 | +from testtools.matchers import ( |
20 | + Equals, |
21 | + LessThan, |
22 | + MatchesListwise, |
23 | + ) |
24 | from zope.component import getUtility |
25 | |
26 | from lp.archivepublisher.config import getPubConfig |
27 | @@ -100,14 +108,13 @@ |
28 | super(TestFTPArchive, self).tearDown() |
29 | shutil.rmtree(self._config.distroroot) |
30 | |
31 | - def _verifyFile(self, filename, directory, |
32 | - result_suffix="", result_open_func=open): |
33 | + def _verifyFile(self, filename, directory): |
34 | """Compare byte-to-byte the given file and the respective sample. |
35 | |
36 | It's a poor way of testing files generated by apt-ftparchive. |
37 | """ |
38 | - result_path = os.path.join(directory, filename) + result_suffix |
39 | - with result_open_func(result_path) as result_file: |
40 | + result_path = os.path.join(directory, filename) |
41 | + with open(result_path) as result_file: |
42 | result_text = result_file.read() |
43 | sample_path = os.path.join(self._sampledir, filename) |
44 | with open(sample_path) as sample_file: |
45 | @@ -120,6 +127,18 @@ |
46 | sample_text.splitlines(), result_text.splitlines()) |
47 | self.assertEqual(sample_text, result_text, '\n'.join(diff_lines)) |
48 | |
49 | + def _verifyDeb822(self, filename, directory, deb822_factory, |
50 | + result_suffix="", result_open_func=open): |
51 | + """Compare the given file and the respective sample as deb822 files.""" |
52 | + result_path = os.path.join(directory, filename) + result_suffix |
53 | + with result_open_func(result_path) as result_file: |
54 | + result = list(deb822_factory(result_file)) |
55 | + sample_path = os.path.join(self._sampledir, filename) |
56 | + with open(sample_path) as sample_file: |
57 | + sample = list(deb822_factory(sample_file)) |
58 | + self.assertThat( |
59 | + result, MatchesListwise([Equals(stanza) for stanza in sample])) |
60 | + |
61 | def _verifyEmpty(self, path, open_func=open): |
62 | """Assert that the given file is empty.""" |
63 | with open_func(path) as result_file: |
64 | @@ -441,18 +460,20 @@ |
65 | # check'. Although they should remain active in PQM to avoid possible |
66 | # regressions. |
67 | fa.runApt(apt_conf) |
68 | - self._verifyFile( |
69 | + self._verifyDeb822( |
70 | "Packages", |
71 | os.path.join(self._distsdir, "hoary-test", "main", "binary-i386"), |
72 | + Packages.iter_paragraphs, |
73 | result_suffix=".gz", result_open_func=gzip.open) |
74 | self._verifyEmpty( |
75 | os.path.join( |
76 | self._distsdir, "hoary-test", "main", "debian-installer", |
77 | "binary-i386", "Packages.gz"), |
78 | open_func=gzip.open) |
79 | - self._verifyFile( |
80 | + self._verifyDeb822( |
81 | "Sources", |
82 | os.path.join(self._distsdir, "hoary-test", "main", "source"), |
83 | + Sources.iter_paragraphs, |
84 | result_suffix=".gz", result_open_func=gzip.open) |
85 | |
86 | # XXX cprov 2007-03-21: see above, byte-to-byte configuration |
87 | @@ -666,15 +687,15 @@ |
88 | binary_overrides = FakeSelectResult([( |
89 | "bin%d" % i, "main", "misc", "i386", |
90 | PackagePublishingPriority.EXTRA, BinaryPackageFormat.DEB, None) |
91 | - for i in range(10)]) |
92 | + for i in range(50)]) |
93 | fa.publishOverrides("hoary-test", source_overrides, binary_overrides) |
94 | source_files = FakeSelectResult([("tiny", "tiny_0.1.dsc", "main")]) |
95 | binary_files = FakeSelectResult([( |
96 | "bin%d" % i, "bin%d_1_i386.deb" % i, "main", "binary-i386") |
97 | - for i in range(10)]) |
98 | + for i in range(50)]) |
99 | fa.publishFileLists("hoary-test", source_files, binary_files) |
100 | self._addRepositoryFile("main", "tiny", "tiny_0.1.dsc") |
101 | - for i in range(10): |
102 | + for i in range(50): |
103 | self._addRepositoryFile( |
104 | "main", "bin%d" % i, "bin%d_1_i386.deb" % i, |
105 | samplename="tiny_0.1_i386.deb") |
106 | @@ -683,7 +704,7 @@ |
107 | |
108 | # Remove most of this repository's files so that cleanCaches has |
109 | # something to do. |
110 | - for i in range(9): |
111 | + for i in range(49): |
112 | os.unlink( |
113 | self._dp.pathFor("main", "bin%d" % i, "bin%d_1_i386.deb" % i)) |
114 | |
115 | |
116 | === modified file 'lib/lp/archiveuploader/tagfiles.py' |
117 | --- lib/lp/archiveuploader/tagfiles.py 2011-12-14 11:58:56 +0000 |
118 | +++ lib/lp/archiveuploader/tagfiles.py 2017-01-14 00:21:20 +0000 |
119 | @@ -1,4 +1,4 @@ |
120 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
121 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
122 | # GNU Affero General Public License version 3 (see the file LICENSE). |
123 | |
124 | """Utility classes for parsing Debian tag files.""" |
125 | @@ -35,7 +35,10 @@ |
126 | with tempfile.TemporaryFile() as f: |
127 | f.write(strip_pgp_signature(content)) |
128 | f.seek(0) |
129 | - stanzas = list(apt_pkg.TagFile(f)) |
130 | + try: |
131 | + stanzas = list(apt_pkg.TagFile(f)) |
132 | + except SystemError as e: |
133 | + raise TagFileParseError("%s: %s" % (filename, e)) |
134 | if len(stanzas) != 1: |
135 | raise TagFileParseError( |
136 | "%s: multiple stanzas where only one is expected" % filename) |
137 | |
138 | === modified file 'lib/lp/soyuz/doc/gina.txt' |
139 | --- lib/lp/soyuz/doc/gina.txt 2016-01-26 15:47:37 +0000 |
140 | +++ lib/lp/soyuz/doc/gina.txt 2017-01-14 00:21:20 +0000 |
141 | @@ -166,7 +166,6 @@ |
142 | MissingRequiredArguments: ['installed_size'] |
143 | ERROR Invalid Sources stanza in /tmp/tmp... |
144 | ... |
145 | - KeyError: 'Bogus, bogus, bogus\n' |
146 | WARNING No changelog file found for mkvmlinuz in mkvmlinuz-14ubuntu1 |
147 | WARNING No copyright file found for mkvmlinuz in mkvmlinuz-14ubuntu1 |
148 | WARNING Invalid urgency in mkvmlinuz, None, assumed 'low' |
149 | @@ -548,7 +547,6 @@ |
150 | MissingRequiredArguments: ['installed_size'] |
151 | ERROR Invalid Sources stanza in /tmp/tmp... |
152 | ... |
153 | - KeyError: 'Bogus, bogus, bogus\n' |
154 | ERROR Error processing package files for python-sqlite |
155 | ... |
156 | PoolFileNotFound: File python-sqlite_1.0.1-2ubuntu1.dsc not in archive |
157 | |
158 | === modified file 'lib/lp/soyuz/doc/soyuz-upload.txt' |
159 | --- lib/lp/soyuz/doc/soyuz-upload.txt 2016-02-08 12:20:20 +0000 |
160 | +++ lib/lp/soyuz/doc/soyuz-upload.txt 2017-01-14 00:21:20 +0000 |
161 | @@ -39,7 +39,10 @@ |
162 | been uploaded over FTP. |
163 | |
164 | >>> from lp.services.config import config |
165 | - >>> from lp.archiveuploader.tagfiles import parse_tagfile |
166 | + >>> from lp.archiveuploader.tagfiles import ( |
167 | + ... parse_tagfile, |
168 | + ... TagFileParseError, |
169 | + ... ) |
170 | >>> import glob |
171 | >>> test_files_dir = os.path.join(config.root, |
172 | ... "lib/lp/soyuz/scripts/" |
173 | @@ -52,7 +55,10 @@ |
174 | |
175 | >>> seq = 1 |
176 | >>> for changes_filepath in changes: |
177 | - ... tf = parse_tagfile(changes_filepath) |
178 | + ... try: |
179 | + ... tf = parse_tagfile(changes_filepath) |
180 | + ... except TagFileParseError: |
181 | + ... tf = {} |
182 | ... |
183 | ... if "Source" in tf: |
184 | ... package_names.append(tf["Source"]) |
185 | @@ -460,30 +466,34 @@ |
186 | ... "/var/tmp/archive/ubuntutest/pool/universe/e/etherwake")) |
187 | 3 |
188 | |
189 | +Define a helper for pretty-printing Deb822 objects, based on Deb822.dump but |
190 | +with sorted output. |
191 | + |
192 | + >>> def pprint_deb822(deb822): |
193 | + ... for key in sorted(deb822): |
194 | + ... value = deb822.get_as_string(key) |
195 | + ... if not value or value[0] == '\n': |
196 | + ... print '%s:%s' % (key, value) |
197 | + ... else: |
198 | + ... print '%s: %s' % (key, value) |
199 | |
200 | + |
201 | Check the generation of a correct Sources tag file for the main |
202 | component of ubuntutest/breezy-autotest, containing the only the |
203 | required entry for 'etherwake': |
204 | |
205 | >>> import gzip |
206 | + >>> from debian.deb822 import Sources |
207 | |
208 | - >>> sources = gzip.open( |
209 | - ... "/var/tmp/archive/ubuntutest/dists/breezy-autotest/universe/source" |
210 | - ... "/Sources.gz").read() |
211 | - >>> print sources + '\nEND' |
212 | - Package: etherwake |
213 | + >>> with gzip.open( |
214 | + ... "/var/tmp/archive/ubuntutest/dists/breezy-autotest/universe/" |
215 | + ... "source/Sources.gz") as sources_file: |
216 | + ... for source in Sources.iter_paragraphs(sources_file): |
217 | + ... pprint_deb822(source) |
218 | + ... print 'END' |
219 | + Architecture: any |
220 | Binary: etherwake |
221 | - Version: 1.08-1 |
222 | - Section: universe/net |
223 | - Maintainer: Alain Schroeder <...@...org> |
224 | Build-Depends: debhelper (>> 2.0) |
225 | - Architecture: any |
226 | - Standards-Version: 3.5.10.0 |
227 | - Format: 1.0 |
228 | - Directory: pool/universe/e/etherwake |
229 | - Files: |
230 | - f13711c5b8261fbb77b43ae0e8ba9360 566 etherwake_1.08-1.dsc |
231 | - c2dc10f98bac012b900fd0b46721fc80 4455 etherwake_1.08.orig.tar.gz |
232 | - 95c1e89e3ad7bc8740793bdf7aeb7334 4145 etherwake_1.08-1.diff.gz |
233 | Checksums-Sha1: |
234 | 2ddcdc87ab3dc35d5ce8232b0cc76bad8242725f 566 etherwake_1.08-1.dsc |
235 | 4d8aa805cf262a613a48597e3638054dae421048 4455 etherwake_1.08.orig.tar.gz |
236 | @@ -496,7 +506,17 @@ |
237 | 51216a36b2ab6fde6ae04d5bcb0b7cefa9a18eb4b2b11552ca8f3abde928159e93729f30c6079e913078e966817368a6095de2cb4239676a3d6ed5d49d9de699 566 etherwake_1.08-1.dsc |
238 | 6ab88a579ae3fdbbe0f1904712a3a42fab98fa586c3718243d2380f3cb021158c228312001b0685a77dc7171b0307d591ad971a82cd1ccd3511135b23d95ee21 4455 etherwake_1.08.orig.tar.gz |
239 | 814074aa8349936fbec84b3ee703788159a085f0ce4a5e35d2dbef617e1c3c6e60818d155772d47b58e0823ed4bc9af29136f64eac8d643a833660e537145cb1 4145 etherwake_1.08-1.diff.gz |
240 | - <BLANKLINE> |
241 | + Directory: pool/universe/e/etherwake |
242 | + Files: |
243 | + f13711c5b8261fbb77b43ae0e8ba9360 566 etherwake_1.08-1.dsc |
244 | + c2dc10f98bac012b900fd0b46721fc80 4455 etherwake_1.08.orig.tar.gz |
245 | + 95c1e89e3ad7bc8740793bdf7aeb7334 4145 etherwake_1.08-1.diff.gz |
246 | + Format: 1.0 |
247 | + Maintainer: Alain Schroeder <...@...org> |
248 | + Package: etherwake |
249 | + Section: universe/net |
250 | + Standards-Version: 3.5.10.0 |
251 | + Version: 1.08-1 |
252 | <BLANKLINE> |
253 | END |
254 | |
255 | |
256 | === modified file 'lib/lp/soyuz/scripts/gina/archive.py' |
257 | --- lib/lp/soyuz/scripts/gina/archive.py 2016-03-20 22:47:48 +0000 |
258 | +++ lib/lp/soyuz/scripts/gina/archive.py 2017-01-14 00:21:20 +0000 |
259 | @@ -1,4 +1,4 @@ |
260 | -# Copyright 2009-2016 Canonical Ltd. This software is licensed under the |
261 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
262 | # GNU Affero General Public License version 3 (see the file LICENSE). |
263 | |
264 | """Archive pool classes. |
265 | @@ -202,17 +202,21 @@ |
266 | # but we go over it to also cover source packages that only |
267 | # compile for one architecture. |
268 | sources = apt_pkg.TagFile(info_set.srcfile) |
269 | - for section in sources: |
270 | - try: |
271 | - src_tmp = dict(section) |
272 | - src_tmp['Component'] = info_set.component |
273 | - src_name = src_tmp['Package'] |
274 | - except KeyError: |
275 | - log.exception( |
276 | - "Invalid Sources stanza in %s", |
277 | - info_set.sources_tagfile) |
278 | - continue |
279 | - self.src_map[src_name].append(src_tmp) |
280 | + try: |
281 | + for section in sources: |
282 | + try: |
283 | + src_tmp = dict(section) |
284 | + src_tmp['Component'] = info_set.component |
285 | + src_name = src_tmp['Package'] |
286 | + except KeyError: |
287 | + log.exception( |
288 | + "Invalid Sources stanza in %s", |
289 | + info_set.sources_tagfile) |
290 | + continue |
291 | + self.src_map[src_name].append(src_tmp) |
292 | + except SystemError: |
293 | + log.exception( |
294 | + "Invalid Sources stanza in %s", info_set.sources_tagfile) |
295 | |
296 | # Check if it's in source-only mode. If so, skip binary index |
297 | # mapping. |
298 | |
299 | === modified file 'lib/lp/soyuz/tests/test_archivejob.py' |
300 | --- lib/lp/soyuz/tests/test_archivejob.py 2015-09-07 15:15:29 +0000 |
301 | +++ lib/lp/soyuz/tests/test_archivejob.py 2017-01-14 00:21:20 +0000 |
302 | @@ -1,6 +1,8 @@ |
303 | -# Copyright 2010-2015 Canonical Ltd. This software is licensed under the |
304 | +# Copyright 2010-2017 Canonical Ltd. This software is licensed under the |
305 | # GNU Affero General Public License version 3 (see the file LICENSE). |
306 | |
307 | +from debian.deb822 import Changes |
308 | + |
309 | from lp.services.job.runner import JobRunner |
310 | from lp.services.mail.sendmail import format_address_for_person |
311 | from lp.soyuz.enums import ( |
312 | @@ -97,7 +99,13 @@ |
313 | # Running a job produces a notification. Detailed tests of which |
314 | # notifications go to whom live in the PackageUpload and |
315 | # PackageUploadMailer tests. |
316 | - upload = self.factory.makeSourcePackageUpload() |
317 | + distroseries = self.factory.makeDistroSeries() |
318 | + creator = self.factory.makePerson() |
319 | + changes = Changes({"Changed-By": format_address_for_person(creator)}) |
320 | + upload = self.factory.makePackageUpload( |
321 | + distroseries=distroseries, archive=distroseries.main_archive, |
322 | + changes_file_content=changes.dump().encode("UTF-8")) |
323 | + upload.addSource(self.factory.makeSourcePackageRelease()) |
324 | self.factory.makeComponentSelection( |
325 | upload.distroseries, upload.sourcepackagerelease.component) |
326 | upload.setAccepted() |
327 | @@ -106,8 +114,6 @@ |
328 | with dbuser(job.config.dbuser): |
329 | JobRunner([job]).runAll() |
330 | [email] = pop_notifications() |
331 | - self.assertEqual( |
332 | - format_address_for_person(upload.sourcepackagerelease.creator), |
333 | - email['To']) |
334 | + self.assertEqual(format_address_for_person(creator), email['To']) |
335 | self.assertIn('(Accepted)', email['Subject']) |
336 | self.assertIn('Fake summary', email.get_payload()[0].get_payload()) |
337 | |
338 | === modified file 'lib/lp/soyuz/tests/test_packageupload.py' |
339 | --- lib/lp/soyuz/tests/test_packageupload.py 2016-05-23 11:23:48 +0000 |
340 | +++ lib/lp/soyuz/tests/test_packageupload.py 2017-01-14 00:21:20 +0000 |
341 | @@ -1,4 +1,4 @@ |
342 | -# Copyright 2009-2016 Canonical Ltd. This software is licensed under the |
343 | +# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
344 | # GNU Affero General Public License version 3 (see the file LICENSE). |
345 | |
346 | """Test Build features.""" |
347 | @@ -294,13 +294,17 @@ |
348 | # Duplicate queue entries are handled sensibly. |
349 | self.test_publisher.prepareBreezyAutotest() |
350 | distroseries = self.test_publisher.distroseries |
351 | + uploader = self.factory.makePerson() |
352 | + changes = Changes({"Changed-By": uploader.preferredemail.email}) |
353 | upload_one = self.factory.makePackageUpload( |
354 | - archive=distroseries.main_archive, distroseries=distroseries) |
355 | + archive=distroseries.main_archive, distroseries=distroseries, |
356 | + changes_file_content=changes.dump().encode("UTF-8")) |
357 | upload_one.addSource(self.factory.makeSourcePackageRelease( |
358 | sourcepackagename="cnews", distroseries=distroseries, |
359 | component="main", version="1.0")) |
360 | upload_two = self.factory.makePackageUpload( |
361 | - archive=distroseries.main_archive, distroseries=distroseries) |
362 | + archive=distroseries.main_archive, distroseries=distroseries, |
363 | + changes_file_content=changes.dump().encode("UTF-8")) |
364 | upload_two.addSource(self.factory.makeSourcePackageRelease( |
365 | sourcepackagename="cnews", distroseries=distroseries, |
366 | component="main", version="1.0")) |
367 | @@ -947,10 +951,14 @@ |
368 | |
369 | def makeSourcePackageUpload(self, person, **kwargs): |
370 | with person_logged_in(person): |
371 | - upload = self.factory.makeSourcePackageUpload( |
372 | - distroseries=self.distroseries, **kwargs) |
373 | - transaction.commit() |
374 | - spr = upload.sourcepackagerelease |
375 | + uploader = self.factory.makePerson() |
376 | + changes = Changes({"Changed-By": uploader.preferredemail.email}) |
377 | + upload = self.factory.makePackageUpload( |
378 | + distroseries=self.distroseries, |
379 | + archive=self.distroseries.main_archive, |
380 | + changes_file_content=changes.dump().encode("UTF-8")) |
381 | + spr = self.factory.makeSourcePackageRelease(**kwargs) |
382 | + upload.addSource(spr) |
383 | for extension in ("dsc", "tar.gz"): |
384 | filename = "%s_%s.%s" % (spr.name, spr.version, extension) |
385 | lfa = self.factory.makeLibraryFileAlias(filename=filename) |