← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/archive-processors-explicit into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/archive-processors-explicit into lp:launchpad with lp:~wgrant/launchpad/archive-processors-backfill as a prerequisite.

Commit message:
All architectures are now toggleable through Archive.processors.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/archive-processors-explicit/+merge/259461

All architectures are now toggleable through Archive.processors.

Mostly just simplifying code and tweaking tests, but I also inlined the few remaining lines of archivearch.py and deleted the interface etc.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/archive-processors-explicit into lp:launchpad.
=== modified file 'lib/lp/registry/browser/tests/test_distribution_views.py'
--- lib/lp/registry/browser/tests/test_distribution_views.py	2015-05-15 12:40:45 +0000
+++ lib/lp/registry/browser/tests/test_distribution_views.py	2015-05-19 03:12:14 +0000
@@ -182,10 +182,7 @@
             method='POST', form=creation_form)
 
         distribution = self.distributionset.getByName('newbuntu')
-        # XXX wgrant 2015-05-15: Default processors are currently implicit.
-        self.assertContentEqual(
-            [proc for proc in self.all_processors if not proc.restricted],
-            distribution.main_archive.processors)
+        self.assertContentEqual([], distribution.main_archive.processors)
 
 
 class TestDistroEditView(TestCaseWithFactory):
@@ -252,10 +249,7 @@
             self.distribution, '+edit', principal=self.admin,
             method='POST', form=edit_form)
 
-        # XXX wgrant 2015-05-15: Default processors are currently implicit.
-        self.assertContentEqual(
-            [proc for proc in self.all_processors if not proc.restricted],
-            self.distribution.main_archive.processors)
+        self.assertContentEqual([], self.distribution.main_archive.processors)
 
     def test_package_derivatives_email(self):
         # Test that the edit form allows changing package_derivatives_email

=== modified file 'lib/lp/soyuz/browser/tests/test_archive_webservice.py'
--- lib/lp/soyuz/browser/tests/test_archive_webservice.py	2015-05-19 00:41:13 +0000
+++ lib/lp/soyuz/browser/tests/test_archive_webservice.py	2015-05-19 03:12:14 +0000
@@ -292,8 +292,7 @@
         body = webservice_for_person(commercial_admin).get(
             ppa_url + '/processors', api_version='devel').jsonBody()
         self.assertContentEqual(
-            ['386', 'hppa', 'amd64', 'arm'],
-            [entry['name'] for entry in body['entries']])
+            ['386', 'arm'], [entry['name'] for entry in body['entries']])
 
     def test_setProcessors_owner_forbidden(self):
         """Only commercial admins can call setProcessors."""

=== modified file 'lib/lp/soyuz/configure.zcml'
--- lib/lp/soyuz/configure.zcml	2015-05-18 22:56:02 +0000
+++ lib/lp/soyuz/configure.zcml	2015-05-19 03:12:14 +0000
@@ -54,21 +54,6 @@
 
         </class>
 
-    <!-- ArchiveArch -->
-    <class
-        class="lp.soyuz.model.archivearch.ArchiveArch">
-        <allow
-            interface="lp.soyuz.interfaces.archivearch.IArchiveArch" />
-    </class>
-
-    <!-- ArchiveArchSet -->
-    <securedutility
-        class="lp.soyuz.model.archivearch.ArchiveArchSet"
-        provides="lp.soyuz.interfaces.archivearch.IArchiveArchSet">
-        <allow
-            interface="lp.soyuz.interfaces.archivearch.IArchiveArchSet"/>
-    </securedutility>
-
     <!-- DistroSeriesPackageCache -->
     <class
         class="lp.soyuz.model.distroseriespackagecache.DistroSeriesPackageCache">

