launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #16196
[Merge] lp:~wgrant/launchpad/no-mSPRBJ into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/no-mSPRBJ into lp:launchpad.
Commit message:
Replace factory.makeSourcePackageRecipeBuildJob() with makeSourcePackageRecipeBuild().queueBuild().
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #598397 in Launchpad itself: "makeSourcePackageRecipeBuildJob creates an arch-agnostic BuildQueue"
https://bugs.launchpad.net/launchpad/+bug/598397
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/no-mSPRBJ/+merge/195180
Replace factory.makeSourcePackageRecipeBuildJob() with makeSourcePackageRecipeBuild().queueBuild().
--
https://code.launchpad.net/~wgrant/launchpad/no-mSPRBJ/+merge/195180
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/no-mSPRBJ into lp:launchpad.
=== modified file 'lib/lp/buildmaster/doc/builder.txt'
--- lib/lp/buildmaster/doc/builder.txt 2013-09-13 06:20:49 +0000
+++ lib/lp/buildmaster/doc/builder.txt 2013-11-14 08:02:42 +0000
@@ -143,32 +143,24 @@
All job types are included. If we create a recipe build job, it will
show up in the calculated queue size.
- >>> recipe_bq = factory.makeSourcePackageRecipeBuildJob()
- >>> # XXX wgrant 20100625 bug=598397: The factory erroneously creates
- >>> # architecture-independent jobs.
- >>> print recipe_bq.processor
- None
-
- >>> from lp.soyuz.interfaces.processor import IProcessorSet
- >>> i386_processor = getUtility(IProcessorSet).getByName('386')
- >>> recipe_bq.processor = i386_processor
- >>> recipe_bq.virtualized = True
+ >>> recipe_bq = factory.makeSourcePackageRecipeBuild(
+ ... distroseries=ubuntu.currentseries).queueBuild()
>>> transaction.commit()
-
>>> queue_sizes = builderset.getBuildQueueSizes()
>>> print queue_sizes['virt']['386']
- (1L, datetime.timedelta(0, 64))
+ (1L, datetime.timedelta(0, 600))
Any BuildQueues with a null `virtualized` property are considered virtual
by default.
- >>> recipe_bq = factory.makeSourcePackageRecipeBuildJob()
+ >>> from zope.security.proxy import removeSecurityProxy
+ >>> recipe_bq = removeSecurityProxy(factory.makeSourcePackageRecipeBuild(
+ ... distroseries=ubuntu.currentseries).queueBuild())
>>> recipe_bq.virtualized = None
- >>> recipe_bq.processor = i386_processor
>>> transaction.commit()
>>> queue_sizes = builderset.getBuildQueueSizes()
The virtual queue size has increased accordingly:
>>> print queue_sizes['virt']['386']
- (2L, datetime.timedelta(0, 128))
+ (2L, datetime.timedelta(0, 1200))
=== modified file 'lib/lp/buildmaster/tests/test_builder.py'
--- lib/lp/buildmaster/tests/test_builder.py 2013-09-04 07:35:02 +0000
+++ lib/lp/buildmaster/tests/test_builder.py 2013-11-14 08:02:42 +0000
@@ -22,6 +22,7 @@
PackagePublishingStatus,
)
from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
+from lp.soyuz.interfaces.processor import IProcessorSet
from lp.testing import TestCaseWithFactory
from lp.testing.layers import (
DatabaseFunctionalLayer,
@@ -334,7 +335,12 @@
self.assertEqual(self.gedit_build.buildqueue_record.lastscore, 2505)
self.assertEqual(self.firefox_build.buildqueue_record.lastscore, 2505)
- recipe_build_job = self.factory.makeSourcePackageRecipeBuildJob(9999)
+ das = self.factory.makeDistroArchSeries(
+ processor=getUtility(IProcessorSet).getByName('386'))
+ das.distroseries.nominatedarchindep = das
+ recipe_build_job = self.factory.makeSourcePackageRecipeBuild(
+ distroseries=das.distroseries).queueBuild()
+ recipe_build_job.manualScore(9999)
self.assertEqual(recipe_build_job.lastscore, 9999)
@@ -361,9 +367,16 @@
self.non_ppa = self.factory.makeArchive(
name="primary", purpose=ArchivePurpose.PRIMARY)
+ das = self.factory.makeDistroArchSeries(
+ processor=getUtility(IProcessorSet).getByName('386'))
+ das.distroseries.nominatedarchindep = das
self.clearBuildQueue()
- self.bq1 = self.factory.makeSourcePackageRecipeBuildJob(3333)
- self.bq2 = self.factory.makeSourcePackageRecipeBuildJob(4333)
+ self.bq1 = self.factory.makeSourcePackageRecipeBuild(
+ distroseries=das.distroseries).queueBuild()
+ self.bq1.manualScore(3333)
+ self.bq2 = self.factory.makeSourcePackageRecipeBuild(
+ distroseries=das.distroseries).queueBuild()
+ self.bq2.manualScore(4333)
def test_findBuildCandidate_with_highest_score(self):
# The recipe build with the highest score is selected first.
=== modified file 'lib/lp/buildmaster/tests/test_buildqueue.py'
--- lib/lp/buildmaster/tests/test_buildqueue.py 2013-11-12 09:07:01 +0000
+++ lib/lp/buildmaster/tests/test_buildqueue.py 2013-11-14 08:02:42 +0000
@@ -8,6 +8,7 @@
from storm.store import Store
from zope import component
from zope.component import getGlobalSiteManager
+from zope.security.proxy import removeSecurityProxy
from lp.buildmaster.enums import (
BuildFarmJobType,
@@ -109,7 +110,7 @@
self.assertCancelled(buildpackagejob.build, bq)
def test_recipebuild_cancel(self):
- bq = self.factory.makeSourcePackageRecipeBuildJob()
+ bq = self.factory.makeSourcePackageRecipeBuild().queueBuild()
build = bq.specific_build
bq.markAsBuilding(self.builder)
bq.cancel()
@@ -122,14 +123,14 @@
def _makeBuildQueue(self):
"""Produce a `BuildQueue` object to test."""
- return self.factory.makeSourcePackageRecipeBuildJob()
+ return self.factory.makeSourcePackageRecipeBuild().queueBuild()
def test_current_build_duration_not_started(self):
buildqueue = self._makeBuildQueue()
self.assertEqual(None, buildqueue.current_build_duration)
def test_current_build_duration(self):
- buildqueue = self._makeBuildQueue()
+ buildqueue = removeSecurityProxy(self._makeBuildQueue())
now = buildqueue._now()
buildqueue._now = FakeMethod(result=now)
age = timedelta(minutes=3)
@@ -272,7 +273,7 @@
def _makeBuildQueue(self):
"""Produce a `BuildQueue` object to test."""
- return self.factory.makeSourcePackageRecipeBuildJob()
+ return self.factory.makeSourcePackageRecipeBuild().queueBuild()
def test_manualScore_prevents_rescoring(self):
# Manually-set scores are fixed.
=== modified file 'lib/lp/buildmaster/tests/test_queuedepth.py'
--- lib/lp/buildmaster/tests/test_queuedepth.py 2013-11-12 09:07:01 +0000
+++ lib/lp/buildmaster/tests/test_queuedepth.py 2013-11-14 08:02:42 +0000
@@ -11,8 +11,12 @@
from zope.component import getUtility
from zope.security.proxy import removeSecurityProxy
-from lp.buildmaster.enums import BuildStatus
+from lp.buildmaster.enums import (
+ BuildFarmJobType,
+ BuildStatus,
+ )
from lp.buildmaster.interfaces.builder import IBuilderSet
+from lp.buildmaster.model.buildqueue import BuildQueue
from lp.buildmaster.queuedepth import (
estimate_job_delay,
estimate_time_to_next_builder,
@@ -223,6 +227,23 @@
getUtility(IBuilderSet)['bob'].builderok = False
getUtility(IBuilderSet)['frog'].builderok = False
+ def makeCustomBuildQueue(self, score=9876, virtualized=True,
+ estimated_duration=64, sourcename=None,
+ recipe_build=None):
+ """Create a `SourcePackageRecipeBuild` and a `BuildQueue` for
+ testing."""
+ if recipe_build is None:
+ recipe_build = self.factory.makeSourcePackageRecipeBuild(
+ sourcename=sourcename)
+ recipe_build_job = recipe_build.makeJob()
+ bq = BuildQueue(
+ job=recipe_build_job.job, lastscore=score,
+ job_type=BuildFarmJobType.RECIPEBRANCHBUILD,
+ estimated_duration=timedelta(seconds=estimated_duration),
+ virtualized=virtualized)
+ IStore(BuildQueue).add(bq)
+ return bq
+
class SingleArchBuildsBase(TestBuildQueueBase):
"""Set up a test environment with builds that target a single
@@ -500,7 +521,7 @@
check_mintime_to_builder(self, apg_job, 0)
# The following job can only run on a native builder.
- job = self.factory.makeSourcePackageRecipeBuildJob(
+ job = self.makeCustomBuildQueue(
estimated_duration=111, sourcename=u'xxr-gftp', score=1055,
virtualized=False)
self.builds.append(job.specific_build)
@@ -667,7 +688,7 @@
check_mintime_to_builder(self, apg_job, 0)
# Let's add a processor-independent job to the mix.
- job = self.factory.makeSourcePackageRecipeBuildJob(
+ job = self.makeCustomBuildQueue(
virtualized=False, estimated_duration=22,
sourcename='my-recipe-digikam', score=9999)
# There are still builders available for the processor-independent
@@ -753,11 +774,11 @@
"""
super(TestMultiArchJobDelayEstimation, self).setUp()
- job = self.factory.makeSourcePackageRecipeBuildJob(
+ job = self.makeCustomBuildQueue(
virtualized=False, estimated_duration=22,
sourcename=u'xx-recipe-bash', score=1025)
self.builds.append(job.specific_build)
- job = self.factory.makeSourcePackageRecipeBuildJob(
+ job = self.makeCustomBuildQueue(
virtualized=False, estimated_duration=222,
sourcename=u'xx-recipe-zsh', score=1053)
self.builds.append(job.specific_build)
@@ -853,7 +874,7 @@
bq = build.buildqueue_record
if bq.processor == self.hppa_proc:
removeSecurityProxy(bq).virtualized = True
- job = self.factory.makeSourcePackageRecipeBuildJob(
+ job = self.makeCustomBuildQueue(
virtualized=True, estimated_duration=332,
sourcename=u'xxr-openssh-client', score=1050)
self.builds.append(job.specific_build)
@@ -875,7 +896,7 @@
# Now add a job with a NULL 'virtualized' flag. It should be treated
# like jobs with virtualized=TRUE.
- job = self.factory.makeSourcePackageRecipeBuildJob(
+ job = self.makeCustomBuildQueue(
estimated_duration=111, sourcename=u'xxr-gwibber', score=1051,
virtualized=None)
self.builds.append(job.specific_build)
@@ -945,33 +966,33 @@
"""
super(TestJobDispatchTimeEstimation, self).setUp()
- job = self.factory.makeSourcePackageRecipeBuildJob(
+ job = self.makeCustomBuildQueue(
virtualized=False, estimated_duration=332,
sourcename=u'xxr-aptitude', score=1025)
self.builds.append(job.specific_build)
- job = self.factory.makeSourcePackageRecipeBuildJob(
+ job = self.makeCustomBuildQueue(
virtualized=False, estimated_duration=443,
sourcename=u'xxr-auto-apt', score=1053)
self.builds.append(job.specific_build)
- job = self.factory.makeSourcePackageRecipeBuildJob(
+ job = self.makeCustomBuildQueue(
estimated_duration=554, sourcename=u'xxr-daptup', score=1051,
virtualized=None)
self.builds.append(job.specific_build)
- job = self.factory.makeSourcePackageRecipeBuildJob(
+ job = self.makeCustomBuildQueue(
estimated_duration=665, sourcename=u'xxr-cron-apt', score=1043)
self.builds.append(job.specific_build)
- job = self.factory.makeSourcePackageRecipeBuildJob(
+ job = self.makeCustomBuildQueue(
estimated_duration=776, sourcename=u'xxr-apt-build', score=1043)
self.builds.append(job.specific_build)
- job = self.factory.makeSourcePackageRecipeBuildJob(
+ job = self.makeCustomBuildQueue(
estimated_duration=887, sourcename=u'xxr-debdelta', score=1044,
virtualized=None)
self.builds.append(job.specific_build)
- job = self.factory.makeSourcePackageRecipeBuildJob(
+ job = self.makeCustomBuildQueue(
estimated_duration=998, sourcename=u'xxr-apt', score=1044,
virtualized=None)
self.builds.append(job.specific_build)
- job = self.factory.makeSourcePackageRecipeBuildJob(
+ job = self.makeCustomBuildQueue(
estimated_duration=1110, sourcename=u'xxr-cupt', score=1044,
virtualized=None)
self.builds.append(job.specific_build)
=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2013-11-11 11:26:02 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2013-11-14 08:02:42 +0000
@@ -1211,7 +1211,7 @@
build = self.factory.makeSourcePackageRecipeBuild(
recipe=recipe, distroseries=self.squirrel, archive=self.ppa,
date_created=date_created)
- self.factory.makeSourcePackageRecipeBuildJob(recipe_build=build)
+ build.queueBuild()
return build
def test_index_pending(self):
@@ -1615,11 +1615,13 @@
distro_series = self.factory.makeDistroSeries(
name='squirrel', distribution=archive.distribution)
removeSecurityProxy(distro_series).nominatedarchindep = (
- self.factory.makeDistroArchSeries(distroseries=distro_series))
+ self.factory.makeDistroArchSeries(
+ distroseries=distro_series,
+ processor=getUtility(IProcessorSet).getByName('386')))
build = self.factory.makeSourcePackageRecipeBuild(
requester=self.user, archive=archive, recipe=recipe,
distroseries=distro_series)
- self.factory.makeSourcePackageRecipeBuildJob(recipe_build=build)
+ build.queueBuild()
self.factory.makeBuilder()
return build
@@ -1650,10 +1652,10 @@
build = self.factory.makeSourcePackageRecipeBuild()
view = SourcePackageRecipeBuildView(build, None)
self.assertIs(None, view.eta)
- queue_entry = self.factory.makeSourcePackageRecipeBuildJob(
- recipe_build=build)
+ queue_entry = removeSecurityProxy(build.queueBuild())
queue_entry._now = lambda: datetime(1970, 1, 1, 0, 0, 0, 0, UTC)
- self.factory.makeBuilder()
+ self.factory.makeBuilder(
+ processor=queue_entry.processor, virtualized=True)
clear_property_cache(view)
self.assertIsNot(None, view.eta)
self.assertEqual(
@@ -1679,7 +1681,7 @@
created .*
Build status
Needs building
- Start in .* \\(9876\\) What's this?.*
+ Start in .* \\(2505\\) What's this?.*
Estimated finish in .*
Build details
Recipe: Recipe my-recipe for Owner
=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py 2013-11-12 09:07:01 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py 2013-11-14 08:02:42 +0000
@@ -88,7 +88,7 @@
def test_cancel_build(self):
"""An admin can cancel a build."""
- queue = self.factory.makeSourcePackageRecipeBuildJob()
+ queue = self.factory.makeSourcePackageRecipeBuild().queueBuild()
build = queue.specific_build
transaction.commit()
build_url = canonical_url(build)
@@ -114,7 +114,7 @@
def test_cancel_build_not_admin(self):
"""No one but an admin can cancel a build."""
- queue = self.factory.makeSourcePackageRecipeBuildJob()
+ queue = self.factory.makeSourcePackageRecipeBuild().queueBuild()
build = queue.specific_build
transaction.commit()
build_url = canonical_url(build)
@@ -144,7 +144,7 @@
def test_rescore_build(self):
"""An admin can rescore a build."""
- queue = self.factory.makeSourcePackageRecipeBuildJob()
+ queue = self.factory.makeSourcePackageRecipeBuild().queueBuild()
build = queue.specific_build
transaction.commit()
build_url = canonical_url(build)
@@ -172,7 +172,7 @@
def test_rescore_build_invalid_score(self):
"""Build scores can only take numbers."""
- queue = self.factory.makeSourcePackageRecipeBuildJob()
+ queue = self.factory.makeSourcePackageRecipeBuild().queueBuild()
build = queue.specific_build
transaction.commit()
build_url = canonical_url(build)
@@ -195,7 +195,7 @@
def test_rescore_build_not_admin(self):
"""No one but admin can rescore a build."""
- queue = self.factory.makeSourcePackageRecipeBuildJob()
+ queue = self.factory.makeSourcePackageRecipeBuild().queueBuild()
build = queue.specific_build
transaction.commit()
build_url = canonical_url(build)
=== modified file 'lib/lp/code/model/tests/test_recipebuilder.py'
--- lib/lp/code/model/tests/test_recipebuilder.py 2013-11-12 09:07:01 +0000
+++ lib/lp/code/model/tests/test_recipebuilder.py 2013-11-14 08:02:42 +0000
@@ -341,7 +341,8 @@
self.factory = LaunchpadObjectFactory()
def prepareBehavior(self, fake_successful_upload=False):
- self.queue_record = self.factory.makeSourcePackageRecipeBuildJob()
+ self.queue_record = (
+ self.factory.makeSourcePackageRecipeBuild().queueBuild())
build = self.queue_record.specific_build
build.updateStatus(BuildStatus.FULLYBUILT)
if fake_successful_upload:
=== modified file 'lib/lp/code/model/tests/test_sourcepackagerecipe.py'
--- lib/lp/code/model/tests/test_sourcepackagerecipe.py 2013-11-12 07:39:51 +0000
+++ lib/lp/code/model/tests/test_sourcepackagerecipe.py 2013-11-14 08:02:42 +0000
@@ -556,12 +556,10 @@
recipe = self.factory.makeSourcePackageRecipe(branches=branches)
pending_build = self.factory.makeSourcePackageRecipeBuild(
recipe=recipe)
- self.factory.makeSourcePackageRecipeBuildJob(
- recipe_build=pending_build)
+ pending_build.queueBuild()
past_build = self.factory.makeSourcePackageRecipeBuild(
recipe=recipe)
- self.factory.makeSourcePackageRecipeBuildJob(
- recipe_build=past_build)
+ past_build.queueBuild()
removeSecurityProxy(past_build).datebuilt = datetime.now(UTC)
with person_logged_in(recipe.owner):
recipe.destroySelf()
=== modified file 'lib/lp/soyuz/browser/tests/test_builder.py'
--- lib/lp/soyuz/browser/tests/test_builder.py 2013-09-02 08:11:58 +0000
+++ lib/lp/soyuz/browser/tests/test_builder.py 2013-11-14 08:02:42 +0000
@@ -42,7 +42,7 @@
# And create BuildFarmJobs of the various types to throw IDs off
# even further, detecting more preloading issues.
self.factory.makeBinaryPackageBuild().queueBuild()
- self.factory.makeSourcePackageRecipeBuildJob()
+ self.factory.makeSourcePackageRecipeBuild().queueBuild()
self.factory.makeTranslationTemplatesBuildJob()
def test_builders_binary_package_build_query_count(self):
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2013-10-24 06:20:06 +0000
+++ lib/lp/testing/factory.py 2013-11-14 08:02:42 +0000
@@ -101,7 +101,6 @@
BuildStatus,
)
from lp.buildmaster.interfaces.builder import IBuilderSet
-from lp.buildmaster.model.buildqueue import BuildQueue
from lp.code.enums import (
BranchMergeProposalStatus,
BranchSubscriptionNotificationLevel,
@@ -2867,24 +2866,6 @@
IStore(spr_build).flush()
return spr_build
- def makeSourcePackageRecipeBuildJob(
- self, score=9876, virtualized=True, estimated_duration=64,
- sourcename=None, recipe_build=None):
- """Create a `SourcePackageRecipeBuildJob` and a `BuildQueue` for
- testing."""
- if recipe_build is None:
- recipe_build = self.makeSourcePackageRecipeBuild(
- sourcename=sourcename)
- recipe_build_job = recipe_build.makeJob()
-
- bq = BuildQueue(
- job=recipe_build_job.job, lastscore=score,
- job_type=BuildFarmJobType.RECIPEBRANCHBUILD,
- estimated_duration=timedelta(seconds=estimated_duration),
- virtualized=virtualized)
- IStore(BuildQueue).add(bq)
- return bq
-
def makeTranslationTemplatesBuildJob(self, branch=None):
"""Make a new `TranslationTemplatesBuildJob`.
Follow ups