Merge lp:~jtv/launchpad/bug-779701 into lp:launchpad
- bug-779701
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Jeroen T. Vermeulen |
Approved revision: | no longer in the source branch. |
Merged at revision: | 13002 |
Proposed branch: | lp:~jtv/launchpad/bug-779701 |
Merge into: | lp:launchpad |
Diff against target: |
349 lines (+137/-76) 2 files modified
lib/lp/archivepublisher/scripts/publish_ftpmaster.py (+33/-29) lib/lp/archivepublisher/tests/test_publish_ftpmaster.py (+104/-47) |
To merge this branch: | bzr merge lp:~jtv/launchpad/bug-779701 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Henning Eggers (community) | code | Approve | |
Review via email: mp+60346@code.launchpad.net |
Commit message
[r=henninge][bug=779701] Create distroseries indexes per suite.
Description of the change
The new, python-based publish-ftpmaster script will create archive indexes for a new distroseries. In the Ubuntu release process this removes a manual "publish-distro.py -A" run for the distroseries. However we want the indexes for each suite in the series created separately, with a separate publish-distro run. This will make it easier to add pockets in the future, for instance. Index creation should be tracked separately for each suite.
This branch makes the index-creation code use the suite name instead of the distroseries name for the marker files that indicate that indexes have been created. It then runs publish-distro separately for each suite.
To test:
{{{
./bin/test -vvc lp.archivepubli
}}}
To Q/A:
* Create a new distroseries for an existing distribution.
* Run cronscripts/
* See that indexes have been created.
* Note marker files in the distribution's archive root, one for each suites.
(The marker files are dot files, so may not show up by default).
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
Jeroen T. Vermeulen (jtv) wrote : | # |
Thanks. Implemented the changes.
Preview Diff
1 | === modified file 'lib/lp/archivepublisher/scripts/publish_ftpmaster.py' | |||
2 | --- lib/lp/archivepublisher/scripts/publish_ftpmaster.py 2011-05-06 03:10:14 +0000 | |||
3 | +++ lib/lp/archivepublisher/scripts/publish_ftpmaster.py 2011-05-09 10:48:36 +0000 | |||
4 | @@ -228,19 +228,18 @@ | |||
5 | 228 | (archive.purpose, getPubConfig(archive)) | 228 | (archive.purpose, getPubConfig(archive)) |
6 | 229 | for archive in self.archives) | 229 | for archive in self.archives) |
7 | 230 | 230 | ||
9 | 231 | def locateIndexesMarker(self, distroseries): | 231 | def locateIndexesMarker(self, suite): |
10 | 232 | """Give path for marker file whose presence marks index creation. | 232 | """Give path for marker file whose presence marks index creation. |
11 | 233 | 233 | ||
15 | 234 | The file will be created once the archive indexes for | 234 | The file will be created once the archive indexes for `suite` |
16 | 235 | `distroseries` have been created. This is how future runs will | 235 | have been created. This is how future runs will know that this |
17 | 236 | know that this work is done. | 236 | work is done. |
18 | 237 | """ | 237 | """ |
19 | 238 | archive_root = self.configs[ArchivePurpose.PRIMARY].archiveroot | 238 | archive_root = self.configs[ArchivePurpose.PRIMARY].archiveroot |
22 | 239 | return os.path.join( | 239 | return os.path.join(archive_root, ".created-indexes-for-%s" % suite) |
21 | 240 | archive_root, ".created-indexes-for-%s" % distroseries.name) | ||
23 | 241 | 240 | ||
26 | 242 | def needsIndexesCreated(self, distroseries): | 241 | def listSuitesNeedingIndexes(self, distroseries): |
27 | 243 | """Does `distroseries` still need its archive indexes created? | 242 | """Find suites in `distroseries` that need indexes created. |
28 | 244 | 243 | ||
29 | 245 | Checks for the marker left by `markIndexCreationComplete`. | 244 | Checks for the marker left by `markIndexCreationComplete`. |
30 | 246 | """ | 245 | """ |
31 | @@ -249,36 +248,39 @@ | |||
32 | 249 | # is in any other state yet has not been marked as having | 248 | # is in any other state yet has not been marked as having |
33 | 250 | # its indexes created, that's because it predates automatic | 249 | # its indexes created, that's because it predates automatic |
34 | 251 | # index creation. | 250 | # index creation. |
36 | 252 | return False | 251 | return [] |
37 | 253 | distro = distroseries.distribution | 252 | distro = distroseries.distribution |
38 | 254 | publisher_config_set = getUtility(IPublisherConfigSet) | 253 | publisher_config_set = getUtility(IPublisherConfigSet) |
39 | 255 | if publisher_config_set.getByDistribution(distro) is None: | 254 | if publisher_config_set.getByDistribution(distro) is None: |
40 | 256 | # We won't be able to do a thing without a publisher config, | 255 | # We won't be able to do a thing without a publisher config, |
41 | 257 | # but that's alright: we have those for all distributions | 256 | # but that's alright: we have those for all distributions |
42 | 258 | # that we want to publish. | 257 | # that we want to publish. |
51 | 259 | return False | 258 | return [] |
52 | 260 | return not file_exists(self.locateIndexesMarker(distroseries)) | 259 | |
53 | 261 | 260 | # May need indexes for this series. | |
54 | 262 | def markIndexCreationComplete(self, distroseries): | 261 | suites = [ |
55 | 263 | """Note that archive indexes for `distroseries` have been created. | 262 | distroseries.getSuite(pocket) |
56 | 264 | 263 | for pocket in pocketsuffix.iterkeys()] | |
57 | 265 | This tells `needsIndexesCreated` that no, this series no longer needs | 264 | return [ |
58 | 266 | archive indexes to be set up. | 265 | suite for suite in suites |
59 | 266 | if not file_exists(self.locateIndexesMarker(suite))] | ||
60 | 267 | |||
61 | 268 | def markIndexCreationComplete(self, suite): | ||
62 | 269 | """Note that archive indexes for `suite` have been created. | ||
63 | 270 | |||
64 | 271 | This tells `listSuitesNeedingIndexes` that no, this suite no | ||
65 | 272 | longer needs archive indexes to be set up. | ||
66 | 267 | """ | 273 | """ |
68 | 268 | with file(self.locateIndexesMarker(distroseries), "w") as marker: | 274 | with file(self.locateIndexesMarker(suite), "w") as marker: |
69 | 269 | marker.write( | 275 | marker.write( |
70 | 270 | "Indexes for %s were created on %s.\n" | 276 | "Indexes for %s were created on %s.\n" |
72 | 271 | % (distroseries, datetime.now(utc))) | 277 | % (suite, datetime.now(utc))) |
73 | 272 | 278 | ||
75 | 273 | def createIndexes(self, distroseries): | 279 | def createIndexes(self, suite): |
76 | 274 | """Create archive indexes for `distroseries`.""" | 280 | """Create archive indexes for `distroseries`.""" |
84 | 275 | self.logger.info( | 281 | self.logger.info("Creating archive indexes for %s.", suite) |
85 | 276 | "Creating archive indexes for series %s.", distroseries) | 282 | self.runPublishDistro(args=['-A'], suites=[suite]) |
86 | 277 | suites = [ | 283 | self.markIndexCreationComplete(suite) |
80 | 278 | distroseries.getSuite(pocket) | ||
81 | 279 | for pocket in pocketsuffix.iterkeys()] | ||
82 | 280 | self.runPublishDistro(args=['-A'], suites=suites) | ||
83 | 281 | self.markIndexCreationComplete(distroseries) | ||
87 | 282 | 284 | ||
88 | 283 | def processAccepted(self): | 285 | def processAccepted(self): |
89 | 284 | """Run the process-accepted script.""" | 286 | """Run the process-accepted script.""" |
90 | @@ -556,8 +558,10 @@ | |||
91 | 556 | self.recoverWorkingDists() | 558 | self.recoverWorkingDists() |
92 | 557 | 559 | ||
93 | 558 | for series in self.distribution.series: | 560 | for series in self.distribution.series: |
96 | 559 | if self.needsIndexesCreated(series): | 561 | suites_needing_indexes = self.listSuitesNeedingIndexes(series) |
97 | 560 | self.createIndexes(series) | 562 | if len(suites_needing_indexes) > 0: |
98 | 563 | for suite in suites_needing_indexes: | ||
99 | 564 | self.createIndexes(suite) | ||
100 | 561 | # Don't try to do too much in one run. Leave the rest | 565 | # Don't try to do too much in one run. Leave the rest |
101 | 562 | # of the work for next time. | 566 | # of the work for next time. |
102 | 563 | return | 567 | return |
103 | 564 | 568 | ||
104 | === modified file 'lib/lp/archivepublisher/tests/test_publish_ftpmaster.py' | |||
105 | --- lib/lp/archivepublisher/tests/test_publish_ftpmaster.py 2011-05-06 03:10:14 +0000 | |||
106 | +++ lib/lp/archivepublisher/tests/test_publish_ftpmaster.py 2011-05-09 10:48:36 +0000 | |||
107 | @@ -108,6 +108,19 @@ | |||
108 | 108 | return file(os.path.join(*path)).read() | 108 | return file(os.path.join(*path)).read() |
109 | 109 | 109 | ||
110 | 110 | 110 | ||
111 | 111 | def get_a_suite(distroseries): | ||
112 | 112 | """Return some suite name for `distroseries`.""" | ||
113 | 113 | # Don't pick Release; it's too easy. | ||
114 | 114 | return distroseries.getSuite(PackagePublishingPocket.SECURITY) | ||
115 | 115 | |||
116 | 116 | |||
117 | 117 | def get_marker_files(script, distroseries): | ||
118 | 118 | suites = [ | ||
119 | 119 | distroseries.getSuite(pocket) | ||
120 | 120 | for pocket in pocketsuffix.iterkeys()] | ||
121 | 121 | return [script.locateIndexesMarker(suite) for suite in suites] | ||
122 | 122 | |||
123 | 123 | |||
124 | 111 | class HelpersMixin: | 124 | class HelpersMixin: |
125 | 112 | """Helpers for the PublishFTPMaster tests.""" | 125 | """Helpers for the PublishFTPMaster tests.""" |
126 | 113 | 126 | ||
127 | @@ -769,58 +782,90 @@ | |||
128 | 769 | 782 | ||
129 | 770 | def createIndexesMarkerDir(self, script, distroseries): | 783 | def createIndexesMarkerDir(self, script, distroseries): |
130 | 771 | """Create the directory for `distroseries`'s indexes marker.""" | 784 | """Create the directory for `distroseries`'s indexes marker.""" |
132 | 772 | marker = script.locateIndexesMarker(distroseries) | 785 | marker = script.locateIndexesMarker(get_a_suite(distroseries)) |
133 | 773 | os.makedirs(os.path.dirname(marker)) | 786 | os.makedirs(os.path.dirname(marker)) |
134 | 774 | 787 | ||
136 | 775 | def test_new_frozen_series_needs_indexes_created(self): | 788 | def makeDistroSeriesNeedingIndexes(self, distribution=None): |
137 | 789 | """Create `DistroSeries` that needs indexes created.""" | ||
138 | 790 | return self.factory.makeDistroSeries( | ||
139 | 791 | status=SeriesStatus.FROZEN, distribution=distribution) | ||
140 | 792 | |||
141 | 793 | def test_listSuitesNeedingIndexes_is_nonempty_for_new_frozen_series(self): | ||
142 | 776 | # If a distroseries is Frozen and has not had its indexes | 794 | # If a distroseries is Frozen and has not had its indexes |
151 | 777 | # created yet, needsIndexesCreated returns True for it. | 795 | # created yet, listSuitesNeedingIndexes returns a nonempty list |
152 | 778 | series = self.factory.makeDistroSeries(status=SeriesStatus.FROZEN) | 796 | # for it. |
153 | 779 | script = self.makeScript(series.distribution) | 797 | series = self.makeDistroSeriesNeedingIndexes() |
154 | 780 | script.setUp() | 798 | script = self.makeScript(series.distribution) |
155 | 781 | self.assertTrue(script.needsIndexesCreated(series)) | 799 | script.setUp() |
156 | 782 | 800 | self.assertNotEqual([], list(script.listSuitesNeedingIndexes(series))) | |
157 | 783 | def test_new_nonfrozen_series_does_not_need_indexes_created(self): | 801 | |
158 | 784 | # needsIndexesCreated only returns True for Frozen distroseries. | 802 | def test_listSuitesNeedingIndexes_initially_includes_entire_series(self): |
159 | 803 | # If a series has not had any of its indexes created yet, | ||
160 | 804 | # listSuitesNeedingIndexes returns all of its suites. | ||
161 | 805 | series = self.makeDistroSeriesNeedingIndexes() | ||
162 | 806 | script = self.makeScript(series.distribution) | ||
163 | 807 | script.setUp() | ||
164 | 808 | self.assertContentEqual( | ||
165 | 809 | [series.getSuite(pocket) for pocket in pocketsuffix.iterkeys()], | ||
166 | 810 | script.listSuitesNeedingIndexes(series)) | ||
167 | 811 | |||
168 | 812 | def test_listSuitesNeedingIndexes_is_empty_for_nonfrozen_series(self): | ||
169 | 813 | # listSuitesNeedingIndexes only returns suites for Frozen | ||
170 | 814 | # distroseries. | ||
171 | 785 | series = self.factory.makeDistroSeries() | 815 | series = self.factory.makeDistroSeries() |
172 | 786 | script = self.makeScript(series.distribution) | 816 | script = self.makeScript(series.distribution) |
174 | 787 | self.assertFalse(script.needsIndexesCreated(series)) | 817 | self.assertEqual([], script.listSuitesNeedingIndexes(series)) |
175 | 788 | 818 | ||
181 | 789 | def test_distro_without_publisher_config_gets_no_indexes(self): | 819 | def test_listSuitesNeedingIndexes_is_empty_for_configless_distro(self): |
182 | 790 | # needsIndexesCreated returns False for distributions that have | 820 | # listSuitesNeedingIndexes returns no suites for distributions |
183 | 791 | # no publisher config, such as Debian. We don't want to publish | 821 | # that have no publisher config, such as Debian. We don't want |
184 | 792 | # these distributions. | 822 | # to publish such distributions. |
185 | 793 | series = self.factory.makeDistroSeries(status=SeriesStatus.FROZEN) | 823 | series = self.makeDistroSeriesNeedingIndexes() |
186 | 794 | pub_config = get_pub_config(series.distribution) | 824 | pub_config = get_pub_config(series.distribution) |
187 | 795 | IMasterStore(pub_config).remove(pub_config) | 825 | IMasterStore(pub_config).remove(pub_config) |
188 | 796 | script = self.makeScript(series.distribution) | 826 | script = self.makeScript(series.distribution) |
190 | 797 | self.assertFalse(script.needsIndexesCreated(series)) | 827 | self.assertEqual([], script.listSuitesNeedingIndexes(series)) |
191 | 798 | 828 | ||
195 | 799 | def test_markIndexCreationComplete_tells_needsIndexesCreated_no(self): | 829 | def test_markIndexCreationComplete_repels_listSuitesNeedingIndexes(self): |
196 | 800 | # The effect of markIndexCreationComplete is to make | 830 | # The effect of markIndexCreationComplete is to remove the suite |
197 | 801 | # needsIndexesCreated for that distroseries return False. | 831 | # in question from the results of listSuitesNeedingIndexes for |
198 | 832 | # that distroseries. | ||
199 | 802 | distro = self.makeDistroWithPublishDirectory() | 833 | distro = self.makeDistroWithPublishDirectory() |
202 | 803 | series = self.factory.makeDistroSeries( | 834 | series = self.makeDistroSeriesNeedingIndexes(distribution=distro) |
201 | 804 | status=SeriesStatus.FROZEN, distribution=distro) | ||
203 | 805 | script = self.makeScript(distro) | 835 | script = self.makeScript(distro) |
204 | 806 | script.setUp() | 836 | script.setUp() |
205 | 807 | self.createIndexesMarkerDir(script, series) | 837 | self.createIndexesMarkerDir(script, series) |
206 | 808 | 838 | ||
210 | 809 | self.assertTrue(script.needsIndexesCreated(series)) | 839 | needful_suites = script.listSuitesNeedingIndexes(series) |
211 | 810 | script.markIndexCreationComplete(series) | 840 | suite = get_a_suite(series) |
212 | 811 | self.assertFalse(script.needsIndexesCreated(series)) | 841 | script.markIndexCreationComplete(suite) |
213 | 842 | needful_suites.remove(suite) | ||
214 | 843 | self.assertContentEqual( | ||
215 | 844 | needful_suites, script.listSuitesNeedingIndexes(series)) | ||
216 | 845 | |||
217 | 846 | def test_listSuitesNeedingIndexes_ignores_other_series(self): | ||
218 | 847 | # listSuitesNeedingIndexes only returns suites for series that | ||
219 | 848 | # need indexes created. It ignores other distroseries. | ||
220 | 849 | series = self.makeDistroSeriesNeedingIndexes() | ||
221 | 850 | self.factory.makeDistroSeries(distribution=series.distribution) | ||
222 | 851 | script = self.makeScript(series.distribution) | ||
223 | 852 | script.setUp() | ||
224 | 853 | suites = list(script.listSuitesNeedingIndexes(series)) | ||
225 | 854 | self.assertNotEqual([], suites) | ||
226 | 855 | for suite in suites: | ||
227 | 856 | self.assertThat(suite, StartsWith(series.name)) | ||
228 | 812 | 857 | ||
229 | 813 | def test_createIndexes_marks_index_creation_complete(self): | 858 | def test_createIndexes_marks_index_creation_complete(self): |
232 | 814 | # createIndexes calls markIndexCreationComplete for the | 859 | # createIndexes calls markIndexCreationComplete for the suite. |
231 | 815 | # distroseries. | ||
233 | 816 | distro = self.makeDistroWithPublishDirectory() | 860 | distro = self.makeDistroWithPublishDirectory() |
234 | 817 | series = self.factory.makeDistroSeries(distribution=distro) | 861 | series = self.factory.makeDistroSeries(distribution=distro) |
235 | 818 | script = self.makeScript(distro) | 862 | script = self.makeScript(distro) |
236 | 819 | script.markIndexCreationComplete = FakeMethod() | 863 | script.markIndexCreationComplete = FakeMethod() |
237 | 820 | script.runPublishDistro = FakeMethod() | 864 | script.runPublishDistro = FakeMethod() |
239 | 821 | script.createIndexes(series) | 865 | suite = get_a_suite(series) |
240 | 866 | script.createIndexes(suite) | ||
241 | 822 | self.assertEqual( | 867 | self.assertEqual( |
243 | 823 | [((series, ), {})], script.markIndexCreationComplete.calls) | 868 | [((suite, ), {})], script.markIndexCreationComplete.calls) |
244 | 824 | 869 | ||
245 | 825 | def test_failed_index_creation_is_not_marked_complete(self): | 870 | def test_failed_index_creation_is_not_marked_complete(self): |
246 | 826 | # If index creation fails, it is not marked as having been | 871 | # If index creation fails, it is not marked as having been |
247 | @@ -833,7 +878,7 @@ | |||
248 | 833 | script.markIndexCreationComplete = FakeMethod() | 878 | script.markIndexCreationComplete = FakeMethod() |
249 | 834 | script.runPublishDistro = FakeMethod(failure=Boom("Sorry!")) | 879 | script.runPublishDistro = FakeMethod(failure=Boom("Sorry!")) |
250 | 835 | try: | 880 | try: |
252 | 836 | script.createIndexes(series) | 881 | script.createIndexes(get_a_suite(series)) |
253 | 837 | except: | 882 | except: |
254 | 838 | pass | 883 | pass |
255 | 839 | self.assertEqual([], script.markIndexCreationComplete.calls) | 884 | self.assertEqual([], script.markIndexCreationComplete.calls) |
256 | @@ -846,20 +891,30 @@ | |||
257 | 846 | script.setUp() | 891 | script.setUp() |
258 | 847 | archive_root = script.configs[ArchivePurpose.PRIMARY].archiveroot | 892 | archive_root = script.configs[ArchivePurpose.PRIMARY].archiveroot |
259 | 848 | self.assertThat( | 893 | self.assertThat( |
261 | 849 | script.locateIndexesMarker(series), | 894 | script.locateIndexesMarker(get_a_suite(series)), |
262 | 850 | StartsWith(os.path.normpath(archive_root))) | 895 | StartsWith(os.path.normpath(archive_root))) |
263 | 851 | 896 | ||
267 | 852 | def test_locateIndexesMarker_uses_separate_files_per_series(self): | 897 | def test_locateIndexesMarker_uses_separate_files_per_suite(self): |
268 | 853 | # Different release series of the same distribution get separate | 898 | # Each suite in a distroseries gets its own marker file for |
269 | 854 | # marker files for index creation. | 899 | # index creation. |
270 | 900 | distro = self.makeDistroWithPublishDirectory() | ||
271 | 901 | series = self.factory.makeDistroSeries(distribution=distro) | ||
272 | 902 | script = self.makeScript(distro) | ||
273 | 903 | script.setUp() | ||
274 | 904 | markers = get_marker_files(script, series) | ||
275 | 905 | self.assertEqual(sorted(markers), sorted(list(set(markers)))) | ||
276 | 906 | |||
277 | 907 | def test_locateIndexesMarker_separates_distroseries(self): | ||
278 | 908 | # Each distroseries gets its own marker files for index | ||
279 | 909 | # creation. | ||
280 | 855 | distro = self.makeDistroWithPublishDirectory() | 910 | distro = self.makeDistroWithPublishDirectory() |
281 | 856 | series1 = self.factory.makeDistroSeries(distribution=distro) | 911 | series1 = self.factory.makeDistroSeries(distribution=distro) |
282 | 857 | series2 = self.factory.makeDistroSeries(distribution=distro) | 912 | series2 = self.factory.makeDistroSeries(distribution=distro) |
283 | 858 | script = self.makeScript(distro) | 913 | script = self.makeScript(distro) |
284 | 859 | script.setUp() | 914 | script.setUp() |
288 | 860 | self.assertNotEqual( | 915 | markers1 = set(get_marker_files(script, series1)) |
289 | 861 | script.locateIndexesMarker(series1), | 916 | markers2 = set(get_marker_files(script, series2)) |
290 | 862 | script.locateIndexesMarker(series2)) | 917 | self.assertEqual(set(), markers1.intersection(markers2)) |
291 | 863 | 918 | ||
292 | 864 | def test_locateIndexMarker_uses_hidden_file(self): | 919 | def test_locateIndexMarker_uses_hidden_file(self): |
293 | 865 | # The index-creation marker file is a "dot file," so it's not | 920 | # The index-creation marker file is a "dot file," so it's not |
294 | @@ -867,20 +922,23 @@ | |||
295 | 867 | series = self.factory.makeDistroSeries() | 922 | series = self.factory.makeDistroSeries() |
296 | 868 | script = self.makeScript(series.distribution) | 923 | script = self.makeScript(series.distribution) |
297 | 869 | script.setUp() | 924 | script.setUp() |
298 | 925 | suite = get_a_suite(series) | ||
299 | 870 | self.assertThat( | 926 | self.assertThat( |
301 | 871 | os.path.basename(script.locateIndexesMarker(series)), | 927 | os.path.basename(script.locateIndexesMarker(suite)), |
302 | 872 | StartsWith(".")) | 928 | StartsWith(".")) |
303 | 873 | 929 | ||
304 | 874 | def test_script_calls_createIndexes_for_new_series(self): | 930 | def test_script_calls_createIndexes_for_new_series(self): |
305 | 875 | # If the script's main() finds a distroseries that needs its | 931 | # If the script's main() finds a distroseries that needs its |
306 | 876 | # indexes created, it calls createIndexes on that distroseries. | 932 | # indexes created, it calls createIndexes on that distroseries. |
307 | 877 | distro = self.makeDistroWithPublishDirectory() | 933 | distro = self.makeDistroWithPublishDirectory() |
310 | 878 | series = self.factory.makeDistroSeries( | 934 | series = self.makeDistroSeriesNeedingIndexes(distribution=distro) |
309 | 879 | status=SeriesStatus.FROZEN, distribution=distro) | ||
311 | 880 | script = self.makeScript(distro) | 935 | script = self.makeScript(distro) |
312 | 881 | script.createIndexes = FakeMethod() | 936 | script.createIndexes = FakeMethod() |
313 | 882 | script.main() | 937 | script.main() |
315 | 883 | self.assertEqual([((series, ), {})], script.createIndexes.calls) | 938 | expected_calls = [ |
316 | 939 | ((series.getSuite(pocket), ), {}) | ||
317 | 940 | for pocket in pocketsuffix.iterkeys()] | ||
318 | 941 | self.assertContentEqual(expected_calls, script.createIndexes.calls) | ||
319 | 884 | 942 | ||
320 | 885 | def test_createIndexes_ignores_other_series(self): | 943 | def test_createIndexes_ignores_other_series(self): |
321 | 886 | # createIndexes does not accidentally also touch other | 944 | # createIndexes does not accidentally also touch other |
322 | @@ -892,14 +950,13 @@ | |||
323 | 892 | script.setUp() | 950 | script.setUp() |
324 | 893 | script.runPublishDistro = FakeMethod() | 951 | script.runPublishDistro = FakeMethod() |
325 | 894 | self.createIndexesMarkerDir(script, series) | 952 | self.createIndexesMarkerDir(script, series) |
326 | 953 | suite = get_a_suite(series) | ||
327 | 895 | 954 | ||
329 | 896 | script.createIndexes(series) | 955 | script.createIndexes(suite) |
330 | 897 | 956 | ||
331 | 898 | args, kwargs = script.runPublishDistro.calls[0] | 957 | args, kwargs = script.runPublishDistro.calls[0] |
336 | 899 | suites = kwargs['suites'] | 958 | self.assertEqual([suite], kwargs['suites']) |
337 | 900 | self.assertEqual(len(pocketsuffix), len(suites)) | 959 | self.assertThat(kwargs['suites'][0], StartsWith(series.name)) |
334 | 901 | for suite in suites: | ||
335 | 902 | self.assertThat(suite, StartsWith(series.name)) | ||
338 | 903 | 960 | ||
339 | 904 | def test_script_creates_indexes(self): | 961 | def test_script_creates_indexes(self): |
340 | 905 | # End-to-end test: the script creates indexes for distroseries | 962 | # End-to-end test: the script creates indexes for distroseries |
341 | @@ -913,7 +970,7 @@ | |||
342 | 913 | self.setUpForScriptRun(series.distribution) | 970 | self.setUpForScriptRun(series.distribution) |
343 | 914 | script = self.makeScript(series.distribution) | 971 | script = self.makeScript(series.distribution) |
344 | 915 | script.main() | 972 | script.main() |
346 | 916 | self.assertFalse(script.needsIndexesCreated(series)) | 973 | self.assertEqual([], script.listSuitesNeedingIndexes(series)) |
347 | 917 | sources = os.path.join( | 974 | sources = os.path.join( |
348 | 918 | script.configs[ArchivePurpose.PRIMARY].distsroot, | 975 | script.configs[ArchivePurpose.PRIMARY].distsroot, |
349 | 919 | series.name, "main", "source", "Sources") | 976 | series.name, "main", "source", "Sources") |
Thank you for this nice improvement. All I have to add is this:
- Consider using a local factory method for the frozen distro series that also explains why it needs to be frozen.
- The test naming is inconsistent. You used the right convention for the new tests but left the old ones as they were. Would be nice if you could update those, too, where applicable (test_methodNam e_condition) .
Cheers,
Henning