=== removed file 'lib/lp/soyuz/interfaces/archivearch.py'
--- lib/lp/soyuz/interfaces/archivearch.py	2015-05-18 06:02:21 +0000
+++ lib/lp/soyuz/interfaces/archivearch.py	1970-01-01 00:00:00 +0000
@@ -1,62 +0,0 @@
-# Copyright 2009-2013 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""ArchiveArch interfaces."""
-
-__metaclass__ = type
-
-__all__ = [
-    'IArchiveArch',
-    'IArchiveArchSet',
-    ]
-
-from lazr.restful.fields import Reference
-from zope.interface import Interface
-from zope.schema import Int
-
-from lp import _
-from lp.buildmaster.interfaces.processor import IProcessor
-from lp.soyuz.interfaces.archive import IArchive
-
-
-class IArchiveArch(Interface):
-    """An interface for archive/processor associations."""
-
-    id = Int(title=_('ID'), required=True, readonly=True)
-
-    archive = Reference(
-        title=_("Archive"), schema=IArchive,
-        required=True, readonly=True,
-        description=_(
-            "The archive associated with the processor at hand."))
-
-    processor = Reference(
-        title=_("Processor"), schema=IProcessor,
-        required=True, readonly=True,
-        description=_(
-            "The processor associated with the archive at hand."))
-
-
-class IArchiveArchSet(Interface):
-    """An interface for sets of archive/processor associations."""
-    def new(archive, processor):
-        """Create a new archive/processor association.
-
-        :param archive: the archive to be associated.
-        :param processor: the processor to be associated.
-
-        :return: a newly created `IArchiveArch`.
-        """
-
-    def getByArchive(archive, processor=None):
-        """Return associations that match the archive and processor.
-
-        If no processor is passed, all associations for 'archive' will
-        be returned.
-
-        :param archive: The associated archive.
-        :param processor: An optional processor; if passed only
-        associations in which it participates will be considered.
-
-        :return: A (potentially empty) result set of `IArchiveArch` instances.
-        """

=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py	2015-05-18 06:36:51 +0000
+++ lib/lp/soyuz/model/archive.py	2015-05-19 03:12:14 +0000
@@ -33,7 +33,10 @@
     )
 from storm.locals import (
     Count,
+    Int,
     Join,
+    Reference,
+    Storm,
     )
 from storm.store import Store
 from zope.component import (
@@ -63,6 +66,7 @@
     )
 from lp.buildmaster.interfaces.buildfarmjob import IBuildFarmJobSet
 from lp.buildmaster.interfaces.processor import IProcessorSet
+from lp.buildmaster.model.processor import Processor
 from lp.registry.enums import (
     INCLUSIVE_TEAM_POLICY,
     PersonVisibility,
@@ -158,7 +162,6 @@
     validate_external_dependencies,
     VersionRequiresName,
     )
