Merge ~cjwatson/launchpad:process-accepted-honour-publish into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 81f4711f6b920dc9fc5033e4e2425c59d715d159
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:process-accepted-honour-publish
Merge into: launchpad:master
Diff against target: 84 lines (+26/-7)
2 files modified
lib/lp/archivepublisher/scripts/processaccepted.py (+3/-1)
lib/lp/archivepublisher/tests/test_processaccepted.py (+23/-6)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+400973@code.launchpad.net

Commit message

process-accepted: Skip archives with the publish flag disabled

Description of the change

This means that it can be run on copy archives without trying to process millions of queue entries that will never go anywhere useful.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/archivepublisher/scripts/processaccepted.py b/lib/lp/archivepublisher/scripts/processaccepted.py
2index d5bc192..f61edcd 100644
3--- a/lib/lp/archivepublisher/scripts/processaccepted.py
4+++ b/lib/lp/archivepublisher/scripts/processaccepted.py
5@@ -1,4 +1,4 @@
6-# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
7+# Copyright 2009-2021 Canonical Ltd. This software is licensed under the
8 # GNU Affero General Public License version 3 (see the file LICENSE).
9
10 """Helper functions for the process-accepted.py script."""
11@@ -110,6 +110,8 @@ class ProcessAccepted(PublisherScript):
12 """
13 processed_queue_ids = []
14 for archive in self.getTargetArchives(distribution):
15+ if not archive.can_be_published:
16+ continue
17 set_request_started(
18 request_statements=LimitedList(10000),
19 txn=self.txn, enable_timeout=False)
20diff --git a/lib/lp/archivepublisher/tests/test_processaccepted.py b/lib/lp/archivepublisher/tests/test_processaccepted.py
21index 6b7147f..f945212 100644
22--- a/lib/lp/archivepublisher/tests/test_processaccepted.py
23+++ b/lib/lp/archivepublisher/tests/test_processaccepted.py
24@@ -1,4 +1,4 @@
25-# Copyright 2010-2018 Canonical Ltd. This software is licensed under the
26+# Copyright 2010-2021 Canonical Ltd. This software is licensed under the
27 # GNU Affero General Public License version 3 (see the file LICENSE).
28
29 """Test process-accepted.py"""
30@@ -100,6 +100,7 @@ class TestProcessAccepted(TestCaseWithFactory):
31 distroseries = self.factory.makeDistroSeries(distribution=self.distro)
32 copy_archive = self.factory.makeArchive(
33 distribution=self.distro, purpose=ArchivePurpose.COPY)
34+ copy_archive.publish = True
35 copy_source = self.createWaitingAcceptancePackage(
36 archive=copy_archive, distroseries=distroseries)
37 # Also upload some stuff in the main archive.
38@@ -108,10 +109,7 @@ class TestProcessAccepted(TestCaseWithFactory):
39 # Before accepting, the package should not be published at all.
40 published_copy = copy_archive.getPublishedSources(
41 name=self.test_package_name)
42- # Using .count() until Storm fixes __nonzero__ on SQLObj result
43- # sets, then we can use bool() which is far more efficient than
44- # counting.
45- self.assertEqual(published_copy.count(), 0)
46+ self.assertTrue(published_copy.is_empty())
47
48 # Accept the packages.
49 script = self.getScript(['--copy-archives'])
50@@ -121,7 +119,7 @@ class TestProcessAccepted(TestCaseWithFactory):
51 # Packages in main archive should not be accepted and published.
52 published_main = self.distro.main_archive.getPublishedSources(
53 name=self.test_package_name)
54- self.assertEqual(published_main.count(), 0)
55+ self.assertTrue(published_main.is_empty())
56
57 # Check the copy archive source was accepted.
58 published_copy = copy_archive.getPublishedSources(
59@@ -130,6 +128,25 @@ class TestProcessAccepted(TestCaseWithFactory):
60 published_copy.status, PackagePublishingStatus.PENDING)
61 self.assertEqual(copy_source, published_copy.sourcepackagerelease)
62
63+ def test_skips_non_publishing_copy_archives(self):
64+ # The script skips copy archives that have the publish flag disabled.
65+ distroseries = self.factory.makeDistroSeries(distribution=self.distro)
66+ copy_archive = self.factory.makeArchive(
67+ distribution=self.distro, purpose=ArchivePurpose.COPY)
68+ self.createWaitingAcceptancePackage(
69+ archive=copy_archive, distroseries=distroseries)
70+ published_copy = copy_archive.getPublishedSources(
71+ name=self.test_package_name)
72+ self.assertTrue(published_copy.is_empty())
73+
74+ script = self.getScript(['--copy-archives'])
75+ switch_dbuser(self.dbuser)
76+ script.main()
77+
78+ published_copy = copy_archive.getPublishedSources(
79+ name=self.test_package_name)
80+ self.assertTrue(published_copy.is_empty())
81+
82 def test_commits_after_each_item(self):
83 # Test that the script commits after each item, not just at the end.
84 uploads = [

Subscribers

People subscribed via source and target branches

to status/vote changes: