Merge lp:~cjwatson/launchpad/custom-upload-publish-dirty into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18611
Proposed branch: lp:~cjwatson/launchpad/custom-upload-publish-dirty
Merge into: lp:launchpad
Diff against target: 74 lines (+34/-1)
2 files modified
lib/lp/soyuz/model/queue.py (+3/-1)
lib/lp/soyuz/tests/test_packageupload.py (+31/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/custom-upload-publish-dirty
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+343005@code.launchpad.net

Commit message

After publishing a custom file, mark its target suite as dirty so that it will be published.

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/soyuz/model/queue.py'
2--- lib/lp/soyuz/model/queue.py 2017-06-13 12:19:20 +0000
3+++ lib/lp/soyuz/model/queue.py 2018-04-11 11:24:54 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 __metaclass__ = type
10@@ -1363,6 +1363,8 @@
11 handler = getUtility(ICustomUploadHandler, self.customformat.name)
12 handler.publish(
13 self.packageupload, self.libraryfilealias, logger=logger)
14+ self.packageupload.archive.markSuiteDirty(
15+ self.packageupload.distroseries, self.packageupload.pocket)
16
17
18 @implementer(IPackageUploadSet)
19
20=== modified file 'lib/lp/soyuz/tests/test_packageupload.py'
21--- lib/lp/soyuz/tests/test_packageupload.py 2018-02-02 03:14:35 +0000
22+++ lib/lp/soyuz/tests/test_packageupload.py 2018-04-11 11:24:54 +0000
23@@ -6,6 +6,7 @@
24 from __future__ import absolute_import, print_function, unicode_literals
25
26 from datetime import timedelta
27+import io
28 from urllib2 import (
29 HTTPError,
30 urlopen,
31@@ -34,6 +35,8 @@
32 from lp.services.job.interfaces.job import JobStatus
33 from lp.services.job.runner import JobRunner
34 from lp.services.librarian.browser import ProxiedLibraryFileAlias
35+from lp.services.log.logger import BufferLogger
36+from lp.services.tarfile_helpers import LaunchpadWriteTarFile
37 from lp.soyuz.adapters.overrides import SourceOverride
38 from lp.soyuz.enums import (
39 PackagePublishingStatus,
40@@ -138,6 +141,34 @@
41 [spph] = upload.realiseUpload()
42 self.assertEqual(spph.packageupload, upload)
43
44+ def test_publish_custom_marks_suite_dirty(self):
45+ # Publishing a PackageUploadCustom will mark the suite as dirty so
46+ # that new indexes will be published for it.
47+ buf = io.BytesIO()
48+ tarfile = LaunchpadWriteTarFile(buf)
49+ tarfile.add_file("installer-amd64/1/hello", b"world")
50+ tarfile.close()
51+ upload = self.factory.makePackageUpload(
52+ pocket=PackagePublishingPocket.PROPOSED)
53+ filename = "debian-installer-images_1_amd64.tar.gz"
54+ lfa = self.factory.makeLibraryFileAlias(
55+ filename=filename, content=buf.getvalue(),
56+ content_type="application/gzipped-tar")
57+ upload.addCustom(lfa, PackageUploadCustomFormat.DEBIAN_INSTALLER)
58+ transaction.commit()
59+ upload.setAccepted()
60+ self.assertIsNone(upload.archive.dirty_suites)
61+ logger = BufferLogger()
62+ self.assertEqual([], upload.realiseUpload(logger=logger))
63+ self.assertEqual(
64+ "DEBUG Publishing custom %s to %s/%s\n" % (
65+ filename, upload.distroseries.distribution.name,
66+ upload.distroseries.name),
67+ logger.getLogBuffer())
68+ self.assertEqual(
69+ ["%s-proposed" % upload.distroseries.name],
70+ upload.archive.dirty_suites)
71+
72 def test_overrideSource_ignores_None_component_change(self):
73 # overrideSource accepts None as a component; it will not object
74 # based on permissions for the new component.