Merge ~cjwatson/launchpad:simplify-publisher-suite-sets into launchpad:master
- Git
- lp:~cjwatson/launchpad
- simplify-publisher-suite-sets
- Merge into master
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) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ioana Lasc (community) | 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.
Preview Diff
1 | diff --git a/lib/lp/archivepublisher/model/ftparchive.py b/lib/lp/archivepublisher/model/ftparchive.py | |||
2 | index 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 | 232 | continue | 232 | continue |
7 | 233 | 233 | ||
8 | 234 | self.publisher.release_files_needed.add( | 234 | self.publisher.release_files_needed.add( |
10 | 235 | (distroseries.name, pocket)) | 235 | distroseries.getSuite(pocket)) |
11 | 236 | 236 | ||
12 | 237 | for comp in components: | 237 | for comp in components: |
13 | 238 | self.createEmptyPocketRequest(distroseries, pocket, comp) | 238 | self.createEmptyPocketRequest(distroseries, pocket, comp) |
14 | @@ -768,9 +768,8 @@ class FTPArchiveHandler: | |||
15 | 768 | 768 | ||
16 | 769 | Otherwise, we aim to limit our config to certain distroseries | 769 | Otherwise, we aim to limit our config to certain distroseries |
17 | 770 | and pockets. By default, we will exclude release pockets for | 770 | and pockets. By default, we will exclude release pockets for |
21 | 771 | released series, and in addition we exclude any pocket not | 771 | released series, and in addition we exclude any suite not |
22 | 772 | explicitly marked as dirty. dirty_pockets must be a nested | 772 | explicitly marked as dirty. |
20 | 773 | dictionary of booleans, keyed by distroseries.name then pocket. | ||
23 | 774 | """ | 773 | """ |
24 | 775 | apt_config = six.StringIO() | 774 | apt_config = six.StringIO() |
25 | 776 | apt_config.write(CONFIG_HEADER % (self._config.archiveroot, | 775 | apt_config.write(CONFIG_HEADER % (self._config.archiveroot, |
26 | diff --git a/lib/lp/archivepublisher/publishing.py b/lib/lp/archivepublisher/publishing.py | |||
27 | index 708e9de..6340738 100644 | |||
28 | --- a/lib/lp/archivepublisher/publishing.py | |||
29 | +++ b/lib/lp/archivepublisher/publishing.py | |||
30 | @@ -1,4 +1,4 @@ | |||
32 | 1 | # Copyright 2009-2019 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2009-2021 Canonical Ltd. This software is licensed under the |
33 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
34 | 3 | 3 | ||
35 | 4 | __all__ = [ | 4 | __all__ = [ |
36 | @@ -416,15 +416,16 @@ class Publisher(object): | |||
37 | 416 | 416 | ||
38 | 417 | Publishers need the pool root dir and a DiskPool object. | 417 | Publishers need the pool root dir and a DiskPool object. |
39 | 418 | 418 | ||
43 | 419 | Optionally we can pass a list of tuples, (distroseries.name, pocket), | 419 | Optionally we can pass a list of suite names which will restrict the |
44 | 420 | which will restrict the publisher actions, only suites listed in | 420 | publisher actions; only suites listed in allowed_suites will be |
45 | 421 | allowed_suites will be modified. | 421 | modified. |
46 | 422 | """ | 422 | """ |
47 | 423 | self.log = log | 423 | self.log = log |
48 | 424 | self._config = config | 424 | self._config = config |
49 | 425 | self.distro = archive.distribution | 425 | self.distro = archive.distribution |
50 | 426 | self.archive = archive | 426 | self.archive = archive |
52 | 427 | self.allowed_suites = allowed_suites | 427 | self.allowed_suites = ( |
53 | 428 | None if allowed_suites is None else set(allowed_suites)) | ||
54 | 428 | 429 | ||
55 | 429 | self._diskpool = diskpool | 430 | self._diskpool = diskpool |
56 | 430 | 431 | ||
57 | @@ -433,14 +434,14 @@ class Publisher(object): | |||
58 | 433 | else: | 434 | else: |
59 | 434 | self._library = library | 435 | self._library = library |
60 | 435 | 436 | ||
65 | 436 | # Track which distroseries pockets have been dirtied by a | 437 | # Track which suites have been dirtied by a change, and therefore |
66 | 437 | # change, and therefore need domination/apt-ftparchive work. | 438 | # need domination/apt-ftparchive work. This is a set of suite names |
67 | 438 | # This is a set of tuples in the form (distroseries.name, pocket) | 439 | # as returned by DistroSeries.getSuite. |
68 | 439 | self.dirty_pockets = set() | 440 | self.dirty_suites = set() |
69 | 440 | 441 | ||
73 | 441 | # Track which pockets need release files. This will contain more | 442 | # Track which suites need release files. This will contain more |
74 | 442 | # than dirty_pockets in the case of a careful index run. | 443 | # than dirty_suites in the case of a careful index run. |
75 | 443 | # This is a set of tuples in the form (distroseries.name, pocket) | 444 | # This is a set of suite names as returned by DistroSeries.getSuite. |
76 | 444 | self.release_files_needed = set() | 445 | self.release_files_needed = set() |
77 | 445 | 446 | ||
78 | 446 | def setupArchiveDirs(self): | 447 | def setupArchiveDirs(self): |
79 | @@ -449,12 +450,12 @@ class Publisher(object): | |||
80 | 449 | 450 | ||
81 | 450 | def isDirty(self, distroseries, pocket): | 451 | def isDirty(self, distroseries, pocket): |
82 | 451 | """True if a publication has happened in this release and pocket.""" | 452 | """True if a publication has happened in this release and pocket.""" |
84 | 452 | return (distroseries.name, pocket) in self.dirty_pockets | 453 | return distroseries.getSuite(pocket) in self.dirty_suites |
85 | 453 | 454 | ||
88 | 454 | def markPocketDirty(self, distroseries, pocket): | 455 | def markSuiteDirty(self, distroseries, pocket): |
89 | 455 | """Mark a pocket dirty only if it's allowed.""" | 456 | """Mark a suite dirty only if it's allowed.""" |
90 | 456 | if self.isAllowed(distroseries, pocket): | 457 | if self.isAllowed(distroseries, pocket): |
92 | 457 | self.dirty_pockets.add((distroseries.name, pocket)) | 458 | self.dirty_suites.add(distroseries.getSuite(pocket)) |
93 | 458 | 459 | ||
94 | 459 | def isAllowed(self, distroseries, pocket): | 460 | def isAllowed(self, distroseries, pocket): |
95 | 460 | """Whether or not the given suite should be considered. | 461 | """Whether or not the given suite should be considered. |
96 | @@ -465,7 +466,7 @@ class Publisher(object): | |||
97 | 465 | Otherwise, return False. | 466 | Otherwise, return False. |
98 | 466 | """ | 467 | """ |
99 | 467 | return (not self.allowed_suites or | 468 | return (not self.allowed_suites or |
101 | 468 | (distroseries.name, pocket) in self.allowed_suites) | 469 | distroseries.getSuite(pocket) in self.allowed_suites) |
102 | 469 | 470 | ||
103 | 470 | @property | 471 | @property |
104 | 471 | def subcomponents(self): | 472 | def subcomponents(self): |
105 | @@ -546,7 +547,7 @@ class Publisher(object): | |||
106 | 546 | 547 | ||
107 | 547 | Consider records returned by getPendingSourcePublications. | 548 | Consider records returned by getPendingSourcePublications. |
108 | 548 | """ | 549 | """ |
110 | 549 | dirty_pockets = set() | 550 | dirty_suites = set() |
111 | 550 | all_spphs = self.getPendingSourcePublications(is_careful) | 551 | all_spphs = self.getPendingSourcePublications(is_careful) |
112 | 551 | for (distroseries, pocket), spphs in groupby( | 552 | for (distroseries, pocket), spphs in groupby( |
113 | 552 | all_spphs, attrgetter("distroseries", "pocket")): | 553 | all_spphs, attrgetter("distroseries", "pocket")): |
114 | @@ -561,8 +562,8 @@ class Publisher(object): | |||
115 | 561 | distroseries.status.name)) | 562 | distroseries.status.name)) |
116 | 562 | else: | 563 | else: |
117 | 563 | self.publishSources(distroseries, pocket, spphs) | 564 | self.publishSources(distroseries, pocket, spphs) |
120 | 564 | dirty_pockets.add((distroseries.name, pocket)) | 565 | dirty_suites.add(distroseries.getSuite(pocket)) |
121 | 565 | return dirty_pockets | 566 | return dirty_suites |
122 | 566 | 567 | ||
123 | 567 | def getPendingBinaryPublications(self, is_careful): | 568 | def getPendingBinaryPublications(self, is_careful): |
124 | 568 | """Return the specific group of binary records to be published.""" | 569 | """Return the specific group of binary records to be published.""" |
125 | @@ -602,7 +603,7 @@ class Publisher(object): | |||
126 | 602 | 603 | ||
127 | 603 | Consider records returned by getPendingBinaryPublications. | 604 | Consider records returned by getPendingBinaryPublications. |
128 | 604 | """ | 605 | """ |
130 | 605 | dirty_pockets = set() | 606 | dirty_suites = set() |
131 | 606 | all_bpphs = self.getPendingBinaryPublications(is_careful) | 607 | all_bpphs = self.getPendingBinaryPublications(is_careful) |
132 | 607 | for (distroarchseries, pocket), bpphs in groupby( | 608 | for (distroarchseries, pocket), bpphs in groupby( |
133 | 608 | all_bpphs, attrgetter("distroarchseries", "pocket")): | 609 | all_bpphs, attrgetter("distroarchseries", "pocket")): |
134 | @@ -618,8 +619,8 @@ class Publisher(object): | |||
135 | 618 | distroseries.status.name)) | 619 | distroseries.status.name)) |
136 | 619 | else: | 620 | else: |
137 | 620 | self.publishBinaries(distroarchseries, pocket, bpphs) | 621 | self.publishBinaries(distroarchseries, pocket, bpphs) |
140 | 621 | dirty_pockets.add((distroseries.name, pocket)) | 622 | dirty_suites.add(distroseries.getSuite(pocket)) |
141 | 622 | return dirty_pockets | 623 | return dirty_suites |
142 | 623 | 624 | ||
143 | 624 | def A_publish(self, force_publishing): | 625 | def A_publish(self, force_publishing): |
144 | 625 | """First step in publishing: actual package publishing. | 626 | """First step in publishing: actual package publishing. |
145 | @@ -631,9 +632,9 @@ class Publisher(object): | |||
146 | 631 | """ | 632 | """ |
147 | 632 | self.log.debug("* Step A: Publishing packages") | 633 | self.log.debug("* Step A: Publishing packages") |
148 | 633 | 634 | ||
150 | 634 | self.dirty_pockets.update( | 635 | self.dirty_suites.update( |
151 | 635 | self.findAndPublishSources(is_careful=force_publishing)) | 636 | self.findAndPublishSources(is_careful=force_publishing)) |
153 | 636 | self.dirty_pockets.update( | 637 | self.dirty_suites.update( |
154 | 637 | self.findAndPublishBinaries(is_careful=force_publishing)) | 638 | self.findAndPublishBinaries(is_careful=force_publishing)) |
155 | 638 | 639 | ||
156 | 639 | def A2_markPocketsWithDeletionsDirty(self): | 640 | def A2_markPocketsWithDeletionsDirty(self): |
157 | @@ -654,9 +655,9 @@ class Publisher(object): | |||
158 | 654 | table.dateremoved == None, | 655 | table.dateremoved == None, |
159 | 655 | ] | 656 | ] |
160 | 656 | 657 | ||
164 | 657 | # We need to get a set of (distroseries, pocket) tuples that have | 658 | # We need to get a set of suite names that have publications that |
165 | 658 | # publications that are waiting to be deleted. Each tuple is | 659 | # are waiting to be deleted. Each suite name is added to the |
166 | 659 | # added to the dirty_pockets set. | 660 | # dirty_suites set. |
167 | 660 | 661 | ||
168 | 661 | # Make the source publications query. | 662 | # Make the source publications query. |
169 | 662 | conditions = base_conditions(SourcePackagePublishingHistory) | 663 | conditions = base_conditions(SourcePackagePublishingHistory) |
170 | @@ -688,7 +689,7 @@ class Publisher(object): | |||
171 | 688 | # stable distroseries, no matter what other bugs | 689 | # stable distroseries, no matter what other bugs |
172 | 689 | # that precede here have dirtied it. | 690 | # that precede here have dirtied it. |
173 | 690 | continue | 691 | continue |
175 | 691 | self.markPocketDirty(distroseries, pocket) | 692 | self.markSuiteDirty(distroseries, pocket) |
176 | 692 | 693 | ||
177 | 693 | def B_dominate(self, force_domination): | 694 | def B_dominate(self, force_domination): |
178 | 694 | """Second step in publishing: domination.""" | 695 | """Second step in publishing: domination.""" |
179 | @@ -729,7 +730,7 @@ class Publisher(object): | |||
180 | 729 | continue | 730 | continue |
181 | 730 | self.checkDirtySuiteBeforePublishing(distroseries, pocket) | 731 | self.checkDirtySuiteBeforePublishing(distroseries, pocket) |
182 | 731 | 732 | ||
184 | 732 | self.release_files_needed.add((distroseries.name, pocket)) | 733 | self.release_files_needed.add(distroseries.getSuite(pocket)) |
185 | 733 | 734 | ||
186 | 734 | components = self.archive.getComponentsForSeries(distroseries) | 735 | components = self.archive.getComponentsForSeries(distroseries) |
187 | 735 | for component in components: | 736 | for component in components: |
188 | @@ -739,9 +740,9 @@ class Publisher(object): | |||
189 | 739 | def D_writeReleaseFiles(self, is_careful): | 740 | def D_writeReleaseFiles(self, is_careful): |
190 | 740 | """Write out the Release files for the provided distribution. | 741 | """Write out the Release files for the provided distribution. |
191 | 741 | 742 | ||
193 | 742 | If is_careful is specified, we include all pockets of all releases. | 743 | If is_careful is specified, we include all suites. |
194 | 743 | 744 | ||
196 | 744 | Otherwise we include only pockets flagged as true in dirty_pockets. | 745 | Otherwise we include only suites flagged as true in dirty_suites. |
197 | 745 | """ | 746 | """ |
198 | 746 | self.log.debug("* Step D: Generating Release files.") | 747 | self.log.debug("* Step D: Generating Release files.") |
199 | 747 | 748 | ||
200 | @@ -750,11 +751,10 @@ class Publisher(object): | |||
201 | 750 | self.archive, container_prefix=u"release:"): | 751 | self.archive, container_prefix=u"release:"): |
202 | 751 | distroseries, pocket = self.distro.getDistroSeriesAndPocket( | 752 | distroseries, pocket = self.distro.getDistroSeriesAndPocket( |
203 | 752 | container[len(u"release:"):]) | 753 | container[len(u"release:"):]) |
205 | 753 | archive_file_suites.add((distroseries.name, pocket)) | 754 | archive_file_suites.add(distroseries.getSuite(pocket)) |
206 | 754 | 755 | ||
207 | 755 | for distroseries in self.distro: | 756 | for distroseries in self.distro: |
208 | 756 | for pocket in self.archive.getPockets(): | 757 | for pocket in self.archive.getPockets(): |
209 | 757 | ds_pocket = (distroseries.name, pocket) | ||
210 | 758 | suite = distroseries.getSuite(pocket) | 758 | suite = distroseries.getSuite(pocket) |
211 | 759 | suite_path = os.path.join(self._config.distsroot, suite) | 759 | suite_path = os.path.join(self._config.distsroot, suite) |
212 | 760 | release_path = os.path.join(suite_path, "Release") | 760 | release_path = os.path.join(suite_path, "Release") |
213 | @@ -768,9 +768,9 @@ class Publisher(object): | |||
214 | 768 | # suites. Only force those suites that already have | 768 | # suites. Only force those suites that already have |
215 | 769 | # Release files. | 769 | # Release files. |
216 | 770 | if file_exists(release_path): | 770 | if file_exists(release_path): |
218 | 771 | self.release_files_needed.add(ds_pocket) | 771 | self.release_files_needed.add(suite) |
219 | 772 | 772 | ||
221 | 773 | write_release = ds_pocket in self.release_files_needed | 773 | write_release = suite in self.release_files_needed |
222 | 774 | if not is_careful: | 774 | if not is_careful: |
223 | 775 | if not self.isDirty(distroseries, pocket): | 775 | if not self.isDirty(distroseries, pocket): |
224 | 776 | self.log.debug("Skipping release files for %s/%s" % | 776 | self.log.debug("Skipping release files for %s/%s" % |
225 | @@ -782,7 +782,7 @@ class Publisher(object): | |||
226 | 782 | 782 | ||
227 | 783 | if write_release: | 783 | if write_release: |
228 | 784 | self._writeSuite(distroseries, pocket) | 784 | self._writeSuite(distroseries, pocket) |
230 | 785 | elif (ds_pocket in archive_file_suites and | 785 | elif (suite in archive_file_suites and |
231 | 786 | distroseries.publish_by_hash): | 786 | distroseries.publish_by_hash): |
232 | 787 | # We aren't publishing a new Release file for this | 787 | # We aren't publishing a new Release file for this |
233 | 788 | # suite, probably because it's immutable, but we still | 788 | # suite, probably because it's immutable, but we still |
234 | diff --git a/lib/lp/archivepublisher/scripts/publishdistro.py b/lib/lp/archivepublisher/scripts/publishdistro.py | |||
235 | index 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 | 233 | suites = set() | 233 | suites = set() |
240 | 234 | for suite in self.options.suite: | 234 | for suite in self.options.suite: |
241 | 235 | series, pocket = self.findSuite(distribution, suite) | 235 | series, pocket = self.findSuite(distribution, suite) |
243 | 236 | suites.add((series.name, pocket)) | 236 | suites.add(series.getSuite(pocket)) |
244 | 237 | return suites | 237 | return suites |
245 | 238 | 238 | ||
246 | 239 | def findExplicitlyDirtySuites(self, archive): | 239 | def findExplicitlyDirtySuites(self, archive): |
247 | @@ -311,7 +311,7 @@ class PublishDistro(PublisherScript): | |||
248 | 311 | """ | 311 | """ |
249 | 312 | for distroseries, pocket in self.findExplicitlyDirtySuites(archive): | 312 | for distroseries, pocket in self.findExplicitlyDirtySuites(archive): |
250 | 313 | if not cannot_modify_suite(archive, distroseries, pocket): | 313 | if not cannot_modify_suite(archive, distroseries, pocket): |
252 | 314 | publisher.markPocketDirty(distroseries, pocket) | 314 | publisher.markSuiteDirty(distroseries, pocket) |
253 | 315 | if archive.dirty_suites is not None: | 315 | if archive.dirty_suites is not None: |
254 | 316 | # Clear the explicit dirt indicator before we start doing | 316 | # Clear the explicit dirt indicator before we start doing |
255 | 317 | # time-consuming publishing, which might race with an | 317 | # time-consuming publishing, which might race with an |
256 | diff --git a/lib/lp/archivepublisher/tests/test_ftparchive.py b/lib/lp/archivepublisher/tests/test_ftparchive.py | |||
257 | index 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 | 582 | # * a-f runs based on this config without any errors | 582 | # * a-f runs based on this config without any errors |
262 | 583 | # * a-f *only* creates the wanted archive indexes. | 583 | # * a-f *only* creates the wanted archive indexes. |
263 | 584 | allowed_suites = set() | 584 | allowed_suites = set() |
265 | 585 | allowed_suites.add(('hoary-test', PackagePublishingPocket.UPDATES)) | 585 | allowed_suites.add('hoary-test-updates') |
266 | 586 | 586 | ||
267 | 587 | publisher = Publisher( | 587 | publisher = Publisher( |
268 | 588 | self._logger, self._config, self._dp, | 588 | self._logger, self._config, self._dp, |
269 | diff --git a/lib/lp/archivepublisher/tests/test_publishdistro.py b/lib/lp/archivepublisher/tests/test_publishdistro.py | |||
270 | index 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 | 117 | foo_path = "%s/main/f/foo/foo_666.dsc" % self.pool_dir | 117 | foo_path = "%s/main/f/foo/foo_666.dsc" % self.pool_dir |
275 | 118 | self.assertEqual(open(foo_path).read().strip(), 'foo') | 118 | self.assertEqual(open(foo_path).read().strip(), 'foo') |
276 | 119 | 119 | ||
279 | 120 | def testDirtyPocketProcessing(self): | 120 | def testDirtySuiteProcessing(self): |
280 | 121 | """Test dirty pocket processing. | 121 | """Test dirty suite processing. |
281 | 122 | 122 | ||
284 | 123 | Make a DELETED source to see if the dirty pocket processing | 123 | Make a DELETED source to see if the dirty suite processing works for |
285 | 124 | works for deletions. | 124 | deletions. |
286 | 125 | """ | 125 | """ |
287 | 126 | pub_source_id = self.getPubSource(filecontent=b'foo').id | 126 | pub_source_id = self.getPubSource(filecontent=b'foo').id |
288 | 127 | self.layer.txn.commit() | 127 | self.layer.txn.commit() |
289 | @@ -717,14 +717,13 @@ class TestPublishDistroMethods(TestCaseWithFactory): | |||
290 | 717 | script = self.makeScript(distro) | 717 | script = self.makeScript(distro) |
291 | 718 | self.assertContentEqual([], script.findAllowedSuites(distro)) | 718 | self.assertContentEqual([], script.findAllowedSuites(distro)) |
292 | 719 | 719 | ||
295 | 720 | def test_findAllowedSuites_finds_series_and_pocket(self): | 720 | def test_findAllowedSuites_finds_single(self): |
296 | 721 | # findAllowedSuites looks up the requested suites. | 721 | # findAllowedSuites looks up the requested suite. |
297 | 722 | series = self.factory.makeDistroSeries() | 722 | series = self.factory.makeDistroSeries() |
298 | 723 | suite = "%s-updates" % series.name | 723 | suite = "%s-updates" % series.name |
299 | 724 | script = self.makeScript(series.distribution, ['--suite', suite]) | 724 | script = self.makeScript(series.distribution, ['--suite', suite]) |
300 | 725 | self.assertContentEqual( | 725 | self.assertContentEqual( |
303 | 726 | [(series.name, PackagePublishingPocket.UPDATES)], | 726 | [suite], script.findAllowedSuites(series.distribution)) |
302 | 727 | script.findAllowedSuites(series.distribution)) | ||
304 | 728 | 727 | ||
305 | 729 | def test_findAllowedSuites_finds_multiple(self): | 728 | def test_findAllowedSuites_finds_multiple(self): |
306 | 730 | # Multiple suites may be requested; findAllowedSuites looks them | 729 | # Multiple suites may be requested; findAllowedSuites looks them |
307 | @@ -733,10 +732,7 @@ class TestPublishDistroMethods(TestCaseWithFactory): | |||
308 | 733 | script = self.makeScript(series.distribution, [ | 732 | script = self.makeScript(series.distribution, [ |
309 | 734 | '--suite', '%s-updates' % series.name, | 733 | '--suite', '%s-updates' % series.name, |
310 | 735 | '--suite', series.name]) | 734 | '--suite', series.name]) |
315 | 736 | expected_suites = [ | 735 | expected_suites = ['%s-updates' % series.name, series.name] |
312 | 737 | (series.name, PackagePublishingPocket.UPDATES), | ||
313 | 738 | (series.name, PackagePublishingPocket.RELEASE), | ||
314 | 739 | ] | ||
316 | 740 | self.assertContentEqual( | 736 | self.assertContentEqual( |
317 | 741 | expected_suites, script.findAllowedSuites(series.distribution)) | 737 | expected_suites, script.findAllowedSuites(series.distribution)) |
318 | 742 | 738 | ||
319 | diff --git a/lib/lp/archivepublisher/tests/test_publisher.py b/lib/lp/archivepublisher/tests/test_publisher.py | |||
320 | index 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 @@ | |||
325 | 1 | # Copyright 2009-2020 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2009-2021 Canonical Ltd. This software is licensed under the |
326 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
327 | 3 | 3 | ||
328 | 4 | """Tests for publisher class.""" | 4 | """Tests for publisher class.""" |
329 | @@ -720,11 +720,6 @@ class TestByHashes(TestCaseWithFactory): | |||
330 | 720 | class TestPublisher(TestPublisherBase): | 720 | class TestPublisher(TestPublisherBase): |
331 | 721 | """Testing `Publisher` behaviour.""" | 721 | """Testing `Publisher` behaviour.""" |
332 | 722 | 722 | ||
333 | 723 | def assertDirtyPocketsContents(self, expected, dirty_pockets): | ||
334 | 724 | contents = [(str(dr_name), pocket.name) for dr_name, pocket in | ||
335 | 725 | dirty_pockets] | ||
336 | 726 | self.assertEqual(expected, contents) | ||
337 | 727 | |||
338 | 728 | def assertReleaseContentsMatch(self, release, filename, contents): | 723 | def assertReleaseContentsMatch(self, release, filename, contents): |
339 | 729 | for hash_name, hash_func in ( | 724 | for hash_name, hash_func in ( |
340 | 730 | ('md5sum', hashlib.md5), | 725 | ('md5sum', hashlib.md5), |
341 | @@ -766,8 +761,7 @@ class TestPublisher(TestPublisherBase): | |||
342 | 766 | self.layer.txn.commit() | 761 | self.layer.txn.commit() |
343 | 767 | 762 | ||
344 | 768 | pub_source.sync() | 763 | pub_source.sync() |
347 | 769 | self.assertDirtyPocketsContents( | 764 | self.assertEqual({'breezy-autotest'}, publisher.dirty_suites) |
346 | 770 | [('breezy-autotest', 'RELEASE')], publisher.dirty_pockets) | ||
348 | 771 | self.assertEqual(PackagePublishingStatus.PUBLISHED, pub_source.status) | 765 | self.assertEqual(PackagePublishingStatus.PUBLISHED, pub_source.status) |
349 | 772 | 766 | ||
350 | 773 | # file got published | 767 | # file got published |
351 | @@ -972,8 +966,7 @@ class TestPublisher(TestPublisherBase): | |||
352 | 972 | publisher.A_publish(force_publishing=False) | 966 | publisher.A_publish(force_publishing=False) |
353 | 973 | 967 | ||
354 | 974 | # The pocket was dirtied: | 968 | # The pocket was dirtied: |
357 | 975 | self.assertDirtyPocketsContents( | 969 | self.assertEqual({'breezy-autotest'}, publisher.dirty_suites) |
356 | 976 | [('breezy-autotest', 'RELEASE')], publisher.dirty_pockets) | ||
358 | 977 | # The file was published: | 970 | # The file was published: |
359 | 978 | foo_path = "%s/main/f/foo/foo_666.dsc" % pub_config.poolroot | 971 | foo_path = "%s/main/f/foo/foo_666.dsc" % pub_config.poolroot |
360 | 979 | with open(foo_path) as foo_file: | 972 | with open(foo_path) as foo_file: |
361 | @@ -993,8 +986,7 @@ class TestPublisher(TestPublisherBase): | |||
362 | 993 | """ | 986 | """ |
363 | 994 | publisher = Publisher( | 987 | publisher = Publisher( |
364 | 995 | self.logger, self.config, self.disk_pool, | 988 | self.logger, self.config, self.disk_pool, |
367 | 996 | self.ubuntutest.main_archive, | 989 | self.ubuntutest.main_archive, allowed_suites=['hoary-test']) |
366 | 997 | allowed_suites=[('hoary-test', PackagePublishingPocket.RELEASE)]) | ||
368 | 998 | 990 | ||
369 | 999 | pub_source = self.getPubSource(filecontent=b'foo') | 991 | pub_source = self.getPubSource(filecontent=b'foo') |
370 | 1000 | pub_source2 = self.getPubSource( | 992 | pub_source2 = self.getPubSource( |
371 | @@ -1006,8 +998,7 @@ class TestPublisher(TestPublisherBase): | |||
372 | 1006 | 998 | ||
373 | 1007 | pub_source.sync() | 999 | pub_source.sync() |
374 | 1008 | pub_source2.sync() | 1000 | pub_source2.sync() |
377 | 1009 | self.assertDirtyPocketsContents( | 1001 | self.assertEqual({'hoary-test'}, publisher.dirty_suites) |
376 | 1010 | [('hoary-test', 'RELEASE')], publisher.dirty_pockets) | ||
378 | 1011 | self.assertEqual( | 1002 | self.assertEqual( |
379 | 1012 | PackagePublishingStatus.PUBLISHED, pub_source2.status) | 1003 | PackagePublishingStatus.PUBLISHED, pub_source2.status) |
380 | 1013 | self.assertEqual(PackagePublishingStatus.PENDING, pub_source.status) | 1004 | self.assertEqual(PackagePublishingStatus.PENDING, pub_source.status) |
381 | @@ -1020,8 +1011,7 @@ class TestPublisher(TestPublisherBase): | |||
382 | 1020 | publisher = Publisher( | 1011 | publisher = Publisher( |
383 | 1021 | self.logger, self.config, self.disk_pool, | 1012 | self.logger, self.config, self.disk_pool, |
384 | 1022 | self.ubuntutest.main_archive, | 1013 | self.ubuntutest.main_archive, |
387 | 1023 | allowed_suites=[('breezy-autotest', | 1014 | allowed_suites=['breezy-autotest-updates']) |
386 | 1024 | PackagePublishingPocket.UPDATES)]) | ||
388 | 1025 | 1015 | ||
389 | 1026 | self.ubuntutest['breezy-autotest'].status = ( | 1016 | self.ubuntutest['breezy-autotest'].status = ( |
390 | 1027 | SeriesStatus.CURRENT) | 1017 | SeriesStatus.CURRENT) |
391 | @@ -1039,8 +1029,7 @@ class TestPublisher(TestPublisherBase): | |||
392 | 1039 | 1029 | ||
393 | 1040 | pub_source.sync() | 1030 | pub_source.sync() |
394 | 1041 | pub_source2.sync() | 1031 | pub_source2.sync() |
397 | 1042 | self.assertDirtyPocketsContents( | 1032 | self.assertEqual({'breezy-autotest-updates'}, publisher.dirty_suites) |
396 | 1043 | [('breezy-autotest', 'UPDATES')], publisher.dirty_pockets) | ||
398 | 1044 | self.assertEqual(PackagePublishingStatus.PUBLISHED, pub_source.status) | 1033 | self.assertEqual(PackagePublishingStatus.PUBLISHED, pub_source.status) |
399 | 1045 | self.assertEqual(PackagePublishingStatus.PENDING, pub_source2.status) | 1034 | self.assertEqual(PackagePublishingStatus.PENDING, pub_source2.status) |
400 | 1046 | 1035 | ||
401 | @@ -1059,7 +1048,7 @@ class TestPublisher(TestPublisherBase): | |||
402 | 1059 | # no pockets will be *dirtied*. | 1048 | # no pockets will be *dirtied*. |
403 | 1060 | publisher.A_publish(False) | 1049 | publisher.A_publish(False) |
404 | 1061 | 1050 | ||
406 | 1062 | self.assertDirtyPocketsContents([], publisher.dirty_pockets) | 1051 | self.assertEqual(set(), publisher.dirty_suites) |
407 | 1063 | # nothing got published | 1052 | # nothing got published |
408 | 1064 | foo_path = "%s/main/f/foo/foo_666.dsc" % self.pool_dir | 1053 | foo_path = "%s/main/f/foo/foo_666.dsc" % self.pool_dir |
409 | 1065 | self.assertEqual(False, os.path.exists(foo_path)) | 1054 | self.assertEqual(False, os.path.exists(foo_path)) |
410 | @@ -1087,8 +1076,7 @@ class TestPublisher(TestPublisherBase): | |||
411 | 1087 | # then we will have a corresponding dirty_pocket entry. | 1076 | # then we will have a corresponding dirty_pocket entry. |
412 | 1088 | publisher.A_publish(True) | 1077 | publisher.A_publish(True) |
413 | 1089 | 1078 | ||
416 | 1090 | self.assertDirtyPocketsContents( | 1079 | self.assertEqual({'breezy-autotest'}, publisher.dirty_suites) |
415 | 1091 | [('breezy-autotest', 'RELEASE')], publisher.dirty_pockets) | ||
417 | 1092 | # file got published | 1080 | # file got published |
418 | 1093 | foo_path = "%s/main/f/foo/foo_666.dsc" % self.pool_dir | 1081 | foo_path = "%s/main/f/foo/foo_666.dsc" % self.pool_dir |
419 | 1094 | with open(foo_path) as foo_file: | 1082 | with open(foo_path) as foo_file: |
420 | @@ -1115,7 +1103,7 @@ class TestPublisher(TestPublisherBase): | |||
421 | 1115 | publisher.A_publish(False) | 1103 | publisher.A_publish(False) |
422 | 1116 | self.layer.txn.commit() | 1104 | self.layer.txn.commit() |
423 | 1117 | 1105 | ||
425 | 1118 | self.assertDirtyPocketsContents([], publisher.dirty_pockets) | 1106 | self.assertEqual(set(), publisher.dirty_suites) |
426 | 1119 | self.assertEqual(PackagePublishingStatus.PENDING, pub_source.status) | 1107 | self.assertEqual(PackagePublishingStatus.PENDING, pub_source.status) |
427 | 1120 | 1108 | ||
428 | 1121 | # nothing got published | 1109 | # nothing got published |
429 | @@ -1146,8 +1134,7 @@ class TestPublisher(TestPublisherBase): | |||
430 | 1146 | self.layer.txn.commit() | 1134 | self.layer.txn.commit() |
431 | 1147 | 1135 | ||
432 | 1148 | pub_source.sync() | 1136 | pub_source.sync() |
435 | 1149 | self.assertDirtyPocketsContents( | 1137 | self.assertEqual({'breezy-autotest'}, publisher.dirty_suites) |
434 | 1150 | [('breezy-autotest', 'RELEASE')], publisher.dirty_pockets) | ||
436 | 1151 | self.assertEqual(PackagePublishingStatus.PUBLISHED, pub_source.status) | 1138 | self.assertEqual(PackagePublishingStatus.PUBLISHED, pub_source.status) |
437 | 1152 | 1139 | ||
438 | 1153 | # nothing got published | 1140 | # nothing got published |
439 | @@ -1224,8 +1211,7 @@ class TestPublisher(TestPublisherBase): | |||
440 | 1224 | helper function: 'getPublisher' | 1211 | helper function: 'getPublisher' |
441 | 1225 | """ | 1212 | """ |
442 | 1226 | # Stub parameters. | 1213 | # Stub parameters. |
445 | 1227 | allowed_suites = [ | 1214 | allowed_suites = ['breezy-autotest'] |
444 | 1228 | ('breezy-autotest', PackagePublishingPocket.RELEASE)] | ||
446 | 1229 | 1215 | ||
447 | 1230 | distro_publisher = getPublisher( | 1216 | distro_publisher = getPublisher( |
448 | 1231 | self.ubuntutest.main_archive, allowed_suites, self.logger) | 1217 | self.ubuntutest.main_archive, allowed_suites, self.logger) |
449 | @@ -1236,9 +1222,7 @@ class TestPublisher(TestPublisherBase): | |||
450 | 1236 | self.assertEqual( | 1222 | self.assertEqual( |
451 | 1237 | '/var/tmp/archive/ubuntutest/dists', | 1223 | '/var/tmp/archive/ubuntutest/dists', |
452 | 1238 | distro_publisher._config.distsroot) | 1224 | distro_publisher._config.distsroot) |
456 | 1239 | self.assertEqual( | 1225 | self.assertEqual({'breezy-autotest'}, distro_publisher.allowed_suites) |
454 | 1240 | [('breezy-autotest', PackagePublishingPocket.RELEASE)], | ||
455 | 1241 | distro_publisher.allowed_suites) | ||
457 | 1242 | 1226 | ||
458 | 1243 | # Check that the partner archive is built in a different directory | 1227 | # Check that the partner archive is built in a different directory |
459 | 1244 | # to the primary archive. | 1228 | # to the primary archive. |
460 | @@ -1263,9 +1247,7 @@ class TestPublisher(TestPublisherBase): | |||
461 | 1263 | self.assertEqual( | 1247 | self.assertEqual( |
462 | 1264 | '/var/tmp/ppa.test/cprov/ppa/ubuntutest/dists', | 1248 | '/var/tmp/ppa.test/cprov/ppa/ubuntutest/dists', |
463 | 1265 | archive_publisher._config.distsroot) | 1249 | archive_publisher._config.distsroot) |
467 | 1266 | self.assertEqual( | 1250 | self.assertEqual({'breezy-autotest'}, archive_publisher.allowed_suites) |
465 | 1267 | [('breezy-autotest', PackagePublishingPocket.RELEASE)], | ||
466 | 1268 | archive_publisher.allowed_suites) | ||
468 | 1269 | 1251 | ||
469 | 1270 | def testPendingArchive(self): | 1252 | def testPendingArchive(self): |
470 | 1271 | """Check Pending Archive Lookup. | 1253 | """Check Pending Archive Lookup. |
471 | @@ -1537,9 +1519,8 @@ class TestPublisher(TestPublisherBase): | |||
472 | 1537 | index_contents) | 1519 | index_contents) |
473 | 1538 | 1520 | ||
474 | 1539 | # We always regenerate all Releases file for a given suite. | 1521 | # We always regenerate all Releases file for a given suite. |
478 | 1540 | self.assertTrue( | 1522 | self.assertIn( |
479 | 1541 | ('breezy-autotest', PackagePublishingPocket.RELEASE) in | 1523 | 'breezy-autotest', archive_publisher.release_files_needed) |
477 | 1542 | archive_publisher.release_files_needed) | ||
480 | 1543 | 1524 | ||
481 | 1544 | # Confirm that i18n files are not created | 1525 | # Confirm that i18n files are not created |
482 | 1545 | i18n_path = os.path.join(archive_publisher._config.distsroot, | 1526 | i18n_path = os.path.join(archive_publisher._config.distsroot, |
483 | @@ -1686,9 +1667,8 @@ class TestPublisher(TestPublisherBase): | |||
484 | 1686 | index_contents) | 1667 | index_contents) |
485 | 1687 | 1668 | ||
486 | 1688 | # We always regenerate all Releases file for a given suite. | 1669 | # We always regenerate all Releases file for a given suite. |
490 | 1689 | self.assertTrue( | 1670 | self.assertIn( |
491 | 1690 | ('breezy-autotest', PackagePublishingPocket.RELEASE) in | 1671 | 'breezy-autotest', archive_publisher.release_files_needed) |
489 | 1691 | archive_publisher.release_files_needed) | ||
492 | 1692 | 1672 | ||
493 | 1693 | # Various compressed Translation-en files are written; ensure that | 1673 | # Various compressed Translation-en files are written; ensure that |
494 | 1694 | # they are the same after decompression. | 1674 | # they are the same after decompression. |
495 | @@ -1762,11 +1742,6 @@ class TestPublisher(TestPublisherBase): | |||
496 | 1762 | self._checkCompressedFiles( | 1742 | self._checkCompressedFiles( |
497 | 1763 | archive_publisher, uncompressed_file_path, ['.xz']) | 1743 | archive_publisher, uncompressed_file_path, ['.xz']) |
498 | 1764 | 1744 | ||
499 | 1765 | def checkDirtyPockets(self, publisher, expected): | ||
500 | 1766 | """Check dirty_pockets contents of a given publisher.""" | ||
501 | 1767 | sorted_dirty_pockets = sorted(list(publisher.dirty_pockets)) | ||
502 | 1768 | self.assertEqual(expected, sorted_dirty_pockets) | ||
503 | 1769 | |||
504 | 1770 | def testDirtyingPocketsWithDeletedPackages(self): | 1745 | def testDirtyingPocketsWithDeletedPackages(self): |
505 | 1771 | """Test that dirtying pockets with deleted packages works. | 1746 | """Test that dirtying pockets with deleted packages works. |
506 | 1772 | 1747 | ||
507 | @@ -1779,7 +1754,7 @@ class TestPublisher(TestPublisherBase): | |||
508 | 1779 | self.ubuntutest.main_archive, allowed_suites, self.logger) | 1754 | self.ubuntutest.main_archive, allowed_suites, self.logger) |
509 | 1780 | 1755 | ||
510 | 1781 | publisher.A2_markPocketsWithDeletionsDirty() | 1756 | publisher.A2_markPocketsWithDeletionsDirty() |
512 | 1782 | self.checkDirtyPockets(publisher, expected=[]) | 1757 | self.assertEqual(set(), publisher.dirty_suites) |
513 | 1783 | 1758 | ||
514 | 1784 | # Make a published source, a deleted source in the release | 1759 | # Make a published source, a deleted source in the release |
515 | 1785 | # pocket, a source that's been removed from disk and one that's | 1760 | # pocket, a source that's been removed from disk and one that's |
516 | @@ -1811,27 +1786,27 @@ class TestPublisher(TestPublisherBase): | |||
517 | 1811 | # Run the deletion detection. | 1786 | # Run the deletion detection. |
518 | 1812 | publisher.A2_markPocketsWithDeletionsDirty() | 1787 | publisher.A2_markPocketsWithDeletionsDirty() |
519 | 1813 | 1788 | ||
527 | 1814 | # Only the pockets with pending deletions are marked as dirty. | 1789 | # Only the suites with pending deletions are marked as dirty. |
528 | 1815 | expected_dirty_pockets = [ | 1790 | expected_dirty_suites = { |
529 | 1816 | ('breezy-autotest', PackagePublishingPocket.RELEASE), | 1791 | 'breezy-autotest', |
530 | 1817 | ('breezy-autotest', PackagePublishingPocket.SECURITY), | 1792 | 'breezy-autotest-security', |
531 | 1818 | ('breezy-autotest', PackagePublishingPocket.BACKPORTS), | 1793 | 'breezy-autotest-backports', |
532 | 1819 | ] | 1794 | } |
533 | 1820 | self.checkDirtyPockets(publisher, expected=expected_dirty_pockets) | 1795 | self.assertEqual(expected_dirty_suites, publisher.dirty_suites) |
534 | 1821 | 1796 | ||
535 | 1822 | # If the distroseries is CURRENT, then the release pocket is not | 1797 | # If the distroseries is CURRENT, then the release pocket is not |
536 | 1823 | # marked as dirty. | 1798 | # marked as dirty. |
537 | 1824 | self.ubuntutest['breezy-autotest'].status = ( | 1799 | self.ubuntutest['breezy-autotest'].status = ( |
538 | 1825 | SeriesStatus.CURRENT) | 1800 | SeriesStatus.CURRENT) |
539 | 1826 | 1801 | ||
541 | 1827 | publisher.dirty_pockets = set() | 1802 | publisher.dirty_suites = set() |
542 | 1828 | publisher.A2_markPocketsWithDeletionsDirty() | 1803 | publisher.A2_markPocketsWithDeletionsDirty() |
543 | 1829 | 1804 | ||
549 | 1830 | expected_dirty_pockets = [ | 1805 | expected_dirty_suites = { |
550 | 1831 | ('breezy-autotest', PackagePublishingPocket.SECURITY), | 1806 | 'breezy-autotest-security', |
551 | 1832 | ('breezy-autotest', PackagePublishingPocket.BACKPORTS), | 1807 | 'breezy-autotest-backports', |
552 | 1833 | ] | 1808 | } |
553 | 1834 | self.checkDirtyPockets(publisher, expected=expected_dirty_pockets) | 1809 | self.assertEqual(expected_dirty_suites, publisher.dirty_suites) |
554 | 1835 | 1810 | ||
555 | 1836 | def testDeletionDetectionRespectsAllowedSuites(self): | 1811 | def testDeletionDetectionRespectsAllowedSuites(self): |
556 | 1837 | """Check if the deletion detection mechanism respects allowed_suites. | 1812 | """Check if the deletion detection mechanism respects allowed_suites. |
557 | @@ -1845,14 +1820,14 @@ class TestPublisher(TestPublisherBase): | |||
558 | 1845 | specified suites should be marked as dirty. | 1820 | specified suites should be marked as dirty. |
559 | 1846 | """ | 1821 | """ |
560 | 1847 | allowed_suites = [ | 1822 | allowed_suites = [ |
563 | 1848 | ('breezy-autotest', PackagePublishingPocket.SECURITY), | 1823 | 'breezy-autotest-security', |
564 | 1849 | ('breezy-autotest', PackagePublishingPocket.UPDATES), | 1824 | 'breezy-autotest-updates', |
565 | 1850 | ] | 1825 | ] |
566 | 1851 | publisher = getPublisher( | 1826 | publisher = getPublisher( |
567 | 1852 | self.ubuntutest.main_archive, allowed_suites, self.logger) | 1827 | self.ubuntutest.main_archive, allowed_suites, self.logger) |
568 | 1853 | 1828 | ||
569 | 1854 | publisher.A2_markPocketsWithDeletionsDirty() | 1829 | publisher.A2_markPocketsWithDeletionsDirty() |
571 | 1855 | self.checkDirtyPockets(publisher, expected=[]) | 1830 | self.assertEqual(set(), publisher.dirty_suites) |
572 | 1856 | 1831 | ||
573 | 1857 | # Create pending deletions in RELEASE, BACKPORTS, SECURITY and | 1832 | # Create pending deletions in RELEASE, BACKPORTS, SECURITY and |
574 | 1858 | # UPDATES pockets. | 1833 | # UPDATES pockets. |
575 | @@ -1873,9 +1848,8 @@ class TestPublisher(TestPublisherBase): | |||
576 | 1873 | status=PackagePublishingStatus.DELETED)[0] | 1848 | status=PackagePublishingStatus.DELETED)[0] |
577 | 1874 | 1849 | ||
578 | 1875 | publisher.A2_markPocketsWithDeletionsDirty() | 1850 | publisher.A2_markPocketsWithDeletionsDirty() |
582 | 1876 | # Only the pockets with pending deletions in the allowed suites | 1851 | # Only the suites with pending deletions are marked as dirty. |
583 | 1877 | # are marked as dirty. | 1852 | self.assertEqual(set(allowed_suites), publisher.dirty_suites) |
581 | 1878 | self.checkDirtyPockets(publisher, expected=allowed_suites) | ||
584 | 1879 | 1853 | ||
585 | 1880 | def testReleaseFile(self): | 1854 | def testReleaseFile(self): |
586 | 1881 | """Test release file writing. | 1855 | """Test release file writing. |
587 | @@ -1892,9 +1866,7 @@ class TestPublisher(TestPublisherBase): | |||
588 | 1892 | publisher.A_publish(False) | 1866 | publisher.A_publish(False) |
589 | 1893 | publisher.C_doFTPArchive(False) | 1867 | publisher.C_doFTPArchive(False) |
590 | 1894 | 1868 | ||
594 | 1895 | self.assertIn( | 1869 | self.assertIn('breezy-autotest', publisher.release_files_needed) |
592 | 1896 | ('breezy-autotest', PackagePublishingPocket.RELEASE), | ||
593 | 1897 | publisher.release_files_needed) | ||
595 | 1898 | 1870 | ||
596 | 1899 | publisher.D_writeReleaseFiles(False) | 1871 | publisher.D_writeReleaseFiles(False) |
597 | 1900 | 1872 | ||
598 | @@ -2140,7 +2112,7 @@ class TestPublisher(TestPublisherBase): | |||
599 | 2140 | os.makedirs(os.path.dirname(contents_path)) | 2112 | os.makedirs(os.path.dirname(contents_path)) |
600 | 2141 | with gzip.GzipFile(contents_path, 'wb'): | 2113 | with gzip.GzipFile(contents_path, 'wb'): |
601 | 2142 | pass | 2114 | pass |
603 | 2143 | publisher.markPocketDirty( | 2115 | publisher.markSuiteDirty( |
604 | 2144 | self.ubuntutest.getSeries('breezy-autotest'), | 2116 | self.ubuntutest.getSeries('breezy-autotest'), |
605 | 2145 | PackagePublishingPocket.RELEASE) | 2117 | PackagePublishingPocket.RELEASE) |
606 | 2146 | 2118 | ||
607 | @@ -2170,7 +2142,7 @@ class TestPublisher(TestPublisherBase): | |||
608 | 2170 | for name in dep11_names: | 2142 | for name in dep11_names: |
609 | 2171 | with gzip.GzipFile(os.path.join(dep11_path, name), 'wb') as f: | 2143 | with gzip.GzipFile(os.path.join(dep11_path, name), 'wb') as f: |
610 | 2172 | f.write(six.ensure_binary(name)) | 2144 | f.write(six.ensure_binary(name)) |
612 | 2173 | publisher.markPocketDirty( | 2145 | publisher.markSuiteDirty( |
613 | 2174 | self.ubuntutest.getSeries('breezy-autotest'), | 2146 | self.ubuntutest.getSeries('breezy-autotest'), |
614 | 2175 | PackagePublishingPocket.RELEASE) | 2147 | PackagePublishingPocket.RELEASE) |
615 | 2176 | 2148 | ||
616 | @@ -2200,7 +2172,7 @@ class TestPublisher(TestPublisherBase): | |||
617 | 2200 | for name in cnf_names: | 2172 | for name in cnf_names: |
618 | 2201 | with lzma.LZMAFile(os.path.join(cnf_path, name), 'wb') as f: | 2173 | with lzma.LZMAFile(os.path.join(cnf_path, name), 'wb') as f: |
619 | 2202 | f.write(six.ensure_binary(name)) | 2174 | f.write(six.ensure_binary(name)) |
621 | 2203 | publisher.markPocketDirty( | 2175 | publisher.markSuiteDirty( |
622 | 2204 | self.ubuntutest.getSeries('breezy-autotest'), | 2176 | self.ubuntutest.getSeries('breezy-autotest'), |
623 | 2205 | PackagePublishingPocket.RELEASE) | 2177 | PackagePublishingPocket.RELEASE) |
624 | 2206 | 2178 | ||
625 | @@ -2460,8 +2432,7 @@ class TestArchiveIndices(TestPublisherBase): | |||
626 | 2460 | that those in 'absent' are not. | 2432 | that those in 'absent' are not. |
627 | 2461 | """ | 2433 | """ |
628 | 2462 | 2434 | ||
631 | 2463 | self.assertTrue( | 2435 | self.assertIn(series.getSuite(pocket), publisher.release_files_needed) |
630 | 2464 | (series.name, pocket) in publisher.release_files_needed) | ||
632 | 2465 | 2436 | ||
633 | 2466 | arch_template = os.path.join( | 2437 | arch_template = os.path.join( |
634 | 2467 | publisher._config.distsroot, series.getSuite(pocket), '%s/%s') | 2438 | publisher._config.distsroot, series.getSuite(pocket), '%s/%s') |
635 | @@ -2774,7 +2745,7 @@ class TestUpdateByHash(TestPublisherBase): | |||
636 | 2774 | # Create the first file. | 2745 | # Create the first file. |
637 | 2775 | with open_for_writing(suite_path('Contents-i386'), 'w') as f: | 2746 | with open_for_writing(suite_path('Contents-i386'), 'w') as f: |
638 | 2776 | f.write('A Contents file\n') | 2747 | f.write('A Contents file\n') |
640 | 2777 | publisher.markPocketDirty( | 2748 | publisher.markSuiteDirty( |
641 | 2778 | self.breezy_autotest, PackagePublishingPocket.RELEASE) | 2749 | self.breezy_autotest, PackagePublishingPocket.RELEASE) |
642 | 2779 | self.runSteps(publisher, step_a=True, step_c=True, step_d=True) | 2750 | self.runSteps(publisher, step_a=True, step_c=True, step_d=True) |
643 | 2780 | flush_database_caches() | 2751 | flush_database_caches() |
644 | @@ -2880,7 +2851,7 @@ class TestUpdateByHash(TestPublisherBase): | |||
645 | 2880 | self.setUpMockTime() | 2851 | self.setUpMockTime() |
646 | 2881 | 2852 | ||
647 | 2882 | # Publish empty index files. | 2853 | # Publish empty index files. |
649 | 2883 | publisher.markPocketDirty( | 2854 | publisher.markSuiteDirty( |
650 | 2884 | self.breezy_autotest, PackagePublishingPocket.RELEASE) | 2855 | self.breezy_autotest, PackagePublishingPocket.RELEASE) |
651 | 2885 | self.runSteps(publisher, step_a=True, step_c=True, step_d=True) | 2856 | self.runSteps(publisher, step_a=True, step_c=True, step_d=True) |
652 | 2886 | suite_path = partial( | 2857 | suite_path = partial( |
653 | @@ -2988,7 +2959,7 @@ class TestUpdateByHash(TestPublisherBase): | |||
654 | 2988 | self.ubuntutest.main_archive) | 2959 | self.ubuntutest.main_archive) |
655 | 2989 | self.runSteps(publisher, step_a2=True, step_c=True, step_d=True) | 2960 | self.runSteps(publisher, step_a2=True, step_c=True, step_d=True) |
656 | 2990 | transaction.commit() | 2961 | transaction.commit() |
658 | 2991 | self.assertEqual(set(), publisher.dirty_pockets) | 2962 | self.assertEqual(set(), publisher.dirty_suites) |
659 | 2992 | # The condemned index files are removed, and no new Release file is | 2963 | # The condemned index files are removed, and no new Release file is |
660 | 2993 | # generated. | 2964 | # generated. |
661 | 2994 | expected_suite_files = ( | 2965 | expected_suite_files = ( |
662 | @@ -3021,7 +2992,7 @@ class TestUpdateByHash(TestPublisherBase): | |||
663 | 3021 | self.ubuntutest.main_archive) | 2992 | self.ubuntutest.main_archive) |
664 | 3022 | self.runSteps(publisher, step_a2=True, step_c=True, step_d=True) | 2993 | self.runSteps(publisher, step_a2=True, step_c=True, step_d=True) |
665 | 3023 | transaction.commit() | 2994 | transaction.commit() |
667 | 3024 | self.assertEqual(set(), publisher.dirty_pockets) | 2995 | self.assertEqual(set(), publisher.dirty_suites) |
668 | 3025 | self.assertEqual(release_mtime, os.stat(release_path).st_mtime) | 2996 | self.assertEqual(release_mtime, os.stat(release_path).st_mtime) |
669 | 3026 | # The condemned index files are removed, and no new Release file is | 2997 | # The condemned index files are removed, and no new Release file is |
670 | 3027 | # generated. | 2998 | # generated. |
LGTM