-from lp.soyuz.interfaces.archivearch import IArchiveArchSet
 from lp.soyuz.interfaces.archiveauthtoken import IArchiveAuthTokenSet
 from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet
 from lp.soyuz.interfaces.archivesubscriber import (
@@ -2076,30 +2079,26 @@
         self.processors = set(self.processors + [processor])
 
     def _getProcessors(self):
-        # To match existing behaviour we always include non-restricted
-        # processors during the transition.
-        enabled = [
-            aa.processor for aa in
-            getUtility(IArchiveArchSet).getByArchive(self)]
-        return [
-            proc for proc in getUtility(IProcessorSet).getAll()
-            if not proc.restricted or proc in enabled]
+        return list(Store.of(self).find(
+            Processor,
+            Processor.id == ArchiveArch.processor_id,
+            ArchiveArch.archive == self))
 
     def setProcessors(self, processors):
         """See `IArchive`."""
-        enablements = {
-            aa.processor: aa for aa in
-            getUtility(IArchiveArchSet).getByArchive(self)}
-        # Remove any enabled restricted processors that aren't in the
-        # new set. _getProcessors currently always includes
-        # non-restricted processors, but this'll change later.
+        enablements = dict(Store.of(self).find(
+            (Processor, ArchiveArch),
+            Processor.id == ArchiveArch.processor_id,
+            ArchiveArch.archive == self))
         for proc in enablements:
-            if proc.restricted and proc not in processors:
+            if proc not in processors:
                 Store.of(self).remove(enablements[proc])
-        # Add any new processors regardless of restrictedness.
         for proc in processors:
             if proc not in self.processors:
-                getUtility(IArchiveArchSet).new(self, proc)
+                archivearch = ArchiveArch()
+                archivearch.archive = self
+                archivearch.processor = proc
+                Store.of(self).add(archivearch)
 
     processors = property(_getProcessors, setProcessors)
 
@@ -2456,8 +2455,7 @@
             processors = [
                 p for p in getUtility(IProcessorSet).getAll()
                 if p.build_by_default]
-        for processor in processors:
-            getUtility(IArchiveArchSet).new(new_archive, processor)
+        new_archive.setProcessors(processors)
 
         return new_archive
 
@@ -2669,6 +2667,17 @@
         return []
 
 
+class ArchiveArch(Storm):
+    """Link table to back Archive.processors."""
+    __storm_table__ = 'ArchiveArch'
+    id = Int(primary=True)
+
+    archive_id = Int(name='archive', allow_none=False)
+    archive = Reference(archive_id, 'Archive.id')
+    processor_id = Int(name='processor', allow_none=False)
+    processor = Reference(processor_id, Processor.id)
+
+
 def get_archive_privacy_filter(user):
     """Get a simplified Archive privacy Storm filter.
 

=== removed file 'lib/lp/soyuz/model/archivearch.py'
--- lib/lp/soyuz/model/archivearch.py	2015-05-18 06:02:21 +0000
+++ lib/lp/soyuz/model/archivearch.py	1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
-# Copyright 2009-2013 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-__metaclass__ = type
-__all__ = [
-    'ArchiveArch',
-    'ArchiveArchSet'
-    ]
-
-from storm.locals import (
-    Int,
-    Reference,
-    Storm,
-    )
-from zope.interface import implements
-
-from lp.buildmaster.model.processor import Processor
-from lp.services.database.interfaces import IStore
-from lp.soyuz.interfaces.archivearch import (
-    IArchiveArch,
-    IArchiveArchSet,
-    )
-
-
-class ArchiveArch(Storm):
-    """See `IArchiveArch`."""
-    implements(IArchiveArch)
-    __storm_table__ = 'ArchiveArch'
-    id = Int(primary=True)
-
-    archive_id = Int(name='archive', allow_none=False)
-    archive = Reference(archive_id, 'Archive.id')
-    processor_id = Int(name='processor', allow_none=False)
-    processor = Reference(processor_id, Processor.id)
-
-
-class ArchiveArchSet:
-    """See `IArchiveArchSet`."""
-    implements(IArchiveArchSet)
-
-    def new(self, archive, processor):
-        """See `IArchiveArchSet`."""
-        archivearch = ArchiveArch()
-        archivearch.archive = archive
-        archivearch.processor = processor
-        IStore(ArchiveArch).add(archivearch)
-        return archivearch
-
-    def getByArchive(self, archive, processor=None):
-        """See `IArchiveArchSet`."""
-        clauses = [ArchiveArch.archive == archive]
-        if processor is not None:
-            clauses.append(ArchiveArch.processor_id == processor.id)
-
-        return IStore(ArchiveArch).find(ArchiveArch, *clauses).order_by(
-            ArchiveArch.id)

=== modified file 'lib/lp/soyuz/model/packagecloner.py'
--- lib/lp/soyuz/model/packagecloner.py	2014-10-31 04:53:06 +0000
+++ lib/lp/soyuz/model/packagecloner.py	2015-05-19 03:12:14 +0000
@@ -14,7 +14,6 @@
 import transaction
 from zope.component import getUtility
 from zope.interface import implements
-from zope.security.proxy import removeSecurityProxy
 
 from lp.services.database.constants import UTC_NOW
 from lp.services.database.interfaces import IStore
@@ -23,7 +22,6 @@
     sqlvalues,
     )
 from lp.soyuz.enums import PackagePublishingStatus
-from lp.soyuz.interfaces.archivearch import IArchiveArchSet
 from lp.soyuz.interfaces.packagecloner import IPackageCloner
 from lp.soyuz.model.publishing import BinaryPackagePublishingHistory
 
@@ -248,13 +246,9 @@
             """ % sqlvalues(
                 PackagePublishingStatus.SUPERSEDED, UTC_NOW))
 
-        processors = [
-            removeSecurityProxy(archivearch).processor for archivearch
-            in getUtility(IArchiveArchSet).getByArchive(destination.archive)]
-
         self._create_missing_builds(
             destination.distroseries, destination.archive, (),
-            processors)
+            destination.archive.processors)
 
     def _compute_packageset_delta(self, origin):
         """Given a source/target archive find obsolete or missing packages.

=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
--- lib/lp/soyuz/scripts/tests/test_copypackage.py	2015-05-06 10:55:59 +0000
+++ lib/lp/soyuz/scripts/tests/test_copypackage.py	2015-05-19 03:12:14 +0000
@@ -26,6 +26,7 @@
     )
 from lp.bugs.interfaces.bugtask import BugTaskStatus
 from lp.buildmaster.enums import BuildStatus
+from lp.buildmaster.interfaces.processor import IProcessorSet
 from lp.registry.interfaces.distribution import IDistributionSet
 from lp.registry.interfaces.pocket import PackagePublishingPocket
 from lp.services.database.constants import UTC_NOW
@@ -1022,6 +1023,11 @@
 
     layer = LaunchpadZopelessLayer
 
+    def setUp(self):
+        super(BaseDoCopyTests, self).setUp()
+        for arch in ('i386', 'hppa'):
+            self.factory.makeProcessor(name='my_%s' % arch)
+
     def createNobby(self, archs):
         """Create a new 'nobby' series with the given architecture tags.
 
@@ -1030,9 +1036,9 @@
         nobby = self.factory.makeDistroSeries(
             distribution=self.test_publisher.ubuntutest, name='nobby')
         for arch in archs:
-            processor = self.factory.makeProcessor(name='my_%s' % arch)
             self.factory.makeDistroArchSeries(
-                distroseries=nobby, architecturetag=arch, processor=processor)
+                distroseries=nobby, architecturetag=arch,
+                processor=getUtility(IProcessorSet).getByName('my_%s' % arch))
         nobby.nominatedarchindep = nobby[archs[0]]
         self.test_publisher.addFakeChroots(nobby)
         return nobby
@@ -1053,7 +1059,7 @@
         source = self.test_publisher.getPubSource(
             archive=archive, architecturehintlist='any')
         [bin_i386, bin_hppa] = self.test_publisher.getPubBinaries(
-            pub_source=source)
+            archive=source.archive, pub_source=source)
 
         # Now make a new distroseries with two architectures, one of
         # which is disabled.
@@ -1094,7 +1100,7 @@
         self.assertCopied(copies, nobby, ('i386',))
 
 
-class TestDoDirectCopy(TestCaseWithFactory, BaseDoCopyTests):
+class TestDoDirectCopy(BaseDoCopyTests, TestCaseWithFactory):
 
     def setUp(self):
         super(TestDoDirectCopy, self).setUp()
@@ -1255,6 +1261,7 @@
         target_archive = self.factory.makeArchive(
             distribution=self.test_publisher.ubuntutest, virtualized=False,
             purpose=ArchivePurpose.PRIMARY)
+        target_archive.setProcessors(getUtility(IProcessorSet).getAll())
         target_archive.build_debug_symbols = True
         existing_source = self.test_publisher.getPubSource(
             archive=target_archive, version='1.0-1', distroseries=nobby,
@@ -1283,6 +1290,7 @@
 
     def _setup_archive(self, version="1.0-2", use_nobby=False, **kwargs):
         archive = self.test_publisher.ubuntutest.main_archive
+        archive.setProcessors(getUtility(IProcessorSet).getAll())
         nobby = self.createNobby(('i386', 'hppa'))
         source = self.test_publisher.getPubSource(
             archive=archive, version=version, architecturehintlist='any',
@@ -1769,7 +1777,9 @@
         # If the destination distroseries supports more architectures than
         # the source distroseries, then the copier propagates
         # architecture-independent binaries to the new architectures.
-        new_series, _ = self.makeSeriesWithExtraArchitecture()
+        new_series, new_das = self.makeSeriesWithExtraArchitecture()
+        self.primary.setProcessors(
+            self.primary.processors + [new_das.processor])
         source = self.test_publisher.getPubSource(
             archive=self.primary, status=PackagePublishingStatus.PUBLISHED,
             architecturehintlist="all")
@@ -1801,6 +1811,8 @@
         # they were built, the copier creates builds for the new
         # architectures.
         new_series, new_das = self.makeSeriesWithExtraArchitecture()
+        self.primary.setProcessors(
+            self.primary.processors + [new_das.processor])
         source = self.test_publisher.getPubSource(
             archive=self.primary, status=PackagePublishingStatus.PUBLISHED,
             architecturehintlist="any")

=== modified file 'lib/lp/soyuz/scripts/tests/test_ppa_apache_log_parser.py'
--- lib/lp/soyuz/scripts/tests/test_ppa_apache_log_parser.py	2013-06-20 05:50:00 +0000
+++ lib/lp/soyuz/scripts/tests/test_ppa_apache_log_parser.py	2015-05-19 03:12:14 +0000
@@ -6,6 +6,7 @@
 
 from zope.component import getUtility
 
+from lp.buildmaster.interfaces.processor import IProcessorSet
 from lp.registry.interfaces.person import IPersonSet
 from lp.services.database.interfaces import IStore
 from lp.services.worlddata.interfaces.country import ICountrySet
@@ -78,6 +79,7 @@
 
         self.archive = getUtility(IPersonSet).getByName('cprov').archive
         self.archive.require_virtualized = False
+        self.archive.setProcessors(getUtility(IProcessorSet).getAll())
 
         self.foo_i386, self.foo_hppa = self.publisher.getPubBinaries(
                 archive=self.archive, architecturespecific=True)

=== modified file 'lib/lp/soyuz/tests/test_archive.py'
--- lib/lp/soyuz/tests/test_archive.py	2015-05-19 00:41:13 +0000
+++ lib/lp/soyuz/tests/test_archive.py	2015-05-19 03:12:14 +0000
@@ -76,7 +76,6 @@
     RedirectedPocket,
     VersionRequiresName,
     )
-from lp.soyuz.interfaces.archivearch import IArchiveArchSet
 from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet
 from lp.soyuz.interfaces.binarypackagebuild import BuildSetStatus
 from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet
@@ -1014,7 +1013,6 @@
         self.publisher = SoyuzTestPublisher()
         self.publisher.prepareBreezyAutotest()
         self.archive = self.factory.makeArchive()
-        self.archive_arch_set = getUtility(IArchiveArchSet)
         self.default_procs = [
             getUtility(IProcessorSet).getByName("386"),
             getUtility(IProcessorSet).getByName("amd64")]
@@ -1026,13 +1024,14 @@
     def test_new_default_processors(self):
         # ArchiveSet.new creates an ArchiveArch for each Processor with
         # build_by_default set.
+        self.factory.makeProcessor(name='default', build_by_default=True)
+        self.factory.makeProcessor(name='nondefault', build_by_default=False)
         archive = getUtility(IArchiveSet).new(
             owner=self.factory.makePerson(), purpose=ArchivePurpose.PPA,
             distribution=self.factory.makeDistribution(), name='ppa')
         self.assertContentEqual(
-            ['386', 'amd64'],
-            [aa.processor.name for aa in
-             self.archive_arch_set.getByArchive(archive)])
+            ['386', 'amd64', 'hppa', 'default'],
+            [processor.name for processor in archive.processors])
 
     def test_new_override_processors(self):
         # ArchiveSet.new can be given a custom set of processors.
@@ -1041,87 +1040,32 @@
             distribution=self.factory.makeDistribution(), name='ppa',
             processors=[self.arm])
         self.assertContentEqual(
-            ['arm'],
-            [aa.processor.name for aa in
-             self.archive_arch_set.getByArchive(archive)])
-
-    def test_default(self):
-        """By default, ARM builds are not allowed as ARM is restricted."""
-        self.assertEqual(0,
-            self.archive_arch_set.getByArchive(
-                self.archive, self.arm).count())
-        self.assertContentEqual(
-            self.unrestricted_procs, self.archive.processors)
-        self.assertContentEqual([], self.archive.enabled_restricted_processors)
-
-    def test_get_uses_archivearch(self):
-        """Adding an entry to ArchiveArch for ARM and an archive will
-        enable enabled_restricted_processors for arm for that archive."""
-        self.assertContentEqual(
-            self.unrestricted_procs, self.archive.processors)
-        self.assertContentEqual([], self.archive.enabled_restricted_processors)
-        self.archive_arch_set.new(self.archive, self.arm)
-        self.assertContentEqual(
-            [self.arm] + self.unrestricted_procs, self.archive.processors)
-        self.assertContentEqual(
-            [self.arm], self.archive.enabled_restricted_processors)
+            ['arm'], [processor.name for processor in archive.processors])
 
     def test_get_returns_restricted_only(self):
-        """Adding an entry to ArchiveArch for something that is not
-        restricted does not make it show up in enabled_restricted_processors.
+        """Only restricted processors showup in enabled_restricted_processors.
         """
         self.assertContentEqual(
             self.unrestricted_procs, self.archive.processors)
         self.assertContentEqual([], self.archive.enabled_restricted_processors)
-        new_proc = self.factory.makeProcessor(
+        uproc = self.factory.makeProcessor(
             restricted=False, build_by_default=True)
-        self.archive_arch_set.new(self.archive, new_proc)
+        rproc = self.factory.makeProcessor(
+            restricted=True, build_by_default=False)
+        self.archive.setProcessors([uproc, rproc])
+        self.assertContentEqual([uproc, rproc], self.archive.processors)
         self.assertContentEqual(
-            self.unrestricted_procs + [new_proc], self.archive.processors)
-        self.assertContentEqual([], self.archive.enabled_restricted_processors)
+            [rproc], self.archive.enabled_restricted_processors)
 
     def test_set(self):
-        """The property remembers its value correctly and sets ArchiveArch.
-
-        It's not yet possible to remove the default processors from the set.
-        """
-        self.archive.processors = [self.arm]
-        allowed_restricted_processors = self.archive_arch_set.getByArchive(
-            self.archive, self.arm)
-        self.assertEqual(1, allowed_restricted_processors.count())
-        self.assertEqual(
-            self.arm, allowed_restricted_processors[0].processor)
-        self.assertContentEqual(
-            [self.arm] + self.unrestricted_procs, self.archive.processors)
-        self.archive.processors = []
-        self.assertEqual(
-            0,
-            self.archive_arch_set.getByArchive(self.archive, self.arm).count())
-        self.assertContentEqual(
-            self.unrestricted_procs, self.archive.processors)
-
-    def test_set_doesnt_remove_default(self):
-        """During the data migration the property must not remove defaults.
-
-        _getProcessors doesn't yet rely on ArchiveArches for
-        non-restricted processors, since the rows don't exist on
-        production yet, but if they do exist then they won't be removed
-        on set. We'll backfill them while this version of the code is
-        running.
-        """
-        i386 = getUtility(IProcessorSet).getByName("386")
-        self.archive.processors = [i386, self.arm]
-        self.assertContentEqual(
-            self.default_procs + [self.arm],
-            [aa.processor for aa in
-             self.archive_arch_set.getByArchive(self.archive)])
-        self.archive.processors = []
-        self.assertContentEqual(
-            self.default_procs,
-            [aa.processor for aa in
-             self.archive_arch_set.getByArchive(self.archive)])
-        self.assertContentEqual(
-            self.unrestricted_procs, self.archive.processors)
+        """The property remembers its value correctly."""
+        self.archive.setProcessors([self.arm])
+        self.assertContentEqual([self.arm], self.archive.processors)
+        self.archive.setProcessors(self.unrestricted_procs + [self.arm])
+        self.assertContentEqual(
+            self.unrestricted_procs + [self.arm], self.archive.processors)
+        self.archive.processors = []
+        self.assertContentEqual([], self.archive.processors)
 
     def test_set_enabled_restricted_processors(self):
         """The deprecated enabled_restricted_processors property still works.
