← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/switch-to-processor into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/switch-to-processor into lp:launchpad with lp:~stevenk/launchpad/db-no-not-null-pf as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1225856 in Launchpad itself: "ProcessorFamily mostly just duplicates Processor"
  https://bugs.launchpad.net/launchpad/+bug/1225856

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/switch-to-processor/+merge/187441

Switch parts of ArchiveArch and DistroArchSeries to query on processor now, in the lead up to ProcessorFamily's death.
-- 
https://code.launchpad.net/~stevenk/launchpad/switch-to-processor/+merge/187441
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/switch-to-processor into lp:launchpad.
=== modified file 'lib/lp/archivepublisher/tests/test_generate_extra_overrides.py'
--- lib/lp/archivepublisher/tests/test_generate_extra_overrides.py	2013-08-29 10:29:01 +0000
+++ lib/lp/archivepublisher/tests/test_generate_extra_overrides.py	2013-09-25 03:59:02 +0000
@@ -151,7 +151,7 @@
         for das in dases:
             build = self.factory.makeBinaryPackageBuild(
                 source_package_release=spph.sourcepackagerelease,
-                distroarchseries=das, processor=das.default_processor)
+                distroarchseries=das, processor=das.processor)
             bpr = self.factory.makeBinaryPackageRelease(
                 binarypackagename=package.name, build=build,
                 component=component, architecturespecific=True,

=== modified file 'lib/lp/code/model/sourcepackagerecipebuild.py'
--- lib/lp/code/model/sourcepackagerecipebuild.py	2013-09-02 08:11:58 +0000
+++ lib/lp/code/model/sourcepackagerecipebuild.py	2013-09-25 03:59:02 +0000
@@ -433,7 +433,7 @@
 
     @property
     def processor(self):
-        return self.build.distroseries.nominatedarchindep.default_processor
+        return self.build.distroseries.nominatedarchindep.processor
 
     @property
     def virtualized(self):

=== modified file 'lib/lp/code/model/tests/test_sourcepackagerecipebuild.py'
--- lib/lp/code/model/tests/test_sourcepackagerecipebuild.py	2013-09-02 08:11:58 +0000
+++ lib/lp/code/model/tests/test_sourcepackagerecipebuild.py	2013-09-25 03:59:02 +0000
@@ -110,8 +110,7 @@
         # They do require specific environments.
         self.assertNotEqual(None, bq.processor)
         self.assertEqual(
-            spb.distroseries.nominatedarchindep.default_processor,
-            bq.processor)
+            spb.distroseries.nominatedarchindep.processor, bq.processor)
         self.assertEqual(bq, spb.buildqueue_record)
 
     def test_title(self):

=== modified file 'lib/lp/registry/model/distroseries.py'
--- lib/lp/registry/model/distroseries.py	2013-09-10 05:00:15 +0000
+++ lib/lp/registry/model/distroseries.py	2013-09-25 03:59:02 +0000
@@ -349,24 +349,18 @@
 
     def getDistroArchSeriesByProcessor(self, processor):
         """See `IDistroSeries`."""
-        # XXX: JRV 2010-01-14: This should ideally use storm to find the
-        # distroarchseries rather than iterating over all of them, but
-        # I couldn't figure out how to do that - and a trivial for loop
-        # isn't expensive given there's generally less than a dozen
-        # architectures.
-        for architecture in self.architectures:
-            if architecture.processorfamily == processor.family:
-                return architecture
-        return None
+        return Store.of(self).find(
+            DistroArchSeries,
+            DistroArchSeries.distroseriesID == self.id,
+            DistroArchSeries.processor_id == processor.id).one()
 
     @property
     def enabled_architectures(self):
-        store = Store.of(self)
-        results = store.find(
+        return Store.of(self).find(
             DistroArchSeries,
             DistroArchSeries.distroseries == self,
-            DistroArchSeries.enabled == True)
-        return results.order_by(DistroArchSeries.architecturetag)
+            DistroArchSeries.enabled == True).order_by(
+                DistroArchSeries.architecturetag)
 
     @property
     def buildable_architectures(self):

