Merge ~cjwatson/launchpad:simplify-publisher-suite-sets into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 0ff12af94d54b644d73831ef66c6ef67d81a5fb9
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:simplify-publisher-suite-sets
Merge into: launchpad:master
Diff against target: 670 lines (+97/-131)
6 files modified
lib/lp/archivepublisher/model/ftparchive.py (+3/-4)
lib/lp/archivepublisher/publishing.py (+37/-37)
lib/lp/archivepublisher/scripts/publishdistro.py (+2/-2)
lib/lp/archivepublisher/tests/test_ftparchive.py (+1/-1)
lib/lp/archivepublisher/tests/test_publishdistro.py (+8/-12)
lib/lp/archivepublisher/tests/test_publisher.py (+46/-75)
Reviewer Review Type Date Requested Status
Ioana Lasc Approve
Review via email: mp+410439@code.launchpad.net

Commit message

Simplify sets-of-suites handling in the publisher

Description of the change

Rather than storing sets of tuples of (distroseries name, pocket), it's equivalent and simpler to just store sets of suite names, which are composed from the distroseries name and the pocket. This means that we don't have to worry about details such as whether security-proxied enumeration items behave identically to unproxied items for purposes of set membership checks (in some situations they don't). The code is also slightly shorter and easier to follow this way.

I have no proof that this changes behaviour, although it's possible that it will fix some weirdness that I encountered while trying to force the jammy release pocket to republish to work around a separate bug on 2021-10-16; while debugging that, I noticed some oddities with set membership checks that I never quite got to the bottom of.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/archivepublisher/model/ftparchive.py b/lib/lp/archivepublisher/model/ftparchive.py
2index d56b881..a5b6e32 100644
3--- a/lib/lp/archivepublisher/model/ftparchive.py
4+++ b/lib/lp/archivepublisher/model/ftparchive.py
5@@ -232,7 +232,7 @@ class FTPArchiveHandler:
6 continue
7
8 self.publisher.release_files_needed.add(
9- (distroseries.name, pocket))
10+ distroseries.getSuite(pocket))
11
12 for comp in components:
13 self.createEmptyPocketRequest(distroseries, pocket, comp)
14@@ -768,9 +768,8 @@ class FTPArchiveHandler:
15
16 Otherwise, we aim to limit our config to certain distroseries
17 and pockets. By default, we will exclude release pockets for
18- released series, and in addition we exclude any pocket not
19- explicitly marked as dirty. dirty_pockets must be a nested
20- dictionary of booleans, keyed by distroseries.name then pocket.
21+ released series, and in addition we exclude any suite not
22+ explicitly marked as dirty.
23 """
24 apt_config = six.StringIO()
25 apt_config.write(CONFIG_HEADER % (self._config.archiveroot,
26diff --git a/lib/lp/archivepublisher/publishing.py b/lib/lp/archivepublisher/publishing.py
27index 708e9de..6340738 100644
28--- a/lib/lp/archivepublisher/publishing.py
29+++ b/lib/lp/archivepublisher/publishing.py
30@@ -1,4 +1,4 @@
31-# Copyright 2009-2019 Canonical Ltd. This software is licensed under the
32+# Copyright 2009-2021 Canonical Ltd. This software is licensed under the
33 # GNU Affero General Public License version 3 (see the file LICENSE).
34
35 __all__ = [
36@@ -416,15 +416,16 @@ class Publisher(object):
37
38 Publishers need the pool root dir and a DiskPool object.
39
40- Optionally we can pass a list of tuples, (distroseries.name, pocket),
41- which will restrict the publisher actions, only suites listed in
42- allowed_suites will be modified.
43+ Optionally we can pass a list of suite names which will restrict the
44+ publisher actions; only suites listed in allowed_suites will be
45+ modified.
46 """
47 self.log = log
48 self._config = config
49 self.distro = archive.distribution
50 self.archive = archive
51- self.allowed_suites = allowed_suites
52+ self.allowed_suites = (
53+ None if allowed_suites is None else set(allowed_suites))
54
55 self._diskpool = diskpool
56
57@@ -433,14 +434,14 @@ class Publisher(object):
58 else:
59 self._library = library
60
61- # Track which distroseries pockets have been dirtied by a
62- # change, and therefore need domination/apt-ftparchive work.
63- # This is a set of tuples in the form (distroseries.name, pocket)
64- self.dirty_pockets = set()
65+ # Track which suites have been dirtied by a change, and therefore
66+ # need domination/apt-ftparchive work. This is a set of suite names
67+ # as returned by DistroSeries.getSuite.
68+ self.dirty_suites = set()
69
70- # Track which pockets need release files. This will contain more
71- # than dirty_pockets in the case of a careful index run.
72- # This is a set of tuples in the form (distroseries.name, pocket)
73+ # Track which suites need release files. This will contain more
74+ # than dirty_suites in the case of a careful index run.
75+ # This is a set of suite names as returned by DistroSeries.getSuite.
76 self.release_files_needed = set()
77
78 def setupArchiveDirs(self):
79@@ -449,12 +450,12 @@ class Publisher(object):
80
81 def isDirty(self, distroseries, pocket):
82 """True if a publication has happened in this release and pocket."""
83- return (distroseries.name, pocket) in self.dirty_pockets
84+ return distroseries.getSuite(pocket) in self.dirty_suites
85
86- def markPocketDirty(self, distroseries, pocket):
87- """Mark a pocket dirty only if it's allowed."""
88+ def markSuiteDirty(self, distroseries, pocket):
89+ """Mark a suite dirty only if it's allowed."""
90 if self.isAllowed(distroseries, pocket):
91- self.dirty_pockets.add((distroseries.name, pocket))
92+ self.dirty_suites.add(distroseries.getSuite(pocket))
93
94 def isAllowed(self, distroseries, pocket):
95 """Whether or not the given suite should be considered.
96@@ -465,7 +466,7 @@ class Publisher(object):
97 Otherwise, return False.
98 """
99 return (not self.allowed_suites or
100- (distroseries.name, pocket) in self.allowed_suites)
101+ distroseries.getSuite(pocket) in self.allowed_suites)
102
103 @property
104 def subcomponents(self):
105@@ -546,7 +547,7 @@ class Publisher(object):
106
107 Consider records returned by getPendingSourcePublications.
108 """
109- dirty_pockets = set()
110+ dirty_suites = set()
111 all_spphs = self.getPendingSourcePublications(is_careful)
112 for (distroseries, pocket), spphs in groupby(
113 all_spphs, attrgetter("distroseries", "pocket")):
114@@ -561,8 +562,8 @@ class Publisher(object):
115 distroseries.status.name))
116 else:
117 self.publishSources(distroseries, pocket, spphs)
118- dirty_pockets.add((distroseries.name, pocket))
119- return dirty_pockets
120+ dirty_suites.add(distroseries.getSuite(pocket))
121+ return dirty_suites
122
123 def getPendingBinaryPublications(self, is_careful):
124 """Return the specific group of binary records to be published."""
125@@ -602,7 +603,7 @@ class Publisher(object):
126
127 Consider records returned by getPendingBinaryPublications.
128 """
129- dirty_pockets = set()
130+ dirty_suites = set()
131 all_bpphs = self.getPendingBinaryPublications(is_careful)
132 for (distroarchseries, pocket), bpphs in groupby(
133 all_bpphs, attrgetter("distroarchseries", "pocket")):
134@@ -618,8 +619,8 @@ class Publisher(object):
135 distroseries.status.name))
136 else:
137 self.publishBinaries(distroarchseries, pocket, bpphs)
138- dirty_pockets.add((distroseries.name, pocket))
139- return dirty_pockets
140+ dirty_suites.add(distroseries.getSuite(pocket))
141+ return dirty_suites
142
143 def A_publish(self, force_publishing):
144 """First step in publishing: actual package publishing.
145@@ -631,9 +632,9 @@ class Publisher(object):
146 """
147 self.log.debug("* Step A: Publishing packages")
148
149- self.dirty_pockets.update(
150+ self.dirty_suites.update(
151 self.findAndPublishSources(is_careful=force_publishing))
152- self.dirty_pockets.update(
153+ self.dirty_suites.update(
154 self.findAndPublishBinaries(is_careful=force_publishing))
155
156 def A2_markPocketsWithDeletionsDirty(self):
157@@ -654,9 +655,9 @@ class Publisher(object):
158 table.dateremoved == None,
159 ]
160
161- # We need to get a set of (distroseries, pocket) tuples that have
162- # publications that are waiting to be deleted. Each tuple is
163- # added to the dirty_pockets set.
164+ # We need to get a set of suite names that have publications that
165+ # are waiting to be deleted. Each suite name is added to the
166+ # dirty_suites set.
167
168 # Make the source publications query.
169 conditions = base_conditions(SourcePackagePublishingHistory)
170@@ -688,7 +689,7 @@ class Publisher(object):
171 # stable distroseries, no matter what other bugs
172 # that precede here have dirtied it.
173 continue
174- self.markPocketDirty(distroseries, pocket)
175+ self.markSuiteDirty(distroseries, pocket)
176
177 def B_dominate(self, force_domination):
178 """Second step in publishing: domination."""
179@@ -729,7 +730,7 @@ class Publisher(object):
180 continue
181 self.checkDirtySuiteBeforePublishing(distroseries, pocket)
182
183- self.release_files_needed.add((distroseries.name, pocket))
184+ self.release_files_needed.add(distroseries.getSuite(pocket))
185
186 components = self.archive.getComponentsForSeries(distroseries)
187 for component in components:
188@@ -739,9 +740,9 @@ class Publisher(object):
189 def D_writeReleaseFiles(self, is_careful):
190 """Write out the Release files for the provided distribution.
191
192- If is_careful is specified, we include all pockets of all releases.
193+ If is_careful is specified, we include all suites.
194
195- Otherwise we include only pockets flagged as true in dirty_pockets.
196+ Otherwise we include only suites flagged as true in dirty_suites.
197 """
198 self.log.debug("* Step D: Generating Release files.")
199
200@@ -750,11 +751,10 @@ class Publisher(object):
201 self.archive, container_prefix=u"release:"):
202 distroseries, pocket = self.distro.getDistroSeriesAndPocket(
203 container[len(u"release:"):])
204- archive_file_suites.add((distroseries.name, pocket))
205+ archive_file_suites.add(distroseries.getSuite(pocket))
206
207 for distroseries in self.distro:
208 for pocket in self.archive.getPockets():
209- ds_pocket = (distroseries.name, pocket)
210 suite = distroseries.getSuite(pocket)
211 suite_path = os.path.join(self._config.distsroot, suite)
212 release_path = os.path.join(suite_path, "Release")
213@@ -768,9 +768,9 @@ class Publisher(object):
214 # suites. Only force those suites that already have
215 # Release files.
216 if file_exists(release_path):
217- self.release_files_needed.add(ds_pocket)
218+ self.release_files_needed.add(suite)
219
220- write_release = ds_pocket in self.release_files_needed
221+ write_release = suite in self.release_files_needed
222 if not is_careful:
223 if not self.isDirty(distroseries, pocket):
224 self.log.debug("Skipping release files for %s/%s" %
225@@ -782,7 +782,7 @@ class Publisher(object):
226
227 if write_release:
228 self._writeSuite(distroseries, pocket)
229- elif (ds_pocket in archive_file_suites and
230+ elif (suite in archive_file_suites and
231 distroseries.publish_by_hash):
232 # We aren't publishing a new Release file for this
233 # suite, probably because it's immutable, but we still
234diff --git a/lib/lp/archivepublisher/scripts/publishdistro.py b/lib/lp/archivepublisher/scripts/publishdistro.py
235index c079484..b82f992 100644
236--- a/lib/lp/archivepublisher/scripts/publishdistro.py
237+++ b/lib/lp/archivepublisher/scripts/publishdistro.py
238@@ -233,7 +233,7 @@ class PublishDistro(PublisherScript):
239 suites = set()
240 for suite in self.options.suite:
241 series, pocket = self.findSuite(distribution, suite)
242- suites.add((series.name, pocket))
243+ suites.add(series.getSuite(pocket))
244 return suites
245
246 def findExplicitlyDirtySuites(self, archive):
247@@ -311,7 +311,7 @@ class PublishDistro(PublisherScript):
248 """
249 for distroseries, pocket in self.findExplicitlyDirtySuites(archive):
250 if not cannot_modify_suite(archive, distroseries, pocket):
251- publisher.markPocketDirty(distroseries, pocket)
252+ publisher.markSuiteDirty(distroseries, pocket)
253 if archive.dirty_suites is not None:
254 # Clear the explicit dirt indicator before we start doing
255 # time-consuming publishing, which might race with an
256diff --git a/lib/lp/archivepublisher/tests/test_ftparchive.py b/lib/lp/archivepublisher/tests/test_ftparchive.py
257index 139392b..1c09bfb 100755
258--- a/lib/lp/archivepublisher/tests/test_ftparchive.py
259+++ b/lib/lp/archivepublisher/tests/test_ftparchive.py
260@@ -582,7 +582,7 @@ class TestFTPArchive(TestCaseWithFactory):
261 # * a-f runs based on this config without any errors
262 # * a-f *only* creates the wanted archive indexes.
263 allowed_suites = set()
264- allowed_suites.add(('hoary-test', PackagePublishingPocket.UPDATES))
265+ allowed_suites.add('hoary-test-updates')
266
267 publisher = Publisher(
268 self._logger, self._config, self._dp,
269diff --git a/lib/lp/archivepublisher/tests/test_publishdistro.py b/lib/lp/archivepublisher/tests/test_publishdistro.py
270index da8f548..fb00a9f 100644
271--- a/lib/lp/archivepublisher/tests/test_publishdistro.py
272+++ b/lib/lp/archivepublisher/tests/test_publishdistro.py
273@@ -117,11 +117,11 @@ class TestPublishDistro(TestNativePublishingBase):
274 foo_path = "%s/main/f/foo/foo_666.dsc" % self.pool_dir
275 self.assertEqual(open(foo_path).read().strip(), 'foo')
276
277- def testDirtyPocketProcessing(self):
278- """Test dirty pocket processing.
279+ def testDirtySuiteProcessing(self):
280+ """Test dirty suite processing.
281
282- Make a DELETED source to see if the dirty pocket processing
283- works for deletions.
284+ Make a DELETED source to see if the dirty suite processing works for
285+ deletions.
286 """
287 pub_source_id = self.getPubSource(filecontent=b'foo').id
288 self.layer.txn.commit()
289@@ -717,14 +717,13 @@ class TestPublishDistroMethods(TestCaseWithFactory):
290 script = self.makeScript(distro)
291 self.assertContentEqual([], script.findAllowedSuites(distro))
292
293- def test_findAllowedSuites_finds_series_and_pocket(self):
294- # findAllowedSuites looks up the requested suites.
295+ def test_findAllowedSuites_finds_single(self):
296+ # findAllowedSuites looks up the requested suite.
297 series = self.factory.makeDistroSeries()
298 suite = "%s-updates" % series.name
299 script = self.makeScript(series.distribution, ['--suite', suite])
300 self.assertContentEqual(
301- [(series.name, PackagePublishingPocket.UPDATES)],
302- script.findAllowedSuites(series.distribution))
303+ [suite], script.findAllowedSuites(series.distribution))
304
305 def test_findAllowedSuites_finds_multiple(self):
306 # Multiple suites may be requested; findAllowedSuites looks them
307@@ -733,10 +732,7 @@ class TestPublishDistroMethods(TestCaseWithFactory):
308 script = self.makeScript(series.distribution, [
309 '--suite', '%s-updates' % series.name,
310 '--suite', series.name])
311- expected_suites = [
312- (series.name, PackagePublishingPocket.UPDATES),
313- (series.name, PackagePublishingPocket.RELEASE),
314- ]
315+ expected_suites = ['%s-updates' % series.name, series.name]
316 self.assertContentEqual(
317 expected_suites, script.findAllowedSuites(series.distribution))
318
319diff --git a/lib/lp/archivepublisher/tests/test_publisher.py b/lib/lp/archivepublisher/tests/test_publisher.py
320index 247fef3..977b626 100644
321--- a/lib/lp/archivepublisher/tests/test_publisher.py
322+++ b/lib/lp/archivepublisher/tests/test_publisher.py
323@@ -1,4 +1,4 @@
324-# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
325+# Copyright 2009-2021 Canonical Ltd. This software is licensed under the
326 # GNU Affero General Public License version 3 (see the file LICENSE).
327
328 """Tests for publisher class."""
329@@ -720,11 +720,6 @@ class TestByHashes(TestCaseWithFactory):
330 class TestPublisher(TestPublisherBase):
331 """Testing `Publisher` behaviour."""
332
333- def assertDirtyPocketsContents(self, expected, dirty_pockets):
334- contents = [(str(dr_name), pocket.name) for dr_name, pocket in
335- dirty_pockets]
336- self.assertEqual(expected, contents)
337-
338 def assertReleaseContentsMatch(self, release, filename, contents):
339 for hash_name, hash_func in (
340 ('md5sum', hashlib.md5),
341@@ -766,8 +761,7 @@ class TestPublisher(TestPublisherBase):
342 self.layer.txn.commit()
343
344 pub_source.sync()
345- self.assertDirtyPocketsContents(
346- [('breezy-autotest', 'RELEASE')], publisher.dirty_pockets)
347+ self.assertEqual({'breezy-autotest'}, publisher.dirty_suites)
348 self.assertEqual(PackagePublishingStatus.PUBLISHED, pub_source.status)
349
350 # file got published
351@@ -972,8 +966,7 @@ class TestPublisher(TestPublisherBase):
352 publisher.A_publish(force_publishing=False)
353
354 # The pocket was dirtied:
355- self.assertDirtyPocketsContents(
356- [('breezy-autotest', 'RELEASE')], publisher.dirty_pockets)
357+ self.assertEqual({'breezy-autotest'}, publisher.dirty_suites)
358 # The file was published:
359 foo_path = "%s/main/f/foo/foo_666.dsc" % pub_config.poolroot
360 with open(foo_path) as foo_file:
361@@ -993,8 +986,7 @@ class TestPublisher(TestPublisherBase):
362 """
363 publisher = Publisher(
364 self.logger, self.config, self.disk_pool,
365- self.ubuntutest.main_archive,
366- allowed_suites=[('hoary-test', PackagePublishingPocket.RELEASE)])
367+ self.ubuntutest.main_archive, allowed_suites=['hoary-test'])
368
369 pub_source = self.getPubSource(filecontent=b'foo')
370 pub_source2 = self.getPubSource(
371@@ -1006,8 +998,7 @@ class TestPublisher(TestPublisherBase):
372
373 pub_source.sync()
374 pub_source2.sync()
375- self.assertDirtyPocketsContents(
376- [('hoary-test', 'RELEASE')], publisher.dirty_pockets)
377+ self.assertEqual({'hoary-test'}, publisher.dirty_suites)
378 self.assertEqual(
379 PackagePublishingStatus.PUBLISHED, pub_source2.status)
380 self.assertEqual(PackagePublishingStatus.PENDING, pub_source.status)
381@@ -1020,8 +1011,7 @@ class TestPublisher(TestPublisherBase):
382 publisher = Publisher(
383 self.logger, self.config, self.disk_pool,
384 self.ubuntutest.main_archive,
385- allowed_suites=[('breezy-autotest',
386- PackagePublishingPocket.UPDATES)])
387+ allowed_suites=['breezy-autotest-updates'])
388
389 self.ubuntutest['breezy-autotest'].status = (
390 SeriesStatus.CURRENT)
391@@ -1039,8 +1029,7 @@ class TestPublisher(TestPublisherBase):
392
393 pub_source.sync()
394 pub_source2.sync()
395- self.assertDirtyPocketsContents(
396- [('breezy-autotest', 'UPDATES')], publisher.dirty_pockets)
397+ self.assertEqual({'breezy-autotest-updates'}, publisher.dirty_suites)
398 self.assertEqual(PackagePublishingStatus.PUBLISHED, pub_source.status)
399 self.assertEqual(PackagePublishingStatus.PENDING, pub_source2.status)
400
401@@ -1059,7 +1048,7 @@ class TestPublisher(TestPublisherBase):
402 # no pockets will be *dirtied*.
403 publisher.A_publish(False)
404
405- self.assertDirtyPocketsContents([], publisher.dirty_pockets)
406+ self.assertEqual(set(), publisher.dirty_suites)
407 # nothing got published
408 foo_path = "%s/main/f/foo/foo_666.dsc" % self.pool_dir
409 self.assertEqual(False, os.path.exists(foo_path))
410@@ -1087,8 +1076,7 @@ class TestPublisher(TestPublisherBase):
411 # then we will have a corresponding dirty_pocket entry.
412 publisher.A_publish(True)
413
414- self.assertDirtyPocketsContents(
415- [('breezy-autotest', 'RELEASE')], publisher.dirty_pockets)
416+ self.assertEqual({'breezy-autotest'}, publisher.dirty_suites)
417 # file got published
418 foo_path = "%s/main/f/foo/foo_666.dsc" % self.pool_dir
419 with open(foo_path) as foo_file:
420@@ -1115,7 +1103,7 @@ class TestPublisher(TestPublisherBase):
421 publisher.A_publish(False)
422 self.layer.txn.commit()
423
424- self.assertDirtyPocketsContents([], publisher.dirty_pockets)
425+ self.assertEqual(set(), publisher.dirty_suites)
426 self.assertEqual(PackagePublishingStatus.PENDING, pub_source.status)
427
428 # nothing got published
429@@ -1146,8 +1134,7 @@ class TestPublisher(TestPublisherBase):
430 self.layer.txn.commit()
431
432 pub_source.sync()
433- self.assertDirtyPocketsContents(
434- [('breezy-autotest', 'RELEASE')], publisher.dirty_pockets)
435+ self.assertEqual({'breezy-autotest'}, publisher.dirty_suites)
436 self.assertEqual(PackagePublishingStatus.PUBLISHED, pub_source.status)
437
438 # nothing got published
439@@ -1224,8 +1211,7 @@ class TestPublisher(TestPublisherBase):
440 helper function: 'getPublisher'
441 """
442 # Stub parameters.
443- allowed_suites = [
444- ('breezy-autotest', PackagePublishingPocket.RELEASE)]
445+ allowed_suites = ['breezy-autotest']
446
447 distro_publisher = getPublisher(
448 self.ubuntutest.main_archive, allowed_suites, self.logger)
449@@ -1236,9 +1222,7 @@ class TestPublisher(TestPublisherBase):
450 self.assertEqual(
451 '/var/tmp/archive/ubuntutest/dists',
452 distro_publisher._config.distsroot)
453- self.assertEqual(
454- [('breezy-autotest', PackagePublishingPocket.RELEASE)],
455- distro_publisher.allowed_suites)
456+ self.assertEqual({'breezy-autotest'}, distro_publisher.allowed_suites)
457
458 # Check that the partner archive is built in a different directory
459 # to the primary archive.
460@@ -1263,9 +1247,7 @@ class TestPublisher(TestPublisherBase):
461 self.assertEqual(
462 '/var/tmp/ppa.test/cprov/ppa/ubuntutest/dists',
463 archive_publisher._config.distsroot)
464- self.assertEqual(
465- [('breezy-autotest', PackagePublishingPocket.RELEASE)],
466- archive_publisher.allowed_suites)
467+ self.assertEqual({'breezy-autotest'}, archive_publisher.allowed_suites)
468
469 def testPendingArchive(self):
470 """Check Pending Archive Lookup.
471@@ -1537,9 +1519,8 @@ class TestPublisher(TestPublisherBase):
472 index_contents)
473
474 # We always regenerate all Releases file for a given suite.
475- self.assertTrue(
476- ('breezy-autotest', PackagePublishingPocket.RELEASE) in
477- archive_publisher.release_files_needed)
478+ self.assertIn(
479+ 'breezy-autotest', archive_publisher.release_files_needed)
480
481 # Confirm that i18n files are not created
482 i18n_path = os.path.join(archive_publisher._config.distsroot,
483@@ -1686,9 +1667,8 @@ class TestPublisher(TestPublisherBase):
484 index_contents)
485
486 # We always regenerate all Releases file for a given suite.
487- self.assertTrue(
488- ('breezy-autotest', PackagePublishingPocket.RELEASE) in
489- archive_publisher.release_files_needed)
490+ self.assertIn(
491+ 'breezy-autotest', archive_publisher.release_files_needed)
492
493 # Various compressed Translation-en files are written; ensure that
494 # they are the same after decompression.
495@@ -1762,11 +1742,6 @@ class TestPublisher(TestPublisherBase):
496 self._checkCompressedFiles(
497 archive_publisher, uncompressed_file_path, ['.xz'])
498
499- def checkDirtyPockets(self, publisher, expected):
500- """Check dirty_pockets contents of a given publisher."""
501- sorted_dirty_pockets = sorted(list(publisher.dirty_pockets))
502- self.assertEqual(expected, sorted_dirty_pockets)
503-
504 def testDirtyingPocketsWithDeletedPackages(self):
505 """Test that dirtying pockets with deleted packages works.
506
507@@ -1779,7 +1754,7 @@ class TestPublisher(TestPublisherBase):
508 self.ubuntutest.main_archive, allowed_suites, self.logger)
509
510 publisher.A2_markPocketsWithDeletionsDirty()
511- self.checkDirtyPockets(publisher, expected=[])
512+ self.assertEqual(set(), publisher.dirty_suites)
513
514 # Make a published source, a deleted source in the release
515 # pocket, a source that's been removed from disk and one that's
516@@ -1811,27 +1786,27 @@ class TestPublisher(TestPublisherBase):
517 # Run the deletion detection.
518 publisher.A2_markPocketsWithDeletionsDirty()
519
520- # Only the pockets with pending deletions are marked as dirty.
521- expected_dirty_pockets = [
522- ('breezy-autotest', PackagePublishingPocket.RELEASE),
523- ('breezy-autotest', PackagePublishingPocket.SECURITY),
524- ('breezy-autotest', PackagePublishingPocket.BACKPORTS),
525- ]
526- self.checkDirtyPockets(publisher, expected=expected_dirty_pockets)
527+ # Only the suites with pending deletions are marked as dirty.
528+ expected_dirty_suites = {
529+ 'breezy-autotest',
530+ 'breezy-autotest-security',
531+ 'breezy-autotest-backports',
532+ }
533+ self.assertEqual(expected_dirty_suites, publisher.dirty_suites)
534
535 # If the distroseries is CURRENT, then the release pocket is not
536 # marked as dirty.
537 self.ubuntutest['breezy-autotest'].status = (
538 SeriesStatus.CURRENT)
539
540- publisher.dirty_pockets = set()
541+ publisher.dirty_suites = set()
542 publisher.A2_markPocketsWithDeletionsDirty()
543
544- expected_dirty_pockets = [
545- ('breezy-autotest', PackagePublishingPocket.SECURITY),
546- ('breezy-autotest', PackagePublishingPocket.BACKPORTS),
547- ]
548- self.checkDirtyPockets(publisher, expected=expected_dirty_pockets)
549+ expected_dirty_suites = {
550+ 'breezy-autotest-security',
551+ 'breezy-autotest-backports',
552+ }
553+ self.assertEqual(expected_dirty_suites, publisher.dirty_suites)
554
555 def testDeletionDetectionRespectsAllowedSuites(self):
556 """Check if the deletion detection mechanism respects allowed_suites.
557@@ -1845,14 +1820,14 @@ class TestPublisher(TestPublisherBase):
558 specified suites should be marked as dirty.
559 """
560 allowed_suites = [
561- ('breezy-autotest', PackagePublishingPocket.SECURITY),
562- ('breezy-autotest', PackagePublishingPocket.UPDATES),
563+ 'breezy-autotest-security',
564+ 'breezy-autotest-updates',
565 ]
566 publisher = getPublisher(
567 self.ubuntutest.main_archive, allowed_suites, self.logger)
568
569 publisher.A2_markPocketsWithDeletionsDirty()
570- self.checkDirtyPockets(publisher, expected=[])
571+ self.assertEqual(set(), publisher.dirty_suites)
572
573 # Create pending deletions in RELEASE, BACKPORTS, SECURITY and
574 # UPDATES pockets.
575@@ -1873,9 +1848,8 @@ class TestPublisher(TestPublisherBase):
576 status=PackagePublishingStatus.DELETED)[0]
577
578 publisher.A2_markPocketsWithDeletionsDirty()
579- # Only the pockets with pending deletions in the allowed suites
580- # are marked as dirty.
581- self.checkDirtyPockets(publisher, expected=allowed_suites)
582+ # Only the suites with pending deletions are marked as dirty.
583+ self.assertEqual(set(allowed_suites), publisher.dirty_suites)
584
585 def testReleaseFile(self):
586 """Test release file writing.
587@@ -1892,9 +1866,7 @@ class TestPublisher(TestPublisherBase):
588 publisher.A_publish(False)
589 publisher.C_doFTPArchive(False)
590
591- self.assertIn(
592- ('breezy-autotest', PackagePublishingPocket.RELEASE),
593- publisher.release_files_needed)
594+ self.assertIn('breezy-autotest', publisher.release_files_needed)
595
596 publisher.D_writeReleaseFiles(False)
597
598@@ -2140,7 +2112,7 @@ class TestPublisher(TestPublisherBase):
599 os.makedirs(os.path.dirname(contents_path))
600 with gzip.GzipFile(contents_path, 'wb'):
601 pass
602- publisher.markPocketDirty(
603+ publisher.markSuiteDirty(
604 self.ubuntutest.getSeries('breezy-autotest'),
605 PackagePublishingPocket.RELEASE)
606
607@@ -2170,7 +2142,7 @@ class TestPublisher(TestPublisherBase):
608 for name in dep11_names:
609 with gzip.GzipFile(os.path.join(dep11_path, name), 'wb') as f:
610 f.write(six.ensure_binary(name))
611- publisher.markPocketDirty(
612+ publisher.markSuiteDirty(
613 self.ubuntutest.getSeries('breezy-autotest'),
614 PackagePublishingPocket.RELEASE)
615
616@@ -2200,7 +2172,7 @@ class TestPublisher(TestPublisherBase):
617 for name in cnf_names:
618 with lzma.LZMAFile(os.path.join(cnf_path, name), 'wb') as f:
619 f.write(six.ensure_binary(name))
620- publisher.markPocketDirty(
621+ publisher.markSuiteDirty(
622 self.ubuntutest.getSeries('breezy-autotest'),
623 PackagePublishingPocket.RELEASE)
624
625@@ -2460,8 +2432,7 @@ class TestArchiveIndices(TestPublisherBase):
626 that those in 'absent' are not.
627 """
628
629- self.assertTrue(
630- (series.name, pocket) in publisher.release_files_needed)
631+ self.assertIn(series.getSuite(pocket), publisher.release_files_needed)
632
633 arch_template = os.path.join(
634 publisher._config.distsroot, series.getSuite(pocket), '%s/%s')
635@@ -2774,7 +2745,7 @@ class TestUpdateByHash(TestPublisherBase):
636 # Create the first file.
637 with open_for_writing(suite_path('Contents-i386'), 'w') as f:
638 f.write('A Contents file\n')
639- publisher.markPocketDirty(
640+ publisher.markSuiteDirty(
641 self.breezy_autotest, PackagePublishingPocket.RELEASE)
642 self.runSteps(publisher, step_a=True, step_c=True, step_d=True)
643 flush_database_caches()
644@@ -2880,7 +2851,7 @@ class TestUpdateByHash(TestPublisherBase):
645 self.setUpMockTime()
646
647 # Publish empty index files.
648- publisher.markPocketDirty(
649+ publisher.markSuiteDirty(
650 self.breezy_autotest, PackagePublishingPocket.RELEASE)
651 self.runSteps(publisher, step_a=True, step_c=True, step_d=True)
652 suite_path = partial(
653@@ -2988,7 +2959,7 @@ class TestUpdateByHash(TestPublisherBase):
654 self.ubuntutest.main_archive)
655 self.runSteps(publisher, step_a2=True, step_c=True, step_d=True)
656 transaction.commit()
657- self.assertEqual(set(), publisher.dirty_pockets)
658+ self.assertEqual(set(), publisher.dirty_suites)
659 # The condemned index files are removed, and no new Release file is
660 # generated.
661 expected_suite_files = (
662@@ -3021,7 +2992,7 @@ class TestUpdateByHash(TestPublisherBase):
663 self.ubuntutest.main_archive)
664 self.runSteps(publisher, step_a2=True, step_c=True, step_d=True)
665 transaction.commit()
666- self.assertEqual(set(), publisher.dirty_pockets)
667+ self.assertEqual(set(), publisher.dirty_suites)
668 self.assertEqual(release_mtime, os.stat(release_path).st_mtime)
669 # The condemned index files are removed, and no new Release file is
670 # generated.

Subscribers

People subscribed via source and target branches

to status/vote changes: