Merge lp:~cjwatson/launchpad/async-copy-unembargo into lp:launchpad

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: no longer in the source branch.
Merged at revision: 15664
Proposed branch: lp:~cjwatson/launchpad/async-copy-unembargo
Merge into: lp:launchpad
Diff against target: 193 lines (+116/-10)
2 files modified
lib/lp/soyuz/browser/archive.py (+1/-1)
lib/lp/soyuz/browser/tests/archive-views.txt (+115/-9)
To merge this branch: bzr merge lp:~cjwatson/launchpad/async-copy-unembargo
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+115950@code.launchpad.net

Commit message

Pass the unembargo flag when doing asynchronous copies in the web UI, to match the synchronous path.

Description of the change

== Summary ==

Bug 1026976: Asynchronous copies via the web UI (available to beta testers) create a PCJ which oopses when trying to copy from a private archive to a public archive.

== Proposed fix ==

Add the unembargo=True flag. I meant to do this a while back, actually, but I had it in a future cleanup branch so forgot about it.

== Pre-implementation notes ==

Cody Somerville raised a concern that there needs to be some kind of confirmation step here. While I think this would be reasonable, the synchronous copy path (which is still used for everyone who isn't in launchpad-beta-testers) has no such confirmation step, so there is no reason to block this fix on that. I've filed that separately as bug 1026979.

== LOC Rationale ==

+106. This will be comfortably more than offset by removing the synchronous copy path once the asynchronous path has passed its beta testing phase.

== Tests ==

bin/test -vvct archive-views.txt

== Demo and Q/A ==

Upload a package to a private archive on dogfood. Make sure you're in ~launchpad-beta-testers there, and use +copy-packages to copy it to a public archive. Run the PCJ; it should complete successfully and make the package's files public.

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

This change looks good Colin.

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/browser/archive.py'
2--- lib/lp/soyuz/browser/archive.py 2012-06-29 08:40:05 +0000
3+++ lib/lp/soyuz/browser/archive.py 2012-07-20 11:07:41 +0000
4@@ -1322,7 +1322,7 @@
5 dest_pocket, include_binaries=include_binaries,
6 package_version=spph.sourcepackagerelease.version,
7 copy_policy=PackageCopyPolicy.INSECURE,
8- requester=person, sponsored=sponsored)
9+ requester=person, sponsored=sponsored, unembargo=True)
10
11 return copy_asynchronously_message(len(source_pubs))
12
13
14=== modified file 'lib/lp/soyuz/browser/tests/archive-views.txt'
15--- lib/lp/soyuz/browser/tests/archive-views.txt 2011-12-30 06:14:56 +0000
16+++ lib/lp/soyuz/browser/tests/archive-views.txt 2012-07-20 11:07:41 +0000
17@@ -1,4 +1,6 @@
18-= Archive View Classes and Pages =
19+==============================
20+Archive View Classes and Pages
21+==============================
22
23 Let's use Celso's PPA for the tests.
24
25@@ -6,7 +8,8 @@
26 >>> cprov = getUtility(IPersonSet).getByName('cprov')
27
28
29-== ArchiveView ==
30+ArchiveView
31+===========
32
33 The ArchiveView includes a few helper methods that make it easier to
34 display different types of archives (copy archives, ppas).
35@@ -482,7 +485,8 @@
36 <p><a rel="nofollow" href="http://example.dom/">http://...example...
37
38
39-== ArchivePackageView ==
40+ArchivePackageView
41+==================
42
43 This view displays detailed information about the archive packages that
44 is not so relevant for the PPA index page, such as a summary of build
45@@ -525,7 +529,8 @@
46 True
47
48
49-== ArchivePackageDeletionView ==
50+ArchivePackageDeletionView
51+==========================
52
53 We use ArchivePackageDeletionView to provide the mechnisms used to
54 delete packages from a PPA via the UI.
55@@ -652,7 +657,8 @@
56 2
57
58
59-== ArchiveEditDependenciesView ==
60+ArchiveEditDependenciesView
61+===========================
62
63 We use ArchiveEditDependenciesView to provide the mechnisms used to
64 add and/or remove archive dependencies for a PPA via the UI.
65@@ -1036,7 +1042,8 @@
66 >>> cprov_private_ppa.disable()
67
68
69-== ArchivePackageCopyingView ==
70+ArchivePackageCopyingView
71+=========================
72
73 This class extends ArchiveSourceSelectionFormView, and thus uses the
74 same mechanisms for presenting and filtering available sources for
75@@ -1313,7 +1320,8 @@
76 RequiredMissing())
77
78
79-=== Copy private files to public archives ===
80+Copy private files to public archives
81+-------------------------------------
82
83 Users are allowed to copy private sources into private PPAs, however
84 it happens via 'delayed-copies' not the usual direct copying method.
85@@ -1378,8 +1386,106 @@
86 >>> print copy.status.name
87 ACCEPTED
88
89-
90-== External dependencies validation ==
91+The action may also be performed asynchronously.
92+
93+ >>> from lp.services.features.testing import FeatureFixture
94+ >>> from lp.soyuz.browser.archive import (
95+ ... FEATURE_FLAG_MAX_SYNCHRONOUS_SYNCS,
96+ ... )
97+ >>> fixture = FeatureFixture({
98+ ... 'soyuz.copypackageppa.enabled': 'on',
99+ ... FEATURE_FLAG_MAX_SYNCHRONOUS_SYNCS: '0',
100+ ... })
101+ >>> fixture.setUp()
102+
103+ >>> login('foo.bar@canonical.com')
104+ >>> async_private_source = test_publisher.createSource(
105+ ... cprov_private_ppa, 'foocomm', '1.0-1', new_version='3.0-1')
106+ >>> transaction.commit()
107+
108+ >>> print async_private_source.displayname
109+ foocomm 3.0-1 in hoary
110+
111+ >>> login('celso.providelo@canonical.com')
112+ >>> view = create_initialized_view(
113+ ... cprov_private_ppa, name="+copy-packages",
114+ ... form={
115+ ... 'field.selected_sources': [str(async_private_source.id)],
116+ ... 'field.destination_archive': 'ubuntu-team/ppa',
117+ ... 'field.destination_series': '',
118+ ... 'field.include_binaries': 'REBUILD_SOURCES',
119+ ... 'field.actions.copy': 'Copy',
120+ ... })
121+
122+ >>> len(view.errors)
123+ 0
124+
125+ >>> for notification in view.request.response.notifications:
126+ ... print extract_text(notification.message)
127+ Requested sync of 1 package.
128+ Please allow some time for this to be processed.
129+
130+There is one copy job waiting, which we run.
131+
132+ >>> from lp.services.config import config
133+ >>> from lp.services.job.runner import JobRunner
134+ >>> from lp.soyuz.interfaces.packagecopyjob import (
135+ ... IPlainPackageCopyJobSource,
136+ ... )
137+ >>> from lp.testing.dbuser import dbuser
138+ >>> [job] = getUtility(IPlainPackageCopyJobSource).getActiveJobs(
139+ ... ubuntu_team_ppa)
140+ >>> with dbuser(config.IPlainPackageCopyJobSource.dbuser):
141+ ... JobRunner([job]).runAll()
142+ >>> print job.status.name
143+ COMPLETED
144+
145+The copy results in a pending source publication.
146+
147+ >>> [copied_source] = ubuntu_team_ppa.getPublishedSources(
148+ ... name="foocomm", exact_match=True)
149+ >>> print copied_source.displayname
150+ foocomm 3.0-1 in hoary
151+
152+If we run the same copy again, it will fail.
153+
154+ >>> view = create_initialized_view(
155+ ... cprov_private_ppa, name="+copy-packages",
156+ ... form={
157+ ... 'field.selected_sources': [str(async_private_source.id)],
158+ ... 'field.destination_archive': 'ubuntu-team/ppa',
159+ ... 'field.destination_series': '',
160+ ... 'field.include_binaries': 'REBUILD_SOURCES',
161+ ... 'field.actions.copy': 'Copy',
162+ ... })
163+ >>> [job] = getUtility(IPlainPackageCopyJobSource).getActiveJobs(
164+ ... ubuntu_team_ppa)
165+ >>> with dbuser(config.IPlainPackageCopyJobSource.dbuser):
166+ ... JobRunner([job]).runAll()
167+ >>> print job.status.name
168+ FAILED
169+
170+The job failure is shown in the UI.
171+
172+ >>> from lp.testing import person_logged_in
173+ >>> with person_logged_in(ubuntu_team_ppa.owner):
174+ ... ubuntu_team_ppa_view = create_initialized_view(
175+ ... ubuntu_team_ppa, name="+packages",
176+ ... principal=ubuntu_team_ppa.owner)
177+ >>> ubuntu_team_ppa_view.has_pending_copy_jobs is not None
178+ True
179+ >>> for job in ubuntu_team_ppa_view.package_copy_jobs:
180+ ... print job.status.title, job.package_name, job.package_version
181+ ... print job.error_message
182+ Failed foocomm 3.0-1
183+ foocomm 3.0-1 in hoary (same version already building in the destination
184+ archive for Hoary)
185+
186+ >>> fixture.cleanUp()
187+
188+
189+External dependencies validation
190+================================
191
192 The ArchiveAdminView checks the external_dependencies form data to see if
193 it's a valid sources.list entry.