=== modified file 'lib/lp/soyuz/model/archivearch.py'
--- lib/lp/soyuz/model/archivearch.py	2013-09-20 05:25:18 +0000
+++ lib/lp/soyuz/model/archivearch.py	2013-09-25 03:59:02 +0000
@@ -23,7 +23,7 @@
     IArchiveArch,
     IArchiveArchSet,
     )
-from lp.soyuz.model.processor import ProcessorFamily
+from lp.soyuz.model.processor import Processor
 
 
 class ArchiveArch(Storm):
@@ -54,27 +54,23 @@
         IStore(ArchiveArch).add(archivearch)
         return archivearch
 
-    def getByArchive(self, archive, processorfamily=None):
+    def getByArchive(self, archive, processor=None):
         """See `IArchiveArchSet`."""
-        base_clauses = (ArchiveArch.archive == archive,)
-        if processorfamily is not None:
-            optional_clauses = (
-                ArchiveArch.processorfamily == processorfamily,)
-        else:
-            optional_clauses = ()
+        clauses = [ArchiveArch.archive == archive]
+        if processor is not None:
+            clauses.append(ArchiveArch.processor == processor)
 
-        return IStore(ArchiveArch).find(
-            ArchiveArch, *(base_clauses + optional_clauses)).order_by(
-                ArchiveArch.id)
+        return IStore(ArchiveArch).find(ArchiveArch, *clauses).order_by(
+            ArchiveArch.id)
 
     def getRestrictedFamilies(self, archive):
         """See `IArchiveArchSet`."""
         origin = (
-            ProcessorFamily,
+            Processor,
             LeftJoin(
                 ArchiveArch,
                 And(ArchiveArch.archive == archive.id,
-                    ArchiveArch.processorfamily == ProcessorFamily.id)))
+                    ArchiveArch.processor == Processor.id)))
         return IStore(ArchiveArch).using(*origin).find(
-            (ProcessorFamily, ArchiveArch),
-            ProcessorFamily.restricted == True).order_by(ProcessorFamily.name)
+            (Processor, ArchiveArch),
+            Processor.restricted == True).order_by(Processor.name)

=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py	2013-07-16 08:10:32 +0000
+++ lib/lp/soyuz/model/publishing.py	2013-09-25 03:59:02 +0000
@@ -599,12 +599,12 @@
         :param available_archs: Architectures to consider
         :return: Sequence of `IDistroArch` instances.
         """
-        # Return all distroarches with unrestricted processor families or with
-        # processor families the archive is explicitly associated with.
+        # Return all distroarches with unrestricted processors or with
+        # processors the archive is explicitly associated with.
         return [distroarch for distroarch in available_archs
-            if not distroarch.processorfamily.restricted or
-               distroarch.processorfamily in
-                    self.archive.enabled_restricted_families]
+            if not distroarch.processor.restricted or
+               distroarch.processor in
+                    self.archive.enabled_restricted_processors]
 
     def createMissingBuilds(self, architectures_available=None, logger=None):
         """See `ISourcePackagePublishingHistory`."""

=== modified file 'lib/lp/soyuz/model/sourcepackagerelease.py'
--- lib/lp/soyuz/model/sourcepackagerelease.py	2013-08-06 09:49:14 +0000
+++ lib/lp/soyuz/model/sourcepackagerelease.py	2013-09-25 03:59:02 +0000
@@ -55,7 +55,6 @@
     SQLBase,
     sqlvalues,
     )
-from lp.services.helpers import shortlist
 from lp.services.librarian.model import (
     LibraryFileAlias,
     LibraryFileContent,
@@ -357,11 +356,9 @@
     def createBuild(self, distro_arch_series, pocket, archive, processor=None,
                     status=None):
         """See ISourcePackageRelease."""
-        # Guess a processor if one is not provided
+        # If a processor is not provided, use the DAS' processor.
         if processor is None:
-            pf = distro_arch_series.processorfamily
-            # We guess at the first processor in the family
-            processor = shortlist(pf.processors)[0]
+            processor = distro_arch_series.processor
 
         if status is None:
             status = BuildStatus.NEEDSBUILD

=== modified file 'lib/lp/soyuz/tests/test_archive.py'
--- lib/lp/soyuz/tests/test_archive.py	2013-09-12 02:29:55 +0000
+++ lib/lp/soyuz/tests/test_archive.py	2013-09-25 03:59:02 +0000
@@ -1006,23 +1006,22 @@
         self.publisher.prepareBreezyAutotest()
         self.archive = self.factory.makeArchive()
         self.archive_arch_set = getUtility(IArchiveArchSet)
-        self.arm = getUtility(IProcessorFamilySet).getByName('arm')
-        self.factory.makeProcessor(family=self.arm)
+        self.arm = self.factory.makeProcessor(name='arm', restricted=True)
 
     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.assertEqual(
+            0,
+            self.archive_arch_set.getByArchive(self.archive, self.arm).count())
         self.assertContentEqual([], self.archive.enabled_restricted_families)
 
     def test_get_uses_archivearch(self):
         """Adding an entry to ArchiveArch for ARM and an archive will
         enable enabled_restricted_families for arm for that archive."""
-        self.assertContentEqual([], self.archive.enabled_restricted_families)
+        self.assertContentEqual([], self.archive.enabled_restricted_processors)
         self.archive_arch_set.new(self.archive, self.arm)
-        self.assertEqual([self.arm],
-                list(self.archive.enabled_restricted_families))
+        self.assertEqual(
+            [self.arm], list(self.archive.enabled_restricted_processors))
 
     def test_get_returns_restricted_only(self):
         """Adding an entry to ArchiveArch for something that is not
@@ -1035,17 +1034,14 @@
 
     def test_set(self):
         """The property remembers its value correctly and sets ArchiveArch."""
-        self.archive.enabled_restricted_families = [self.arm]
-        allowed_restricted_families = self.archive_arch_set.getByArchive(
+        self.archive.enabled_restricted_families = [self.arm.family]
+        allowed_restricted_processors = self.archive_arch_set.getByArchive(
             self.archive, self.arm)
-        self.assertEqual(1, allowed_restricted_families.count())
-        self.assertEqual(
-            self.arm, allowed_restricted_families[0].processorfamily)
-        self.assertEqual([self.arm], self.archive.enabled_restricted_families)
+        self.assertEqual([self.arm], allowed_restricted_processors)
         self.archive.enabled_restricted_families = []
-        self.assertEqual(0,
-            self.archive_arch_set.getByArchive(
-                self.archive, self.arm).count())
+        self.assertEqual(
+            0,
+            self.archive_arch_set.getByArchive(self.archive, self.arm).count())
         self.assertContentEqual([], self.archive.enabled_restricted_families)
 
 

=== modified file 'lib/lp/soyuz/tests/test_archivearch.py'
--- lib/lp/soyuz/tests/test_archivearch.py	2013-09-12 02:29:55 +0000
+++ lib/lp/soyuz/tests/test_archivearch.py	2013-09-25 03:59:02 +0000
@@ -26,14 +26,14 @@
         ubuntu = getUtility(IDistributionSet)['ubuntu']
         self.ubuntu_archive = ubuntu.main_archive
         pss = getUtility(IProcessorFamilySet)
-        self.cell_proc = pss.new(
+        cell_pf = pss.new(
             'cell-proc', 'PS cell processor', 'Screamingly faaaaaaaaaaaast',
             True)
-        self.cell_proc.addProcessor('Cell', '', '')
-        self.omap = pss.new(
+        self.cell_proc = cell_pf.addProcessor('Cell', '', '')
+        omap_pf = pss.new(
             'omap', 'Multimedia applications processor',
             'Does all your sound & video', True)
-        self.omap.addProcessor('Omap', '', '')
+        self.omap = omap_pf.addProcessor('Omap', '', '')
 
     def test_getRestrictedFamilies_no_restricted_associations(self):
         # Our archive is not associated with any restricted processor
@@ -46,56 +46,52 @@
     def test_getRestrictedFamilies_single_restricted_association(self):
         # Our archive is now associated with one of the restricted processor
         # families.
-        self.archive_arch_set.new(self.ppa, self.cell_proc)
+        self.archive_arch_set.new(self.ppa, self.cell_proc.family)
         result_set = list(
             self.archive_arch_set.getRestrictedFamilies(self.ppa))
         results = dict(
             (row[0].name, row[1] is not None) for row in result_set)
-        self.assertEqual(
-            {'arm': False, 'cell-proc': True, 'omap': False},
-            results)
+        self.assertEqual({u'Cell': True, u'Omap': False}, results)
 
     def test_getRestrictedFamilies_archive_only(self):
         # Test that only the associated archs for the archive itself are
         # returned.
-        self.archive_arch_set.new(self.ppa, self.cell_proc)
-        self.archive_arch_set.new(self.ubuntu_archive, self.omap)
+        self.archive_arch_set.new(self.ppa, self.cell_proc.family)
+        self.archive_arch_set.new(self.ubuntu_archive, self.omap.family)
         result_set = list(
             self.archive_arch_set.getRestrictedFamilies(self.ppa))
         results = dict(
             (row[0].name, row[1] is not None) for row in result_set)
-        self.assertEqual(
-            {'arm': False, 'cell-proc': True, 'omap': False},
-            results)
+        self.assertEqual({u'Cell': True, u'Omap': False}, results)
 
     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)
+        self.archive_arch_set.new(self.ppa, self.cell_proc.family)
+        self.archive_arch_set.new(self.ubuntu_archive, self.omap.family)
         result_set = list(self.archive_arch_set.getByArchive(self.ppa))
         self.assertEqual(1, len(result_set))
         self.assertEqual(self.ppa, result_set[0].archive)
-        self.assertEqual(self.cell_proc, result_set[0].processorfamily)
+        self.assertEqual(self.cell_proc, result_set[0].processor)
 
     def test_getByArchive_follows_creation_order(self):
         # The result of ArchiveArchSet.getByArchive follows the order in
         # which architecture associations were added.
-        self.archive_arch_set.new(self.ppa, self.cell_proc)
-        self.archive_arch_set.new(self.ppa, self.omap)
+        self.archive_arch_set.new(self.ppa, self.cell_proc.family)
+        self.archive_arch_set.new(self.ppa, self.omap.family)
         result_set = list(self.archive_arch_set.getByArchive(self.ppa))
         self.assertEqual(2, len(result_set))
         self.assertEqual(self.ppa, result_set[0].archive)
-        self.assertEqual(self.cell_proc, result_set[0].processorfamily)
+        self.assertEqual(self.cell_proc, result_set[0].processor)
         self.assertEqual(self.ppa, result_set[1].archive)
-        self.assertEqual(self.omap, result_set[1].processorfamily)
+        self.assertEqual(self.omap, result_set[1].processor)
 
     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)
+        self.archive_arch_set.new(self.ppa, self.cell_proc.family)
+        self.archive_arch_set.new(self.ppa, self.omap.family)
         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].processorfamily)
