Merge lp:~laney/launchpad/proposed-notautomatic into lp:launchpad

Proposed by Iain Lane
Status: Work in progress
Proposed branch: lp:~laney/launchpad/proposed-notautomatic
Merge into: lp:launchpad
Diff against target: 196 lines (+55/-25)
7 files modified
lib/lp/archivepublisher/publishing.py (+4/-2)
lib/lp/archivepublisher/tests/test_publisher.py (+32/-16)
lib/lp/registry/configure.zcml (+1/-0)
lib/lp/registry/interfaces/distroseries.py (+12/-0)
lib/lp/registry/model/distroseries.py (+1/-0)
lib/lp/soyuz/scripts/initialize_distroseries.py (+3/-0)
lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py (+2/-7)
To merge this branch: bzr merge lp:~laney/launchpad/proposed-notautomatic
Reviewer Review Type Date Requested Status
Richard Harding (community) Needs Information
Review via email: mp+113921@code.launchpad.net

Commit message

Add flag proposed_not_automatic to cause Release files for -proposed to be set NotAutomatic and ButAutomaticUpgrades so that users are not offered upgrades to packages in the proposed pocket, but are within it.

Description of the change

Summary
=======

Users are offered upgrades to packages in -proposed, which is often used as a staging/test area. It would be better if they were able to opt in on a per-package basis.

Proposed Fix
============

Add a flag which causes the -proposed Eelease files for a series to contain the NotAutomatic and ButAutomaticUpgrade flags, so that users are not offered updates by apt to packages in -propoed, but are offered upgrades within it.

Test
====

bin/test -cvv test_publisher

QA/demo Plans
==============

Upload (or copy) a package into quantal-proposed with proposed_not_automatic = False. Confirm that the Release file for quantal-proposed does not contain NotAutomatic or ButAutomaticUpgrades. Set the flag to True and upload another package (to cause the Release files to be re-written) and check that the Release file contains NotAutomatic: yes and ButAutomaticUpgrades: yes.

To post a comment you must log in.
Revision history for this message
Iain Lane (laney) wrote :

One thing I don't know is whether the way that I modified the tests is the best way to go about this. In particular I'm not sure about the "set_flag" functions.

Perhaps both tests should just be combined?

Revision history for this message
Richard Harding (rharding) wrote :

Thank Iain. I think having the split tests is ok. I might have passed in the string for the property 'proposed_not_automatic' for instance, and used getattr/setattr to test and check the value myself, but it works.

I don't see any LoC qualification in the MP. Do you have a credit currently?

I want to make sure the removed imports in #164 are unused imports then?

Other than that, I don't see anything. Marking needs information for the moment.

review: Needs Information

Unmerged revisions

15424. By Iain Lane

Fix missing copy of proposed_not_automatic when initialising new series

15423. By Iain Lane

Lint and including remove some unused imports.

15422. By Iain Lane

Add DistroSeries.proposed_not_automatic to set NotAutomatic ButAutomaticUpgrades

This means that users will not be offered upgrades to packages in -proposed for
series with this flag enabled, but will be offered upgrade within it.

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 2012-06-29 08:40:05 +0000
3+++ lib/lp/archivepublisher/publishing.py 2012-07-09 08:16:26 +0000
4@@ -569,8 +569,10 @@
5 release_file["Components"] = " ".join(
6 reorder_components(all_components))
7 release_file["Description"] = drsummary
8- if (pocket == PackagePublishingPocket.BACKPORTS and
9- distroseries.backports_not_automatic):
10+ if ((pocket == PackagePublishingPocket.BACKPORTS and
11+ distroseries.backports_not_automatic) or
12+ (pocket == PackagePublishingPocket.PROPOSED and
13+ distroseries.proposed_not_automatic)):
14 release_file["NotAutomatic"] = "yes"
15 release_file["ButAutomaticUpgrades"] = "yes"
16
17
18=== modified file 'lib/lp/archivepublisher/tests/test_publisher.py'
19--- lib/lp/archivepublisher/tests/test_publisher.py 2012-01-03 01:02:12 +0000
20+++ lib/lp/archivepublisher/tests/test_publisher.py 2012-07-09 08:16:26 +0000
21@@ -64,6 +64,7 @@
22
23 RELEASE = PackagePublishingPocket.RELEASE
24 BACKPORTS = PackagePublishingPocket.BACKPORTS
25+PROPOSED = PackagePublishingPocket.PROPOSED
26
27
28 class TestPublisherBase(TestNativePublishingBase):
29@@ -1021,13 +1022,14 @@
30 # The Label: field should be set to the archive displayname
31 self.assertEqual('Partner archive', release['label'])
32
33- def testReleaseFileForNotAutomaticBackports(self):
34- # Test Release file writing for series with NotAutomatic backports.
35+ def releaseFileNotAutomatic(self, pocket, flag_value, set_flag):
36+ # Set up Release file writing for series/pocket with NotAutomatic
37+ # ButAutomaticUpgrades.
38 publisher = Publisher(
39 self.logger, self.config, self.disk_pool,
40 self.ubuntutest.main_archive)
41 self.getPubSource(filecontent='Hello world', pocket=RELEASE)
42- self.getPubSource(filecontent='Hello world', pocket=BACKPORTS)
43+ self.getPubSource(filecontent='Hello world', pocket=pocket)
44
45 publisher.A_publish(True)
46 publisher.C_writeIndexes(False)
47@@ -1039,20 +1041,34 @@
48 with open(release_path) as release_file:
49 return release_file.read().splitlines()
50
51- # When backports_not_automatic is unset, no Release files have
52+ # When flag is unset, no Release files have
53 # NotAutomatic: yes.
54- self.assertEqual(False, self.breezy_autotest.backports_not_automatic)
55- publisher.D_writeReleaseFiles(False)
56- self.assertNotIn("NotAutomatic: yes", get_release(RELEASE))
57- self.assertNotIn("NotAutomatic: yes", get_release(BACKPORTS))
58-
59- # But with the flag set, -backports Release files gain
60- # NotAutomatic: yes and ButAutomaticUpgrades: yes.
61- self.breezy_autotest.backports_not_automatic = True
62- publisher.D_writeReleaseFiles(False)
63- self.assertNotIn("NotAutomatic: yes", get_release(RELEASE))
64- self.assertIn("NotAutomatic: yes", get_release(BACKPORTS))
65- self.assertIn("ButAutomaticUpgrades: yes", get_release(BACKPORTS))
66+ self.assertEqual(False, flag_value)
67+ publisher.D_writeReleaseFiles(False)
68+ self.assertNotIn("NotAutomatic: yes", get_release(RELEASE))
69+ self.assertNotIn("NotAutomatic: yes", get_release(pocket))
70+
71+ # But with the flag set, the pocket's Release files gain NotAutomatic:
72+ # yes and ButAutomaticUpgrades: yes.
73+ set_flag(True)
74+ publisher.D_writeReleaseFiles(False)
75+ self.assertNotIn("NotAutomatic: yes", get_release(RELEASE))
76+ self.assertIn("NotAutomatic: yes", get_release(pocket))
77+ self.assertIn("ButAutomaticUpgrades: yes", get_release(pocket))
78+
79+ def testReleaseFileForNotAutomaticBackports(self):
80+ def set_flag(value):
81+ self.breezy_autotest.backports_not_automatic = value
82+ self.releaseFileNotAutomatic(BACKPORTS,
83+ self.breezy_autotest.backports_not_automatic,
84+ set_flag)
85+
86+ def testReleaseFileForNotAutomaticProposed(self):
87+ def set_flag(value):
88+ self.breezy_autotest.proposed_not_automatic = value
89+ self.releaseFileNotAutomatic(PROPOSED,
90+ self.breezy_autotest.proposed_not_automatic,
91+ set_flag)
92
93 def testReleaseFileForI18n(self):
94 """Test Release file writing for translated package descriptions."""
95
96=== modified file 'lib/lp/registry/configure.zcml'
97--- lib/lp/registry/configure.zcml 2012-06-29 02:15:05 +0000
98+++ lib/lp/registry/configure.zcml 2012-07-09 08:16:26 +0000
99@@ -263,6 +263,7 @@
100 permission="launchpad.Edit"
101 set_attributes="displayname title summary description driver
102 backports_not_automatic
103+ proposed_not_automatic
104 include_long_descriptions"/>
105
106 <!-- NB: check with SABDFL before modifying these, there is potential to
107
108=== modified file 'lib/lp/registry/interfaces/distroseries.py'
109--- lib/lp/registry/interfaces/distroseries.py 2012-07-03 08:04:35 +0000
110+++ lib/lp/registry/interfaces/distroseries.py 2012-07-09 08:16:26 +0000
111@@ -365,6 +365,18 @@
112 automatically upgrade within backports, but not into it.
113 """))
114
115+ proposed_not_automatic = Bool(
116+ title=_("Don't upgrade to packages in proposed automatically"),
117+ required=True,
118+ description=_("""
119+ Set NotAutomatic: yes and ButAutomaticUpgrades: yes in Release
120+ files generated for the proposed pocket pre-release. This tells apt
121+ to automatically upgrade within proposed, but not into it.
122+ Pre-release, this pocket is used as a package staging area for
123+ archive consistency purposes. Post-release, users would like to be
124+ able to opt-in to testing proposed updates on a per-package basis.
125+ """))
126+
127 include_long_descriptions = exported(
128 Bool(
129 title=_(
130
131=== modified file 'lib/lp/registry/model/distroseries.py'
132--- lib/lp/registry/model/distroseries.py 2012-07-05 09:43:58 +0000
133+++ lib/lp/registry/model/distroseries.py 2012-07-09 08:16:26 +0000
134@@ -244,6 +244,7 @@
135 notNull=False, default=None)
136 language_pack_full_export_requested = BoolCol(notNull=True, default=False)
137 backports_not_automatic = BoolCol(notNull=True, default=False)
138+ proposed_not_automatic = BoolCol(notNull=True, default=False)
139 include_long_descriptions = BoolCol(notNull=True, default=True)
140
141 language_packs = SQLMultipleJoin(
142
143=== modified file 'lib/lp/soyuz/scripts/initialize_distroseries.py'
144--- lib/lp/soyuz/scripts/initialize_distroseries.py 2012-07-05 09:43:58 +0000
145+++ lib/lp/soyuz/scripts/initialize_distroseries.py 2012-07-09 08:16:26 +0000
146@@ -367,6 +367,9 @@
147 self.distroseries.backports_not_automatic = any(
148 parent.backports_not_automatic
149 for parent in self.derivation_parents)
150+ self.distroseries.proposed_not_automatic = any(
151+ parent.proposed_not_automatic
152+ for parent in self.derivation_parents)
153 self.distroseries.include_long_descriptions = any(
154 parent.include_long_descriptions
155 for parent in self.derivation_parents)
156
157=== modified file 'lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py'
158--- lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py 2012-04-23 22:18:46 +0000
159+++ lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py 2012-07-09 08:16:26 +0000
160@@ -5,12 +5,6 @@
161
162 __metaclass__ = type
163
164-import os
165-import subprocess
166-import sys
167-
168-from testtools.content import Content
169-from testtools.content_type import UTF8_TEXT
170 import transaction
171 from zope.component import getUtility
172
173@@ -21,7 +15,6 @@
174 )
175 from lp.registry.interfaces.distroseriesparent import IDistroSeriesParentSet
176 from lp.registry.interfaces.pocket import PackagePublishingPocket
177-from lp.services.config import config
178 from lp.services.database.lpstorm import IStore
179 from lp.services.features.testing import FeatureFixture
180 from lp.soyuz.enums import (
181@@ -89,6 +82,7 @@
182 if existing_format_selection is None:
183 spfss_utility.add(parent, format_selection)
184 parent.backports_not_automatic = True
185+ parent.proposed_not_automatic = True
186 parent.include_long_descriptions = False
187 self._populate_parent(parent, parent_das, packages, pocket)
188 return parent, parent_das
189@@ -593,6 +587,7 @@
190 SourcePackageFormat.FORMAT_1_0))
191 # Other configuration bits are copied too.
192 self.assertTrue(child.backports_not_automatic)
193+ self.assertTrue(child.proposed_not_automatic)
194 self.assertFalse(child.include_long_descriptions)
195
196 def test_initialize(self):