Merge lp:~cjwatson/launchpad/publish-distro-disable-steps into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 17961
Proposed branch: lp:~cjwatson/launchpad/publish-distro-disable-steps
Merge into: lp:launchpad
Diff against target: 140 lines (+80/-25)
2 files modified
lib/lp/archivepublisher/scripts/publishdistro.py (+51/-23)
lib/lp/archivepublisher/tests/test_publishdistro.py (+29/-2)
To merge this branch: bzr merge lp:~cjwatson/launchpad/publish-distro-disable-steps
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+289658@code.launchpad.net

Commit message

Add publish-distro --disable-* options to allow entirely disabling individual steps.

Description of the change

Add publish-distro --disable-* options to allow entirely disabling individual steps. This will let us e.g. run just step D over a set of archives without incurring the time cost of running step A (even in non-careful mode) on them all.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/archivepublisher/scripts/publishdistro.py'
--- lib/lp/archivepublisher/scripts/publishdistro.py 2016-03-17 17:08:49 +0000
+++ lib/lp/archivepublisher/scripts/publishdistro.py 2016-03-21 15:45:54 +0000
@@ -72,6 +72,26 @@
72 help="Make the Release file generation process careful.")72 help="Make the Release file generation process careful.")
7373
74 self.parser.add_option(74 self.parser.add_option(
75 "--disable-publishing", action="store_false",
76 dest="enable_publishing", default=True,
77 help="Disable the package publishing process.")
78
79 self.parser.add_option(
80 "--disable-domination", action="store_false",
81 dest="enable_domination", default=True,
82 help="Disable the domination process.")
83
84 self.parser.add_option(
85 "--disable-apt", action="store_false",
86 dest="enable_apt", default=True,
87 help="Disable index generation (e.g. apt-ftparchive).")
88
89 self.parser.add_option(
90 "--disable-release", action="store_false",
91 dest="enable_release", default=True,
92 help="Disable the Release file generation process.")
93
94 self.parser.add_option(
75 "--include-non-pending", action="store_true",95 "--include-non-pending", action="store_true",
76 dest="include_non_pending", default=False,96 dest="include_non_pending", default=False,
77 help=(97 help=(
@@ -270,29 +290,37 @@
270 Commits transactions along the way.290 Commits transactions along the way.
271 """291 """
272 publisher.setupArchiveDirs()292 publisher.setupArchiveDirs()
273 publisher.A_publish(self.isCareful(self.options.careful_publishing))293 if self.options.enable_publishing:
274 self.txn.commit()294 publisher.A_publish(
275295 self.isCareful(self.options.careful_publishing))
276 # Flag dirty pockets for any outstanding deletions.296 self.txn.commit()
277 publisher.A2_markPocketsWithDeletionsDirty()297
278 publisher.B_dominate(self.isCareful(self.options.careful_domination))298 if self.options.enable_domination:
279 self.txn.commit()299 # Flag dirty pockets for any outstanding deletions.
280300 publisher.A2_markPocketsWithDeletionsDirty()
281 # The primary and copy archives use apt-ftparchive to301 publisher.B_dominate(
282 # generate the indexes, everything else uses the newer302 self.isCareful(self.options.careful_domination))
283 # internal LP code.303 self.txn.commit()
284 careful_indexing = self.isCareful(self.options.careful_apt)304
285 if archive.purpose in (ArchivePurpose.PRIMARY, ArchivePurpose.COPY):305 if self.options.enable_apt:
286 publisher.C_doFTPArchive(careful_indexing)306 # The primary and copy archives use apt-ftparchive to
287 else:307 # generate the indexes, everything else uses the newer
288 publisher.C_writeIndexes(careful_indexing)308 # internal LP code.
289 self.txn.commit()309 careful_indexing = self.isCareful(self.options.careful_apt)
290310 if archive.purpose in (
291 publisher.D_writeReleaseFiles(self.isCareful(311 ArchivePurpose.PRIMARY, ArchivePurpose.COPY):
292 self.options.careful_apt or self.options.careful_release))312 publisher.C_doFTPArchive(careful_indexing)
293 # The caller will commit this last step.313 else:
294314 publisher.C_writeIndexes(careful_indexing)
295 publisher.createSeriesAliases()315 self.txn.commit()
316
317 if self.options.enable_release:
318 publisher.D_writeReleaseFiles(self.isCareful(
319 self.options.careful_apt or self.options.careful_release))
320 # The caller will commit this last step.
321
322 if self.options.enable_apt:
323 publisher.createSeriesAliases()
296324
297 def main(self):325 def main(self):
298 """See `LaunchpadScript`."""326 """See `LaunchpadScript`."""
299327
=== modified file 'lib/lp/archivepublisher/tests/test_publishdistro.py'
--- lib/lp/archivepublisher/tests/test_publishdistro.py 2016-03-21 00:11:14 +0000
+++ lib/lp/archivepublisher/tests/test_publishdistro.py 2016-03-21 15:45:54 +0000
@@ -429,8 +429,10 @@
429 self.assertThat(hoary_inrelease_path, Not(PathExists()))429 self.assertThat(hoary_inrelease_path, Not(PathExists()))
430 self.assertThat(breezy_inrelease_path, Not(PathExists()))430 self.assertThat(breezy_inrelease_path, Not(PathExists()))
431431
432 self.runPublishDistro(432 self.runPublishDistro([
433 ['--ppa', '--careful-release', '--include-non-pending'])433 '--ppa', '--careful-release', '--include-non-pending',
434 '--disable-publishing', '--disable-domination', '--disable-apt',
435 ])
434 # hoary-test never had indexes created, so is untouched.436 # hoary-test never had indexes created, so is untouched.
435 self.assertThat(hoary_inrelease_path, Not(PathExists()))437 self.assertThat(hoary_inrelease_path, Not(PathExists()))
436 # breezy-autotest has its Release files rewritten.438 # breezy-autotest has its Release files rewritten.
@@ -896,6 +898,31 @@
896 self.assertEqual(1, publisher.B_dominate.call_count)898 self.assertEqual(1, publisher.B_dominate.call_count)
897 self.assertEqual(1, publisher.D_writeReleaseFiles.call_count)899 self.assertEqual(1, publisher.D_writeReleaseFiles.call_count)
898900
901 def test_publishArchive_honours_disable_options(self):
902 # The various --disable-* options disable the corresponding
903 # publisher steps.
904 possible_options = {
905 "--disable-publishing": ["A_publish"],
906 "--disable-domination": [
907 "A2_markPocketsWithDeletionsDirty", "B_dominate",
908 ],
909 "--disable-apt": ["C_doFTPArchive", "createSeriesAliases"],
910 "--disable-release": ["D_writeReleaseFiles"],
911 }
912 for option in possible_options:
913 distro = self.makeDistro()
914 script = self.makeScript(distro, args=[option])
915 script.txn = FakeTransaction()
916 publisher = FakePublisher()
917 script.publishArchive(FakeArchive(), publisher)
918 for check_option, steps in possible_options.items():
919 for step in steps:
920 publisher_step = getattr(publisher, step)
921 if check_option == option:
922 self.assertEqual(0, publisher_step.call_count)
923 else:
924 self.assertEqual(1, publisher_step.call_count)
925
899 def test_publishArchive_uses_apt_ftparchive_for_main_archive(self):926 def test_publishArchive_uses_apt_ftparchive_for_main_archive(self):
900 # For some types of archive, publishArchive invokes the927 # For some types of archive, publishArchive invokes the
901 # publisher's C_doFTPArchive method as a way of generating928 # publisher's C_doFTPArchive method as a way of generating