launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #15100
[Merge] lp:~wgrant/launchpad/flatten-bfj-6-denorm-more-queries into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/flatten-bfj-6-denorm-more-queries into lp:launchpad with lp:~wgrant/launchpad/flatten-bfj-5-app-cleanup as a prerequisite.
Commit message:
Migrate BinaryPackageBuild queries to use the new distro/distroseries/distroarchseries/sourcepackagename/is_distro_archive columns for performance.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/flatten-bfj-6-denorm-more-queries/+merge/146817
Migrate BinaryPackageBuild queries to use the new distribution, distro_series, distro_arch_series, source_package_name and is_distro_archive columns where appropriate. Makes BPB:+retry, D:+builds, DS:+builds, DAS:+builds almost correctly fast.
DistroArchSeriesSet was accidentally killed during the renovations.
--
https://code.launchpad.net/~wgrant/launchpad/flatten-bfj-6-denorm-more-queries/+merge/146817
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/flatten-bfj-6-denorm-more-queries into lp:launchpad.
=== modified file 'lib/lp/registry/doc/distribution-mirror.txt'
--- lib/lp/registry/doc/distribution-mirror.txt 2012-12-26 01:32:19 +0000
+++ lib/lp/registry/doc/distribution-mirror.txt 2013-02-06 10:56:24 +0000
@@ -18,7 +18,7 @@
>>> from lp.registry.interfaces.pocket import PackagePublishingPocket
>>> from lp.registry.interfaces.series import SeriesStatus
>>> from lp.services.worlddata.interfaces.country import ICountrySet
- >>> from lp.soyuz.interfaces.distroarchseries import IDistroArchSeriesSet
+ >>> from lp.soyuz.model.distroarchseries import DistroArchSeries
>>> mirrorset = getUtility(IDistributionMirrorSet)
>>> distroset = getUtility(IDistributionSet)
>>> ubuntu = distroset.get(1)
@@ -72,7 +72,7 @@
(or ensureMirrorDistroSeriesSource) method.
>>> warty = getUtility(IDistroSeriesSet).get(1)
- >>> warty_i386 = getUtility(IDistroArchSeriesSet).get(1)
+ >>> warty_i386 = DistroArchSeries.get(1)
>>> pocket = PackagePublishingPocket.RELEASE
>>> warty_component = warty.components[0]
>>> warty_i386_mirror = new_mirror.ensureMirrorDistroArchSeries(
=== modified file 'lib/lp/registry/model/distribution.py'
--- lib/lp/registry/model/distribution.py 2013-01-22 05:07:31 +0000
+++ lib/lp/registry/model/distribution.py 2013-02-06 10:56:24 +0000
@@ -173,10 +173,7 @@
from lp.soyuz.model.distributionsourcepackagerelease import (
DistributionSourcePackageRelease,
)
-from lp.soyuz.model.distroarchseries import (
- DistroArchSeries,
- DistroArchSeriesSet,
- )
+from lp.soyuz.model.distroarchseries import DistroArchSeries
from lp.soyuz.model.publishing import (
BinaryPackagePublishingHistory,
get_current_source_releases,
@@ -987,15 +984,8 @@
# now).
# The "binary_only" option is not yet supported for
# IDistribution.
-
- # Find out the distroarchseries in question.
- arch_ids = DistroArchSeriesSet().getIdsForArchitectures(
- self.architectures, arch_tag)
-
- # Use the facility provided by IBinaryPackageBuildSet to
- # retrieve the records.
- return getUtility(IBinaryPackageBuildSet).getBuildsByArchIds(
- self, arch_ids, build_state, name, pocket)
+ return getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
+ self, build_state, name, pocket, arch_tag)
def searchSourcePackageCaches(
self, text, has_packaging=None, publishing_distroseries=None):
=== modified file 'lib/lp/registry/model/distroseries.py'
--- lib/lp/registry/model/distroseries.py 2013-01-22 05:07:31 +0000
+++ lib/lp/registry/model/distroseries.py 2013-02-06 10:56:24 +0000
@@ -142,7 +142,6 @@
from lp.soyuz.model.component import Component
from lp.soyuz.model.distroarchseries import (
DistroArchSeries,
- DistroArchSeriesSet,
PocketChroot,
)
from lp.soyuz.model.distroseriesbinarypackage import DistroSeriesBinaryPackage
@@ -1022,15 +1021,8 @@
# Ignore "user", since it would not make any difference to the
# records returned here (private builds are only in PPA right
# now). We also ignore binary_only and always return binaries.
-
- # Find out the distroarchseries in question.
- arch_ids = DistroArchSeriesSet().getIdsForArchitectures(
- self.architectures, arch_tag)
-
- # Use the facility provided by IBinaryPackageBuildSet to
- # retrieve the records.
- return getUtility(IBinaryPackageBuildSet).getBuildsByArchIds(
- self.distribution, arch_ids, build_state, name, pocket)
+ return getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
+ self, build_state, name, pocket, arch_tag)
def createUploadedSourcePackageRelease(
self, sourcepackagename, version, maintainer, builddepends,
=== modified file 'lib/lp/registry/model/sourcepackagename.py'
--- lib/lp/registry/model/sourcepackagename.py 2013-01-07 02:40:55 +0000
+++ lib/lp/registry/model/sourcepackagename.py 2013-02-06 10:56:24 +0000
@@ -129,16 +129,13 @@
cur.execute("""SELECT DISTINCT BinaryPackageName.name,
SourcePackageName.name
FROM BinaryPackageRelease, SourcePackageName,
- BinaryPackageBuild, SourcePackageRelease,
- BinaryPackageName
+ BinaryPackageBuild, BinaryPackageName
WHERE
BinaryPackageName.id =
BinaryPackageRelease.binarypackagename AND
BinaryPackageRelease.build = BinaryPackageBuild.id AND
- SourcePackageRelease.sourcepackagename =
+ BinaryPackageBuild.source_package_name =
SourcePackageName.id AND
- BinaryPackageBuild.source_package_release =
- SourcePackageRelease.id AND
%s
ORDER BY BinaryPackageName.name,
SourcePackageName.name"""
=== modified file 'lib/lp/soyuz/configure.zcml'
--- lib/lp/soyuz/configure.zcml 2013-01-22 02:06:41 +0000
+++ lib/lp/soyuz/configure.zcml 2013-02-06 10:56:24 +0000
@@ -626,20 +626,6 @@
factory="lp.soyuz.browser.distroarchseries.DistroArchSeriesBreadcrumb"
permission="zope.Public" />
- <!-- DistroArchSeriesSet -->
-
- <class
- class="lp.soyuz.model.distroarchseries.DistroArchSeriesSet">
- <allow
- interface="lp.soyuz.interfaces.distroarchseries.IDistroArchSeriesSet"/>
- </class>
- <securedutility
- class="lp.soyuz.model.distroarchseries.DistroArchSeriesSet"
- provides="lp.soyuz.interfaces.distroarchseries.IDistroArchSeriesSet">
- <allow
- interface="lp.soyuz.interfaces.distroarchseries.IDistroArchSeriesSet"/>
- </securedutility>
-
<!-- PocketChroot -->
<class
=== modified file 'lib/lp/soyuz/doc/distroarchseries.txt'
--- lib/lp/soyuz/doc/distroarchseries.txt 2012-12-26 01:32:19 +0000
+++ lib/lp/soyuz/doc/distroarchseries.txt 2013-02-06 10:56:24 +0000
@@ -374,34 +374,3 @@
>>> print_architectures(hoary.buildable_architectures)
The Hoary Hedgehog Release for hppa (hppa) (ppa)
The Hoary Hedgehog Release for i386 (x86) (official, ppa)
-
-
-===========================
-DistroArchSeriesSet Methods
-===========================
-
-The `DistroArchSeriesSet` class provides a helper method
-getIdsForArchitectures() - not exposed through the `IDistroArchSeriesSet`
-interface - which will filter an iterable of DistroArchSeries
-using an optional arch_tag and return a list of their IDs.
-
- >>> architectures = [
- ... factory.makeDistroArchSeries(architecturetag='i986'),
- ... factory.makeDistroArchSeries(architecturetag='i986'),
- ... factory.makeDistroArchSeries(architecturetag='powerpc'),
- ... ]
- >>> from lp.soyuz.model.distroarchseries import DistroArchSeriesSet
- >>> distroarchseries_set = DistroArchSeriesSet()
-
- >>> arch_ids = distroarchseries_set.getIdsForArchitectures(architectures)
- >>> len(arch_ids)
- 3
- >>> isinstance(arch_ids[0], int)
- True
- >>> len(distroarchseries_set.getIdsForArchitectures(architectures,
- ... arch_tag='i986'))
- 2
- >>> len(distroarchseries_set.getIdsForArchitectures(architectures,
- ... arch_tag='powerpc'))
- 1
-
=== modified file 'lib/lp/soyuz/interfaces/binarypackagebuild.py'
--- lib/lp/soyuz/interfaces/binarypackagebuild.py 2013-02-05 06:11:57 +0000
+++ lib/lp/soyuz/interfaces/binarypackagebuild.py 2013-02-06 10:56:24 +0000
@@ -341,9 +341,9 @@
:return: a `ResultSet` representing the requested builds.
"""
- def getBuildsByArchIds(distribution, arch_ids, status=None, name=None,
- pocket=None):
- """Retrieve Build Records for a given arch_ids list.
+ def getBuildsForDistro(context, status=None, name=None, pocket=None,
+ arch_tag=None):
+ """Retrieve `IBinaryPackageBuild`s for a given Distribution/DS/DAS.
Optionally, for a given status and/or pocket, if ommited return all
records. If name is passed return only the builds which the
=== modified file 'lib/lp/soyuz/interfaces/distroarchseries.py'
--- lib/lp/soyuz/interfaces/distroarchseries.py 2013-01-07 02:40:55 +0000
+++ lib/lp/soyuz/interfaces/distroarchseries.py 2013-02-06 10:56:24 +0000
@@ -7,7 +7,6 @@
__all__ = [
'IDistroArchSeries',
- 'IDistroArchSeriesSet',
'IPocketChroot',
]
@@ -185,19 +184,6 @@
"""
-class IDistroArchSeriesSet(Interface):
- """Interface for DistroArchSeriesSet"""
-
- def __iter__():
- """Iterate over distroarchseriess."""
-
- def count():
- """Return the number of distroarchseriess in the system."""
-
- def get(distroarchseries_id):
- """Return the IDistroArchSeries to the given distroarchseries_id."""
-
-
class IPocketChroot(Interface):
"""PocketChroot Table Interface"""
id = Attribute("Identifier")
=== modified file 'lib/lp/soyuz/model/binarypackagebuild.py'
--- lib/lp/soyuz/model/binarypackagebuild.py 2013-02-06 10:56:23 +0000
+++ lib/lp/soyuz/model/binarypackagebuild.py 2013-02-06 10:56:24 +0000
@@ -47,6 +47,8 @@
from lp.buildmaster.model.buildfarmjob import BuildFarmJob
from lp.buildmaster.model.buildqueue import BuildQueue
from lp.buildmaster.model.packagebuild import PackageBuildMixin
+from lp.registry.interfaces.distribution import IDistribution
+from lp.registry.interfaces.distroseries import IDistroSeries
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.services.config import config
from lp.services.database.bulk import load_related
@@ -85,6 +87,7 @@
IBinaryPackageBuildSet,
UnparsableDependencies,
)
+from lp.soyuz.interfaces.distroarchseries import IDistroArchSeries
from lp.soyuz.model.binarypackagename import BinaryPackageName
from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
from lp.soyuz.model.buildpackagejob import BuildPackageJob
@@ -597,20 +600,16 @@
# and get the (successfully built) build records for this
# package.
completed_builds = BinaryPackageBuild.select("""
- BinaryPackageBuild.source_package_release =
- SourcePackageRelease.id AND
+ BinaryPackageBuild.source_package_name = %s AND
BinaryPackageBuild.id != %s AND
BinaryPackageBuild.distro_arch_series = %s AND
- SourcePackageRelease.sourcepackagename = SourcePackageName.id AND
- SourcePackageName.name = %s AND
BinaryPackageBuild.archive IN %s AND
BinaryPackageBuild.date_finished IS NOT NULL AND
BinaryPackageBuild.status = %s
- """ % sqlvalues(self, self.distro_arch_series,
- self.source_package_release.name, archives,
+ """ % sqlvalues(self.source_package_name, self,
+ self.distro_arch_series, archives,
BuildStatus.FULLYBUILT),
- orderBy=['-date_finished', '-id'],
- clauseTables=['SourcePackageName', 'SourcePackageRelease'])
+ orderBy=['-date_finished', '-id'])
estimated_duration = None
if bool(completed_builds):
@@ -927,7 +926,6 @@
# Circular. :(
from lp.registry.model.sourcepackagename import SourcePackageName
from lp.soyuz.model.distroarchseries import DistroArchSeries
- from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
origin.append(BinaryPackageBuild)
@@ -953,12 +951,10 @@
# Add query clause that filters on source package release name if the
# latter is provided.
if name is not None:
- clauses.extend(
- [BinaryPackageBuild.source_package_release_id ==
- SourcePackageRelease.id,
- SourcePackageRelease.sourcepackagenameID ==
- SourcePackageName.id])
- origin.extend([SourcePackageRelease, SourcePackageName])
+ clauses.append(
+ BinaryPackageBuild.source_package_name_id ==
+ SourcePackageName.id)
+ origin.extend([SourcePackageName])
if not isinstance(name, (list, tuple)):
clauses.append(
SourcePackageName.name.contains_string(name))
@@ -1010,20 +1006,18 @@
IStore(BinaryPackageBuild).using(*origin).find(
BinaryPackageBuild, *clauses).order_by(*orderBy))
- def getBuildsByArchIds(self, distribution, arch_ids, status=None,
- name=None, pocket=None):
+ def getBuildsForDistro(self, context, status=None, name=None,
+ pocket=None, arch_tag=None):
"""See `IBinaryPackageBuildSet`."""
- # If no distroarchseries were passed in, return an empty list
- if not arch_ids:
- return EmptyResultSet()
-
- # format clause according single/multiple architecture(s) form
- if len(arch_ids) == 1:
- condition_clauses = [('distro_arch_series=%s'
- % sqlvalues(arch_ids[0]))]
+ if IDistribution.providedBy(context):
+ col = BinaryPackageBuild.distribution_id
+ elif IDistroSeries.providedBy(context):
+ col = BinaryPackageBuild.distro_series_id
+ elif IDistroArchSeries.providedBy(context):
+ col = BinaryPackageBuild.distro_arch_series_id
else:
- condition_clauses = [('distro_arch_series IN %s'
- % sqlvalues(arch_ids))]
+ raise AssertionError("Unsupported context: %r" % context)
+ condition_clauses = [col == context.id]
# XXX cprov 2006-09-25: It would be nice if we could encapsulate
# the chunk of code below (which deals with the optional paramenters)
@@ -1069,18 +1063,16 @@
# End of duplication (see XXX cprov 2006-09-25 above).
self.handleOptionalParamsForBuildQueries(
- condition_clauses, clauseTables, status, name, pocket)
+ condition_clauses, clauseTables, status, name, pocket, arch_tag)
# Only pick builds from the distribution's main archive to
# exclude PPA builds
- condition_clauses.append(
- "BinaryPackageBuild.archive IN %s" %
- sqlvalues(list(distribution.all_distro_archive_ids)))
+ condition_clauses.append("BinaryPackageBuild.is_distro_archive")
find_spec = (BinaryPackageBuild,)
if order_by_table:
find_spec = find_spec + (order_by_table,)
- result_set = Store.of(distribution).using(*clauseTables).find(
+ result_set = IStore(BinaryPackageBuild).using(*clauseTables).find(
find_spec, *condition_clauses)
result_set.order_by(*order_by)
@@ -1104,21 +1096,16 @@
if (sourcepackagerelease_ids is None or
len(sourcepackagerelease_ids) == 0):
return []
- # Circular.
- from lp.soyuz.model.archive import Archive
-
query = """
source_package_release IN %s AND
- archive.id = binarypackagebuild.archive AND
- archive.purpose != %s
- """ % sqlvalues(sourcepackagerelease_ids, ArchivePurpose.PPA)
+ binarypackagebuild.is_distro_archive
+ """ % sqlvalues(sourcepackagerelease_ids)
if buildstate is not None:
query += (
"AND binarypackagebuild.status = %s" % sqlvalues(buildstate))
- resultset = IStore(BinaryPackageBuild).using(
- BinaryPackageBuild, Archive).find(
+ resultset = IStore(BinaryPackageBuild).find(
BinaryPackageBuild,
SQL(query))
resultset.order_by(
=== modified file 'lib/lp/soyuz/model/distributionsourcepackagerelease.py'
--- lib/lp/soyuz/model/distributionsourcepackagerelease.py 2013-02-06 10:56:23 +0000
+++ lib/lp/soyuz/model/distributionsourcepackagerelease.py 2013-02-06 10:56:24 +0000
@@ -88,11 +88,6 @@
@property
def builds(self):
"""See IDistributionSourcePackageRelease."""
- # Import DistroArchSeries here to avoid circular imports.
- from lp.soyuz.model.distroarchseries import (
- DistroArchSeries)
- from lp.registry.model.distroseries import DistroSeries
-
# We want to return all the builds for this distribution that
# were built for a main archive together with the builds for this
# distribution that were built for a PPA but have been published
@@ -100,9 +95,7 @@
builds_for_distro_exprs = (
(BinaryPackageBuild.source_package_release ==
self.sourcepackagerelease),
- BinaryPackageBuild.distro_arch_series == DistroArchSeries.id,
- DistroArchSeries.distroseries == DistroSeries.id,
- DistroSeries.distribution == self.distribution,
+ BinaryPackageBuild.distribution == self.distribution,
)
# First, get all the builds built in a main archive (this will
=== modified file 'lib/lp/soyuz/model/distroarchseries.py'
--- lib/lp/soyuz/model/distroarchseries.py 2013-01-07 02:40:55 +0000
+++ lib/lp/soyuz/model/distroarchseries.py 2013-02-06 10:56:24 +0000
@@ -2,10 +2,10 @@
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
-__all__ = ['DistroArchSeries',
- 'DistroArchSeriesSet',
- 'PocketChroot'
- ]
+__all__ = [
+ 'DistroArchSeries',
+ 'PocketChroot'
+ ]
from sqlobject import (
BoolCol,
@@ -45,7 +45,6 @@
from lp.soyuz.interfaces.buildrecords import IHasBuildRecords
from lp.soyuz.interfaces.distroarchseries import (
IDistroArchSeries,
- IDistroArchSeriesSet,
IPocketChroot,
)
from lp.soyuz.interfaces.publishing import ICanPublishPackages
@@ -263,9 +262,8 @@
# Use the facility provided by IBinaryPackageBuildSet to
# retrieve the records.
- return getUtility(IBinaryPackageBuildSet).getBuildsByArchIds(
- self.distroseries.distribution, [self.id], build_state, name,
- pocket)
+ return getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
+ self, build_state, name, pocket)
def getReleasedPackages(self, binary_name, pocket=None,
include_pending=False, archive=None):
@@ -354,43 +352,6 @@
return self.distroseries.distribution.main_archive
-class DistroArchSeriesSet:
- """This class is to deal with DistroArchSeries related stuff"""
-
- implements(IDistroArchSeriesSet)
-
- def __iter__(self):
- return iter(DistroArchSeries.select())
-
- def get(self, dar_id):
- """See `IDistributionSet`."""
- return DistroArchSeries.get(dar_id)
-
- def count(self):
- return DistroArchSeries.select().count()
-
- def getIdsForArchitectures(self, architectures, arch_tag=None):
- """Filter architectures and return the ids.
-
- This method is not exposed via the public interface as it is
- used simply to keep trusted code DRY.
-
- :param architectures: an iterable of architectures to process.
- :param arch_tag: an optional architecture tag or a tag list with
- which to filter the results.
- :return: a list of the ids of the architectures matching arch_tag.
- """
- # If arch_tag was not provided, just return the ids without
- # filtering.
- if arch_tag is None:
- return [arch.id for arch in architectures]
- else:
- if not isinstance(arch_tag, (list, tuple)):
- arch_tag = (arch_tag, )
- return [arch.id for arch in architectures
- if arch.architecturetag in arch_tag]
-
-
class PocketChroot(SQLBase):
implements(IPocketChroot)
_table = "PocketChroot"
=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py 2013-02-06 10:56:23 +0000
+++ lib/lp/soyuz/model/publishing.py 2013-02-06 10:56:24 +0000
@@ -1584,12 +1584,13 @@
# We'll be looking for builds in the same distroseries as the
# SPPH for the same release.
builds_for_distroseries_expr = (
- BinaryPackageBuild.distro_arch_series_id == DistroArchSeries.id,
SourcePackagePublishingHistory.distroseriesID ==
- DistroArchSeries.distroseriesID,
+ BinaryPackageBuild.distro_series_id,
SourcePackagePublishingHistory.sourcepackagereleaseID ==
BinaryPackageBuild.source_package_release_id,
- SourcePackagePublishingHistory.id.is_in(source_publication_ids))
+ SourcePackagePublishingHistory.id.is_in(source_publication_ids),
+ DistroArchSeries.id == BinaryPackageBuild.distro_arch_series_id,
+ )
# First, we'll find the builds that were built in the same
# archive context as the published sources.
=== modified file 'lib/lp/soyuz/model/queue.py'
--- lib/lp/soyuz/model/queue.py 2013-02-06 10:56:23 +0000
+++ lib/lp/soyuz/model/queue.py 2013-02-06 10:56:24 +0000
@@ -1580,7 +1580,6 @@
"""See `IPackageUploadSet`."""
# Avoiding circular imports.
from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
- from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
archives = distroseries.distribution.getArchiveIDList()
clauses = [
@@ -1596,9 +1595,7 @@
if names is not None:
clauses.extend([
BinaryPackageBuild.id == PackageUploadBuild.buildID,
- BinaryPackageBuild.source_package_release ==
- SourcePackageRelease.id,
- SourcePackageRelease.sourcepackagename ==
+ BinaryPackageBuild.source_package_name ==
SourcePackageName.id,
SourcePackageName.name.is_in(names),
])
=== modified file 'lib/lp/soyuz/tests/test_build_set.py'
--- lib/lp/soyuz/tests/test_build_set.py 2013-01-30 04:21:58 +0000
+++ lib/lp/soyuz/tests/test_build_set.py 2013-02-06 10:56:24 +0000
@@ -48,7 +48,6 @@
self.archive = self.factory.makeArchive(
distribution=self.distroseries.distribution,
purpose=ArchivePurpose.PRIMARY)
- self.arch_ids = [arch.id for arch in self.distroseries.architectures]
with person_logged_in(self.admin):
self.publisher = SoyuzTestPublisher()
self.publisher.prepareBreezyAutotest()
@@ -78,49 +77,59 @@
b.buildqueue_record.destroySelf()
self.builds += builds
- def test_get_by_arch_ids(self):
- # Test fetching builds via the arch tag
- self.setUpBuilds()
- set = getUtility(IBinaryPackageBuildSet).getBuildsByArchIds(
- self.distribution, self.arch_ids)
- self.assertEquals(set.count(), 10)
-
- def test_get_by_no_arch_ids(self):
- # .getBuildsByArchIds still works if the list given is empty, or none
- set = getUtility(IBinaryPackageBuildSet).getBuildsByArchIds(
- self.distribution, [])
- self.assertIsInstance(set, EmptyResultSet)
- set = getUtility(IBinaryPackageBuildSet).getBuildsByArchIds(
- self.distribution, None)
- self.assertIsInstance(set, EmptyResultSet)
-
- def test_get_by_arch_ids_filter_build_status(self):
+ def test_get_for_distro_distribution(self):
+ # Test fetching builds for a distro's main archives
+ self.setUpBuilds()
+ set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
+ self.distribution)
+ self.assertEquals(set.count(), 10)
+
+ def test_get_for_distro_distroseries(self):
+ # Test fetching builds for a distroseries' main archives
+ self.setUpBuilds()
+ set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
+ self.distroseries)
+ self.assertEquals(set.count(), 10)
+
+ def test_get_for_distro_distroarchseries(self):
+ # Test fetching builds for a distroarchseries' main archives
+ self.setUpBuilds()
+ set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
+ self.das_one)
+ self.assertEquals(set.count(), 5)
+
+ def test_get_for_distro_filter_build_status(self):
# The result can be filtered based on the build status
self.setUpBuilds()
- set = getUtility(IBinaryPackageBuildSet).getBuildsByArchIds(
- self.distribution, self.arch_ids, status=BuildStatus.FULLYBUILT)
+ set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
+ self.distribution, status=BuildStatus.FULLYBUILT)
self.assertEquals(set.count(), 8)
- def test_get_by_arch_ids_filter_name(self):
+ def test_get_for_distro_filter_name(self):
# The result can be filtered based on the name
self.setUpBuilds()
spn = self.builds[2].source_package_release.sourcepackagename.name
- set = getUtility(IBinaryPackageBuildSet).getBuildsByArchIds(
- self.distribution, self.arch_ids, name=spn)
+ set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
+ self.distribution, name=spn)
self.assertEquals(set.count(), 2)
- def test_get_by_arch_ids_filter_pocket(self):
+ def test_get_for_distro_filter_pocket(self):
# The result can be filtered based on the pocket of the build
self.setUpBuilds()
- set = getUtility(IBinaryPackageBuildSet).getBuildsByArchIds(
- self.distribution, self.arch_ids,
- pocket=PackagePublishingPocket.RELEASE)
+ set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
+ self.distribution, pocket=PackagePublishingPocket.RELEASE)
self.assertEquals(set.count(), 10)
- set = getUtility(IBinaryPackageBuildSet).getBuildsByArchIds(
- self.distribution, self.arch_ids,
- pocket=PackagePublishingPocket.UPDATES)
+ set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
+ self.distribution, pocket=PackagePublishingPocket.UPDATES)
self.assertEquals(set.count(), 0)
+ def test_get_for_distro_filter_arch_tag(self):
+ # The result can be filtered based on the archtag of the build
+ self.setUpBuilds()
+ set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
+ self.distribution, arch_tag=self.das_one.architecturetag)
+ self.assertEquals(set.count(), 5)
+
def test_get_status_summary_for_builds(self):
# We can query for the status summary of a number of builds
self.setUpBuilds()
=== modified file 'lib/lp/soyuz/tests/test_distributionsourcepackagerelease.py'
--- lib/lp/soyuz/tests/test_distributionsourcepackagerelease.py 2012-01-01 02:58:52 +0000
+++ lib/lp/soyuz/tests/test_distributionsourcepackagerelease.py 2013-02-06 10:56:24 +0000
@@ -7,10 +7,10 @@
from zope.component import getUtility
from lp.soyuz.enums import PackagePublishingStatus
-from lp.soyuz.interfaces.distroarchseries import IDistroArchSeriesSet
from lp.soyuz.model.distributionsourcepackagerelease import (
DistributionSourcePackageRelease,
)
+from lp.soyuz.model.distroarchseries import DistroArchSeries
from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
from lp.testing import (
StormStatementRecorder,
@@ -108,8 +108,7 @@
publisher = SoyuzTestPublisher()
publisher.updateDistroSeriesPackageCache(
self.distroarchseries.distroseries)
- self.distroarchseries = getUtility(IDistroArchSeriesSet).get(
- self.distroarchseries.id)
+ self.distroarchseries = DistroArchSeries.get(self.distroarchseries.id)
distribution = self.distroarchseries.distroseries.distribution
releases = distribution.getCurrentSourceReleases([sourcepackagename])
[(distribution_sourcepackage, dsp_release)] = releases.items()