← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~julian-edwards/launchpad/cp-das-disabled-builds-bug-633139 into lp:~launchpad-pqm/launchpad/production-devel

 

Julian Edwards has proposed merging lp:~julian-edwards/launchpad/cp-das-disabled-builds-bug-633139 into lp:~launchpad-pqm/launchpad/production-devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


Cherry pick request for bug 633139 - the changes here are already landed on db-devel.
-- 
https://code.launchpad.net/~julian-edwards/launchpad/cp-das-disabled-builds-bug-633139/+merge/35269
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~julian-edwards/launchpad/cp-das-disabled-builds-bug-633139 into lp:~launchpad-pqm/launchpad/production-devel.
=== modified file 'database/schema/comments.sql'
--- database/schema/comments.sql	2010-09-03 16:43:11 +0000
+++ database/schema/comments.sql	2010-09-13 12:03:49 +0000
@@ -1171,6 +1171,7 @@
 COMMENT ON COLUMN DistroArchSeries.package_count IS 'A cache of the number of binary packages published in this distro arch release. The count only includes packages published in the release pocket.';
 COMMENT ON COLUMN DistroArchSeries.supports_virtualized IS 'Whether or not
 virtualized build support should be provided by this specific distroarchseries';
+COMMENT ON COLUMN DistroArchSeries.enabled IS 'Whether to allow build creation and publishing for this DistroArchSeries.';
 
 -- LauncpadDatabaseRevision
 COMMENT ON TABLE LaunchpadDatabaseRevision IS 'This table contains a list of the database patches that have been successfully applied to this database.';

=== added file 'database/schema/patch-2208-08-1.sql'
--- database/schema/patch-2208-08-1.sql	1970-01-01 00:00:00 +0000
+++ database/schema/patch-2208-08-1.sql	2010-09-13 12:03:49 +0000
@@ -0,0 +1,9 @@
+-- Copyright 2010 Canonical Ltd.  This software is licensed under the
+-- GNU Affero General Public License version 3 (see the file LICENSE).
+
+SET client_min_messages=ERROR;
+
+ALTER TABLE distroarchseries
+    ADD COLUMN enabled bool NOT NULL DEFAULT TRUE;
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 08, 1);

=== modified file 'lib/lp/soyuz/browser/distroarchseries.py'
--- lib/lp/soyuz/browser/distroarchseries.py	2010-08-20 20:31:18 +0000
+++ lib/lp/soyuz/browser/distroarchseries.py	2010-09-13 12:03:49 +0000
@@ -124,7 +124,8 @@
     schema = IDistroArchSeries
 
     field_names = [
-        'architecturetag', 'official', 'supports_virtualized'
+        'architecturetag', 'official', 'supports_virtualized',
+        'enabled',
         ]
 
     @action(_('Change'), name='update')

=== added file 'lib/lp/soyuz/browser/tests/test_distroarchseries_view.py'
--- lib/lp/soyuz/browser/tests/test_distroarchseries_view.py	1970-01-01 00:00:00 +0000
+++ lib/lp/soyuz/browser/tests/test_distroarchseries_view.py	2010-09-13 12:03:49 +0000
@@ -0,0 +1,51 @@
+# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+__metaclass__ = type
+
+from canonical.launchpad.ftests import login
+from canonical.launchpad.webapp.servers import LaunchpadTestRequest
+from canonical.testing import LaunchpadFunctionalLayer
+from lp.soyuz.browser.distroarchseries import DistroArchSeriesAdminView
+from lp.testing import TestCaseWithFactory
+from lp.testing.sampledata import LAUNCHPAD_ADMIN
+
+
+class TestDistroArchSeriesView(TestCaseWithFactory):
+
+    layer = LaunchpadFunctionalLayer
+
+    def setUp(self):
+        """Create a distroarchseries for the tests and login as an admin."""
+        super(TestDistroArchSeriesView, self).setUp()
+        self.das = self.factory.makeDistroArchSeries()
+        # Login as an admin to ensure access to the view's context
+        # object.
+        login(LAUNCHPAD_ADMIN)
+
+    def initialize_admin_view(self, enabled=True):
+        # Initialize the admin view with the supplied params.
+        method = 'POST'
+        form = {
+            'field.actions.update': 'update',
+            }
+
+        if enabled:
+            form['field.enabled'] = 'on'
+        else:
+            form['field.enabled'] = 'off'
+
+        view = DistroArchSeriesAdminView(
+            self.das, LaunchpadTestRequest(method=method, form=form))
+        view.initialize()
+        return view
+
+    def test_enabling_enabled_flag(self):
+        view = self.initialize_admin_view(enabled=False)
+        self.assertEqual(0, len(view.errors))
+        self.assertFalse(view.context.enabled)
+
+    def test_disabling_enabled_flag(self):
+        view = self.initialize_admin_view(enabled=True)
+        self.assertEqual(0, len(view.errors))
+        self.assertTrue(view.context.enabled)

=== modified file 'lib/lp/soyuz/doc/distroarchseries.txt'
--- lib/lp/soyuz/doc/distroarchseries.txt	2010-07-20 09:36:17 +0000
+++ lib/lp/soyuz/doc/distroarchseries.txt	2010-09-13 12:03:49 +0000
@@ -25,6 +25,16 @@
 #      This needs many more tests to be effective.
 
 
+Properties
+==========
+
+Enabled is a boolean flag that says whether the arch will receive new builds
+and publish them.
+
+    >>> print hoary_i386.enabled
+    True
+
+
 DistroArchSeries can tell you about their published releases
 ============================================================
 

=== modified file 'lib/lp/soyuz/doc/package-arch-specific.txt'
--- lib/lp/soyuz/doc/package-arch-specific.txt	2010-08-24 15:29:01 +0000
+++ lib/lp/soyuz/doc/package-arch-specific.txt	2010-09-13 12:03:49 +0000
@@ -121,6 +121,17 @@
     >>> print_build_architectures(pub_one)
     hppa
 
+If an architecture is disabled for some reason, then the results from
+determineArchitecturesToBuild() will not include it.
+
+    >>> hoary['hppa'].enabled = False
+
+    >>> print_build_architectures(pub_three)
+    i386
+
+Re-enable it before continuing:
+    >>> hoary['hppa'].enabled = True
+
 
 == Check support for kernel notation in architecture hint list ==
 

=== modified file 'lib/lp/soyuz/interfaces/distroarchseries.py'
--- lib/lp/soyuz/interfaces/distroarchseries.py	2010-08-20 20:31:18 +0000
+++ lib/lp/soyuz/interfaces/distroarchseries.py	2010-09-13 12:03:49 +0000
@@ -83,6 +83,12 @@
             description=_("Indicate whether or not this port has support "
                           "for building PPA packages."),
             required=False))
+    enabled = Bool(
+        title=_("Enabled"),
+        description=_(
+            "Whether or not this DistroArchSeries is enabled for build "
+            "creation and publication."),
+        required=False, readonly=False)
 
     # Joins.
     packages = Attribute('List of binary packages in this port.')

=== modified file 'lib/lp/soyuz/model/distroarchseries.py'
--- lib/lp/soyuz/model/distroarchseries.py	2010-08-24 15:29:01 +0000
+++ lib/lp/soyuz/model/distroarchseries.py	2010-09-13 12:03:49 +0000
@@ -82,6 +82,7 @@
         storm_validator=validate_public_person, notNull=True)
     package_count = IntCol(notNull=True, default=DEFAULT)
     supports_virtualized = BoolCol(notNull=False, default=False)
+    enabled = BoolCol(notNull=False, default=True)
 
     packages = SQLRelatedJoin('BinaryPackageRelease',
         joinColumn='distroarchseries',
@@ -337,6 +338,11 @@
 
     def publish(self, diskpool, log, archive, pocket, is_careful=False):
         """See `ICanPublishPackages`."""
+        if not self.enabled:
+            log.debug(
+                "Skipping disabled architecture %s" % self.architecturetag)
+            return set()
+
         log.debug("Attempting to publish pending binaries for %s"
               % self.architecturetag)
 

=== modified file 'lib/lp/soyuz/pas.py'
--- lib/lp/soyuz/pas.py	2010-08-23 16:51:11 +0000
+++ lib/lp/soyuz/pas.py	2010-09-13 12:03:49 +0000
@@ -164,7 +164,8 @@
         if not legal_archseries:
             return []
 
-    legal_arch_tags = set(arch.architecturetag for arch in legal_archseries)
+    legal_arch_tags = set(
+        arch.architecturetag for arch in legal_archseries if arch.enabled)
 
     # We need to support arch tags like any-foo and linux-foo, so remove
     # supported kernel prefixes, Also allow linux-any but not any-any.

=== modified file 'lib/lp/soyuz/tests/test_publishing_top_level_api.py'
--- lib/lp/soyuz/tests/test_publishing_top_level_api.py	2010-08-24 15:29:01 +0000
+++ lib/lp/soyuz/tests/test_publishing_top_level_api.py	2010-09-13 12:03:49 +0000
@@ -419,3 +419,16 @@
         self.checkBinaryLookupForPocket(
             PackagePublishingPocket.RELEASE, is_careful=True,
             expected_result=[pub_published_release, pub_pending_release])
+
+    def test_publishing_disabled_distroarchseries(self):
+        # Disabled DASes will be skipped even if there are pending
+        # publications for them.
+        binaries = self.getPubBinaries(architecturespecific=True)
+        # Just use the first binary.
+        binary = binaries[0]
+        self.assertEqual(PackagePublishingStatus.PENDING, binary.status)
+
+        binary.distroarchseries.enabled = False
+        self._publish(pocket=binary.pocket)
+
+        self.assertEqual(PackagePublishingStatus.PENDING, binary.status)


Follow ups