+        self.assertEqual(self.cell_proc, result_set[0].processor)

=== modified file 'lib/lp/translations/model/translationtemplatesbuild.py'
--- lib/lp/translations/model/translationtemplatesbuild.py	2013-06-20 05:50:00 +0000
+++ lib/lp/translations/model/translationtemplatesbuild.py	2013-09-25 03:59:02 +0000
@@ -127,7 +127,7 @@
         # default processor architecture.  This stops the buildfarm from
         # accidentally dispatching the jobs to private builders.
         ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
-        return ubuntu.currentseries.nominatedarchindep.default_processor
+        return ubuntu.currentseries.nominatedarchindep.processor
 
     @classmethod
     def create(cls, branch):

=== modified file 'lib/lp/translations/tests/test_translationtemplatesbuildjob.py'
--- lib/lp/translations/tests/test_translationtemplatesbuildjob.py	2013-09-02 08:11:58 +0000
+++ lib/lp/translations/tests/test_translationtemplatesbuildjob.py	2013-09-25 03:59:02 +0000
@@ -91,10 +91,9 @@
         buildqueue = queueset.get(job_id)
 
         ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
-        expected_processor = (
-            ubuntu.currentseries.nominatedarchindep.default_processor)
-
-        self.assertEquals(expected_processor, buildqueue.processor)
+        self.assertEquals(
+            ubuntu.currentseries.nominatedarchindep.processor,
+            buildqueue.processor)
 
     def test_score(self):
         # For now, these jobs always score themselves at 2510.  In the


Follow ups