Merge lp:~cjwatson/launchpad/stop-publishing-obsolete-series into lp:launchpad

Proposed by Colin Watson
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 14622
Proposed branch: lp:~cjwatson/launchpad/stop-publishing-obsolete-series
Merge into: lp:launchpad
Diff against target: 98 lines (+63/-1)
2 files modified
lib/lp/archivepublisher/publishing.py (+23/-1)
lib/lp/archivepublisher/tests/test_publisher.py (+40/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/stop-publishing-obsolete-series
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+86967@code.launchpad.net

Commit message

[r=rvb][bug=905281] Skip publishing OBSOLETE and FUTURE series in PRIMARY and PARTNER archives.

Description of the change

== Summary ==

About 15 seconds of the primary archive publisher's runtime is spent considering obsolete distroseries. It's not a huge amount, but it would be nice to shave this off.

== Proposed fix ==

Exclude OBSOLETE and FUTURE series when publishing PRIMARY and PARTNER archives. The archive purpose restriction is because apparently OEM still has PPAs for obsolete series, as noted by William Grant pre-implementation.

== Tests ==

bin/test -vvct archivepublisher.tests.test_publisher.TestPublisher

== Demo and Q/A ==

Run the publisher on mawson. Given the current state of the dogfood database, the publisher log under "Step A: Publishing packages" should show it considering rusty, precise, oneiric, natty, maverick, lucid, newdog, hardy, testagain, and dozing, but not q-series, karmic, jaunty, intrepid, gutsy, feisty, edgy, dapper, breezy, hoary, or warty.

== lint ==

None.

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) wrote :

This looks good to land. Maybe you could merge testPublishingSkipsObsoletePrimarySeries and testPublishingSkipsFuturePrimarySeries into one single method to avoid code duplication.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archivepublisher/publishing.py'
2--- lib/lp/archivepublisher/publishing.py 2011-12-30 06:14:56 +0000
3+++ lib/lp/archivepublisher/publishing.py 2012-01-03 01:07:25 +0000
4@@ -39,6 +39,7 @@
5 RepositoryIndexFile,
6 )
7 from lp.registry.interfaces.pocket import PackagePublishingPocket
8+from lp.registry.interfaces.series import SeriesStatus
9 from lp.services.database.sqlbase import sqlvalues
10 from lp.services.librarian.client import LibrarianClient
11 from lp.services.utils import file_exists
12@@ -236,7 +237,28 @@
13 """
14 self.log.debug("* Step A: Publishing packages")
15
16- for distroseries in self.distro.series:
17+ if self.archive.purpose in (
18+ ArchivePurpose.PRIMARY,
19+ ArchivePurpose.PARTNER,
20+ ):
21+ # For PRIMARY and PARTNER archives, skip OBSOLETE and FUTURE
22+ # series. We will never want to publish anything in them, so it
23+ # isn't worth thinking about whether they have pending
24+ # publications.
25+ consider_series = [
26+ series
27+ for series in self.distro.series
28+ if series.status not in (
29+ SeriesStatus.OBSOLETE,
30+ SeriesStatus.FUTURE,
31+ )]
32+ else:
33+ # Other archives may have reasons to continue building at least
34+ # for OBSOLETE series. For example, a PPA may be continuing to
35+ # provide custom builds for users who haven't upgraded yet.
36+ consider_series = self.distro.series
37+
38+ for distroseries in consider_series:
39 for pocket in self.archive.getPockets():
40 allowed = (
41 not self.allowed_suites or
42
43=== modified file 'lib/lp/archivepublisher/tests/test_publisher.py'
44--- lib/lp/archivepublisher/tests/test_publisher.py 2011-12-30 06:14:56 +0000
45+++ lib/lp/archivepublisher/tests/test_publisher.py 2012-01-03 01:07:25 +0000
46@@ -56,6 +56,7 @@
47 from lp.soyuz.interfaces.archive import IArchiveSet
48 from lp.soyuz.tests.test_publishing import TestNativePublishingBase
49 from lp.testing import TestCaseWithFactory
50+from lp.testing.fakemethod import FakeMethod
51 from lp.testing.gpgkeys import gpgkeysdir
52 from lp.testing.keyserver import KeyServerTac
53 from lp.testing.layers import ZopelessDatabaseLayer
54@@ -431,6 +432,45 @@
55 # remove locally created dir
56 shutil.rmtree(test_pool_dir)
57
58+ def testPublishingSkipsObsoleteFuturePrimarySeries(self):
59+ """Publisher skips OBSOLETE/FUTURE series in PRIMARY archives."""
60+ publisher = Publisher(
61+ self.logger, self.config, self.disk_pool,
62+ self.ubuntutest.main_archive)
63+ # Remove security proxy so that the publisher can call our fake
64+ # method.
65+ publisher.distro = removeSecurityProxy(publisher.distro)
66+
67+ for status in (SeriesStatus.OBSOLETE, SeriesStatus.FUTURE):
68+ naked_breezy_autotest = publisher.distro['breezy-autotest']
69+ naked_breezy_autotest.status = status
70+ naked_breezy_autotest.publish = FakeMethod(result=set())
71+
72+ publisher.A_publish(False)
73+
74+ self.assertEqual(0, naked_breezy_autotest.publish.call_count)
75+
76+ def testPublishingConsidersObsoleteFuturePPASeries(self):
77+ """Publisher does not skip OBSOLETE/FUTURE series in PPA archives."""
78+ ubuntu_team = getUtility(IPersonSet).getByName('ubuntu-team')
79+ test_archive = getUtility(IArchiveSet).new(
80+ distribution=self.ubuntutest, owner=ubuntu_team,
81+ purpose=ArchivePurpose.PPA)
82+ publisher = Publisher(
83+ self.logger, self.config, self.disk_pool, test_archive)
84+ # Remove security proxy so that the publisher can call our fake
85+ # method.
86+ publisher.distro = removeSecurityProxy(publisher.distro)
87+
88+ for status in (SeriesStatus.OBSOLETE, SeriesStatus.FUTURE):
89+ naked_breezy_autotest = publisher.distro['breezy-autotest']
90+ naked_breezy_autotest.status = status
91+ naked_breezy_autotest.publish = FakeMethod(result=set())
92+
93+ publisher.A_publish(False)
94+
95+ self.assertEqual(1, naked_breezy_autotest.publish.call_count)
96+
97 def testPublisherBuilderFunctions(self):
98 """Publisher can be initialized via provided helper function.
99