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
1=== modified file 'lib/lp/archivepublisher/scripts/publishdistro.py'
2--- lib/lp/archivepublisher/scripts/publishdistro.py 2016-03-17 17:08:49 +0000
3+++ lib/lp/archivepublisher/scripts/publishdistro.py 2016-03-21 15:45:54 +0000
4@@ -72,6 +72,26 @@
5 help="Make the Release file generation process careful.")
6
7 self.parser.add_option(
8+ "--disable-publishing", action="store_false",
9+ dest="enable_publishing", default=True,
10+ help="Disable the package publishing process.")
11+
12+ self.parser.add_option(
13+ "--disable-domination", action="store_false",
14+ dest="enable_domination", default=True,
15+ help="Disable the domination process.")
16+
17+ self.parser.add_option(
18+ "--disable-apt", action="store_false",
19+ dest="enable_apt", default=True,
20+ help="Disable index generation (e.g. apt-ftparchive).")
21+
22+ self.parser.add_option(
23+ "--disable-release", action="store_false",
24+ dest="enable_release", default=True,
25+ help="Disable the Release file generation process.")
26+
27+ self.parser.add_option(
28 "--include-non-pending", action="store_true",
29 dest="include_non_pending", default=False,
30 help=(
31@@ -270,29 +290,37 @@
32 Commits transactions along the way.
33 """
34 publisher.setupArchiveDirs()
35- publisher.A_publish(self.isCareful(self.options.careful_publishing))
36- self.txn.commit()
37-
38- # Flag dirty pockets for any outstanding deletions.
39- publisher.A2_markPocketsWithDeletionsDirty()
40- publisher.B_dominate(self.isCareful(self.options.careful_domination))
41- self.txn.commit()
42-
43- # The primary and copy archives use apt-ftparchive to
44- # generate the indexes, everything else uses the newer
45- # internal LP code.
46- careful_indexing = self.isCareful(self.options.careful_apt)
47- if archive.purpose in (ArchivePurpose.PRIMARY, ArchivePurpose.COPY):
48- publisher.C_doFTPArchive(careful_indexing)
49- else:
50- publisher.C_writeIndexes(careful_indexing)
51- self.txn.commit()
52-
53- publisher.D_writeReleaseFiles(self.isCareful(
54- self.options.careful_apt or self.options.careful_release))
55- # The caller will commit this last step.
56-
57- publisher.createSeriesAliases()
58+ if self.options.enable_publishing:
59+ publisher.A_publish(
60+ self.isCareful(self.options.careful_publishing))
61+ self.txn.commit()
62+
63+ if self.options.enable_domination:
64+ # Flag dirty pockets for any outstanding deletions.
65+ publisher.A2_markPocketsWithDeletionsDirty()
66+ publisher.B_dominate(
67+ self.isCareful(self.options.careful_domination))
68+ self.txn.commit()
69+
70+ if self.options.enable_apt:
71+ # The primary and copy archives use apt-ftparchive to
72+ # generate the indexes, everything else uses the newer
73+ # internal LP code.
74+ careful_indexing = self.isCareful(self.options.careful_apt)
75+ if archive.purpose in (
76+ ArchivePurpose.PRIMARY, ArchivePurpose.COPY):
77+ publisher.C_doFTPArchive(careful_indexing)
78+ else:
79+ publisher.C_writeIndexes(careful_indexing)
80+ self.txn.commit()
81+
82+ if self.options.enable_release:
83+ publisher.D_writeReleaseFiles(self.isCareful(
84+ self.options.careful_apt or self.options.careful_release))
85+ # The caller will commit this last step.
86+
87+ if self.options.enable_apt:
88+ publisher.createSeriesAliases()
89
90 def main(self):
91 """See `LaunchpadScript`."""
92
93=== modified file 'lib/lp/archivepublisher/tests/test_publishdistro.py'
94--- lib/lp/archivepublisher/tests/test_publishdistro.py 2016-03-21 00:11:14 +0000
95+++ lib/lp/archivepublisher/tests/test_publishdistro.py 2016-03-21 15:45:54 +0000
96@@ -429,8 +429,10 @@
97 self.assertThat(hoary_inrelease_path, Not(PathExists()))
98 self.assertThat(breezy_inrelease_path, Not(PathExists()))
99
100- self.runPublishDistro(
101- ['--ppa', '--careful-release', '--include-non-pending'])
102+ self.runPublishDistro([
103+ '--ppa', '--careful-release', '--include-non-pending',
104+ '--disable-publishing', '--disable-domination', '--disable-apt',
105+ ])
106 # hoary-test never had indexes created, so is untouched.
107 self.assertThat(hoary_inrelease_path, Not(PathExists()))
108 # breezy-autotest has its Release files rewritten.
109@@ -896,6 +898,31 @@
110 self.assertEqual(1, publisher.B_dominate.call_count)
111 self.assertEqual(1, publisher.D_writeReleaseFiles.call_count)
112
113+ def test_publishArchive_honours_disable_options(self):
114+ # The various --disable-* options disable the corresponding
115+ # publisher steps.
116+ possible_options = {
117+ "--disable-publishing": ["A_publish"],
118+ "--disable-domination": [
119+ "A2_markPocketsWithDeletionsDirty", "B_dominate",
120+ ],
121+ "--disable-apt": ["C_doFTPArchive", "createSeriesAliases"],
122+ "--disable-release": ["D_writeReleaseFiles"],
123+ }
124+ for option in possible_options:
125+ distro = self.makeDistro()
126+ script = self.makeScript(distro, args=[option])
127+ script.txn = FakeTransaction()
128+ publisher = FakePublisher()
129+ script.publishArchive(FakeArchive(), publisher)
130+ for check_option, steps in possible_options.items():
131+ for step in steps:
132+ publisher_step = getattr(publisher, step)
133+ if check_option == option:
134+ self.assertEqual(0, publisher_step.call_count)
135+ else:
136+ self.assertEqual(1, publisher_step.call_count)
137+
138 def test_publishArchive_uses_apt_ftparchive_for_main_archive(self):
139 # For some types of archive, publishArchive invokes the
140 # publisher's C_doFTPArchive method as a way of generating