@@ -1129,17 +1073,11 @@
         It's like processors, but only including those that are restricted.
         """
         self.archive.enabled_restricted_processors = [self.arm]
-        allowed_restricted_processors = self.archive_arch_set.getByArchive(
-            self.archive, self.arm)
-        self.assertEqual(1, allowed_restricted_processors.count())
-        self.assertEqual(
-            self.arm, allowed_restricted_processors[0].processor)
-        self.assertEqual(
+        self.assertContentEqual(
+            self.unrestricted_procs + [self.arm], self.archive.processors)
+        self.assertContentEqual(
             [self.arm], self.archive.enabled_restricted_processors)
         self.archive.enabled_restricted_processors = []
-        self.assertEqual(
-            0,
-            self.archive_arch_set.getByArchive(self.archive, self.arm).count())
         self.assertContentEqual(
             self.unrestricted_procs, self.archive.processors)
         self.assertContentEqual([], self.archive.enabled_restricted_processors)

=== removed file 'lib/lp/soyuz/tests/test_archivearch.py'
--- lib/lp/soyuz/tests/test_archivearch.py	2015-05-19 00:41:13 +0000
+++ lib/lp/soyuz/tests/test_archivearch.py	1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
-# Copyright 2010-2012 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Test ArchiveArch features."""
-
-from zope.component import getUtility
-
-from lp.registry.interfaces.distribution import IDistributionSet
-from lp.registry.interfaces.person import IPersonSet
-from lp.soyuz.interfaces.archivearch import IArchiveArchSet
-from lp.testing import TestCaseWithFactory
-from lp.testing.layers import LaunchpadZopelessLayer
-
-
-class TestArchiveArch(TestCaseWithFactory):
-
-    layer = LaunchpadZopelessLayer
-
-    def setUp(self):
-        """Use `SoyuzTestPublisher` to publish some sources in archives."""
-        super(TestArchiveArch, self).setUp()
-
-        self.archive_arch_set = getUtility(IArchiveArchSet)
-        self.ppa = getUtility(IPersonSet).getByName('cprov').archive
-        ubuntu = getUtility(IDistributionSet)['ubuntu']
-        self.ubuntu_archive = ubuntu.main_archive
-        self.cell_proc = self.factory.makeProcessor(
-            'cell-proc', 'PS cell processor', 'Screamingly faaaaaaaaaaaast',
-            restricted=True, build_by_default=False)
-        self.omap = self.factory.makeProcessor(
-            'omap', 'Multimedia applications processor',
-            'Does all your sound & video', restricted=True,
-            build_by_default=False)
-
-    def test_getByArchive_no_other_archives(self):
-        # Test ArchiveArchSet.getByArchive returns no other archives.
-        self.archive_arch_set.new(self.ppa, self.cell_proc)
-        self.archive_arch_set.new(self.ubuntu_archive, self.omap)
-        result = self.archive_arch_set.getByArchive(self.ppa)
-        self.assertContentEqual([self.ppa], set(aa.archive for aa in result))
-
-    def test_getByArchive_specific_architecture(self):
-        # ArchiveArchSet.getByArchive can query for a specific architecture
-        # association.
-        self.archive_arch_set.new(self.ppa, self.cell_proc)
-        self.archive_arch_set.new(self.ppa, self.omap)
-        result_set = list(
-            self.archive_arch_set.getByArchive(self.ppa, self.cell_proc))
-        self.assertEqual(1, len(result_set))
-        self.assertEqual(self.ppa, result_set[0].archive)
-        self.assertEqual(self.cell_proc, result_set[0].processor)

=== modified file 'lib/lp/soyuz/tests/test_build_set.py'
--- lib/lp/soyuz/tests/test_build_set.py	2015-05-19 00:41:13 +0000
+++ lib/lp/soyuz/tests/test_build_set.py	2015-05-19 03:12:14 +0000
@@ -13,7 +13,6 @@
     ArchivePurpose,
     SourcePackageFormat,
     )
-from lp.soyuz.interfaces.archivearch import IArchiveArchSet
 from lp.soyuz.interfaces.binarypackagebuild import (
     BuildSetStatus,
     IBinaryPackageBuildSet,
@@ -306,7 +305,11 @@
         self.avr.build_by_default = False
         self.avr.restricted = True
         archive = self.factory.makeArchive(distribution=self.distro)
-        getUtility(IArchiveArchSet).new(archive, self.avr)
+        self.assertContentEqual(
+            [self.distroseries['sparc']],
+            BinaryPackageBuildSet()._getAllowedArchitectures(
+                archive, self.distroseries.architectures))
+        archive.setProcessors(archive.processors + [self.avr])
         self.assertContentEqual(
             [self.distroseries['sparc'], self.distroseries['avr']],
             BinaryPackageBuildSet()._getAllowedArchitectures(
@@ -348,7 +351,6 @@
     def setUp(self):
         super(BuildRecordCreationTests, self).setUp()
         self.distro = self.factory.makeDistribution()
-        self.archive = self.factory.makeArchive(distribution=self.distro)
         self.avr = self.factory.makeProcessor(
             name="avr2001", supports_virtualized=True)
         self.sparc = self.factory.makeProcessor(
@@ -375,6 +377,10 @@
         self.distroseries2.nominatedarchindep = self.distroseries2['x32']
         self.addFakeChroots(self.distroseries2)
 
+        # Initialised by the first createBuilds in case the test needs
+        # to tweak arch settings.
+        self.archive = None
+
     def getPubSource(self, architecturehintlist):
         """Return a mock source package publishing record for the archive
         and architecture used in this testcase.
@@ -383,10 +389,12 @@
             (e.g. "i386 amd64")
         """
         return super(BuildRecordCreationTests, self).getPubSource(
-            archive=self.archive, distroseries=self.distroseries,
+            archive=self.factory.makeArchive(), distroseries=self.distroseries,
             architecturehintlist=architecturehintlist)
 
     def createBuilds(self, spr, distroseries):
+        if self.archive is None:
+            self.archive = self.factory.makeArchive(distribution=self.distro)
         self.factory.makeSourcePackagePublishingHistory(
             sourcepackagerelease=spr, archive=self.archive,
             distroseries=distroseries, pocket=PackagePublishingPocket.RELEASE)
@@ -450,7 +458,8 @@
         """
         self.avr.build_by_default = False
         self.avr.restricted = True
-        getUtility(IArchiveArchSet).new(self.archive, self.avr)
+        self.archive = self.factory.makeArchive(distribution=self.distro)
+        self.archive.setProcessors(self.archive.processors + [self.avr])
         spr = self.factory.makeSourcePackageRelease(architecturehintlist='any')
         builds = self.createBuilds(spr, self.distroseries)
         self.assertBuildsMatch({'sparc': True, 'avr': False}, builds)


Follow ups