launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #15860
[Merge] lp:~wgrant/launchpad/cleanup-bfjo into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/cleanup-bfjo into lp:launchpad.
Commit message:
Delete, move, etc. lots of bits of BuildFarmJobOld, BuildQueueSet, etc.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/cleanup-bfjo/+merge/183396
Delete, move, etc. lots of bits of BuildFarmJobOld, BuildQueueSet, etc.
This is a flag day for slave cookies; all currently executing build farm jobs will be aborted when buildd-manager starts up with the new code.
--
https://code.launchpad.net/~wgrant/launchpad/cleanup-bfjo/+merge/183396
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/cleanup-bfjo into lp:launchpad.
=== modified file 'lib/lp/buildmaster/doc/buildqueue.txt'
--- lib/lp/buildmaster/doc/buildqueue.txt 2013-08-27 11:35:09 +0000
+++ lib/lp/buildmaster/doc/buildqueue.txt 2013-09-02 08:37:02 +0000
@@ -80,11 +80,6 @@
>>> bq.manual
False
-BuildQueue provides the name for the logfile resulting from the build:
-
- >>> bq.getLogFileName()
- u'buildlog_ubuntu-hoary-i386.mozilla-firefox_0.9_BUILDING.txt'
-
BuildQueue provides a method to handle "manual scoring" procedure
properly, in order to retain the manually set score we need to
set 'manual' attribute atomically. For this we use manualScore:
@@ -168,34 +163,11 @@
>>> verifyObject(IBuildQueueSet, bqset)
True
-IBuildQueueSet utility is iterable:
-
- >>> for bq in bqset:
- ... bq.id
- 1
- 2
-
-Also provides a getter:
-
- >>> bqset[1].id
- 1
-
-a 'get' method:
+IBuildQueueSet utility provides a 'get' method:
>>> bqset.get(2).id
2
-and a full counter:
-
- >>> bqset.count()
- 2
-
-IBuildQueueSet provides a method to retrieve the active job:
-
- >>> for bq in bqset.getActiveBuildJobs():
- ... bq.id, bq.builder.name
- (1, u'bob')
-
Another method to fetch the BuildQueue being processed for a builder,
there should be only one since the builders are sigle-task
applications:
=== modified file 'lib/lp/buildmaster/interactor.py'
--- lib/lp/buildmaster/interactor.py 2013-09-02 01:51:25 +0000
+++ lib/lp/buildmaster/interactor.py 2013-09-02 08:37:02 +0000
@@ -319,7 +319,7 @@
"""See `IBuildFarmJobBehavior`."""
if self._current_build_behavior is None:
raise CorruptBuildCookie('No job assigned to builder')
- good_cookie = self._current_build_behavior.generateSlaveBuildCookie()
+ good_cookie = self._current_build_behavior.getBuildCookie()
if slave_build_cookie != good_cookie:
raise CorruptBuildCookie("Invalid slave build cookie.")
@@ -608,20 +608,7 @@
status_sentence, status_dict = statuses
builder_status = status_dict['builder_status']
if builder_status not in builder_status_handlers:
- logger.critical(
- "Builder on %s returned unknown status %s, failing it"
- % (self.builder.url, builder_status))
- self.builder.failBuilder(
- "Unknown status code (%s) returned from status() probe."
- % builder_status)
- # XXX: This will leave the build and job in a bad state, but
- # should never be possible, since our builder statuses are
- # known.
- queueItem._builder = None
- queueItem.setDateStarted(None)
- transaction.commit()
- return
-
+ raise AssertionError("Unknown status %s" % builder_status)
method = builder_status_handlers[builder_status]
return defer.maybeDeferred(
method, queueItem, status_sentence, status_dict, logger)
=== modified file 'lib/lp/buildmaster/interfaces/builder.py'
--- lib/lp/buildmaster/interfaces/builder.py 2013-08-26 07:37:00 +0000
+++ lib/lp/buildmaster/interfaces/builder.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Builder interfaces."""
@@ -38,7 +38,6 @@
)
from zope.schema import (
Bool,
- Field,
Int,
Text,
TextLine,
@@ -178,15 +177,6 @@
def failBuilder(reason):
"""Mark builder as failed for a given reason."""
- def getBuildQueue():
- """Return a `BuildQueue` if there's an active job on this builder.
-
- :return: A BuildQueue, or None.
- """
-
- def getCurrentBuildFarmJob():
- """Return a `BuildFarmJob` for this builder."""
-
def acquireBuildCandidate():
"""Acquire a build candidate in an atomic fashion.
=== modified file 'lib/lp/buildmaster/interfaces/buildfarmjob.py'
--- lib/lp/buildmaster/interfaces/buildfarmjob.py 2013-08-29 03:01:24 +0000
+++ lib/lp/buildmaster/interfaces/buildfarmjob.py 2013-09-02 08:37:02 +0000
@@ -75,15 +75,6 @@
def score():
"""Calculate a job score appropriate for the job type in question."""
- def getLogFileName():
- """The preferred file name for this job's log."""
-
- def getName():
- """An appropriate name for this job."""
-
- def getTitle():
- """A string to identify and describe the job to users."""
-
def jobStarted():
"""'Job started' life cycle event, handle as appropriate."""
@@ -146,13 +137,6 @@
has entries associated with `job`s.
"""
- def generateSlaveBuildCookie():
- """Produce a cookie for the slave as a token of the job it's doing.
-
- The cookie should uniquely represent the current dispatch of this
- build.
- """
-
def cleanUp():
"""Job's finished. Delete its supporting data."""
=== modified file 'lib/lp/buildmaster/interfaces/buildfarmjobbehavior.py'
--- lib/lp/buildmaster/interfaces/buildfarmjobbehavior.py 2013-09-02 01:51:25 +0000
+++ lib/lp/buildmaster/interfaces/buildfarmjobbehavior.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Interface for build farm job behaviors."""
@@ -38,12 +38,8 @@
:param logger: A logger to be used to log diagnostic information.
"""
- def generateSlaveBuildCookie():
- """Produce a cookie for the slave as a token of the job it's doing.
-
- The cookie should uniquely represent the current dispatch of the
- current build.
- """
+ def getBuildCookie():
+ """Return a string which uniquely identifies the job."""
def updateSlaveStatus(status_sentence, status_dict):
"""Update the slave status dict with custom values for this behavior.
=== modified file 'lib/lp/buildmaster/interfaces/buildqueue.py'
--- lib/lp/buildmaster/interfaces/buildqueue.py 2013-08-27 11:35:09 +0000
+++ lib/lp/buildmaster/interfaces/buildqueue.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Build interfaces."""
@@ -88,9 +88,6 @@
def destroySelf():
"""Delete this entry from the database."""
- def getLogFileName():
- """Get the preferred filename for the buildlog of this build."""
-
def markAsBuilding(builder):
"""Set this queue item to a 'building' state."""
@@ -104,9 +101,6 @@
IBuildFarmJob, title=_("Job"),
description=_("Data and operations common to all build farm jobs."))
- def setDateStarted(timestamp):
- """Sets the date started property to the given value."""
-
date_started = Datetime(
title=_('Start time'),
description=_('Time when the job started.'))
@@ -124,33 +118,12 @@
class IBuildQueueSet(Interface):
"""Launchpad Auto Build queue set handler and auxiliary methods."""
- title = Attribute('Title')
-
- def __iter__():
- """Iterate over current build jobs."""
-
- def __getitem__(buildqueue_id):
- """Retrieve a build job by id."""
-
- def count():
- """Return the number of build jobs in the queue."""
-
def get(buildqueue_id):
"""Return the `IBuildQueue` with the given id."""
- def getByJob(job):
- """Find the `IBuildQueue` to which `job` belongs.
-
- :param job: A `Job`.
- :return: The matching `IBuildQueue`, or None.
- """
-
def getByBuilder(builder):
"""Return an IBuildQueue instance for a builder.
Retrieve the only one possible entry being processed for a given
builder. If not found, return None.
"""
-
- def getActiveBuildJobs():
- """Return All active Build Jobs."""
=== modified file 'lib/lp/buildmaster/manager.py'
--- lib/lp/buildmaster/manager.py 2013-08-31 16:17:48 +0000
+++ lib/lp/buildmaster/manager.py 2013-09-02 08:37:02 +0000
@@ -212,7 +212,7 @@
by resuming a slave host, so that there is no need to update its
status.
"""
- buildqueue = self.builder.getBuildQueue()
+ buildqueue = self.builder.currentjob
if not buildqueue:
self.date_cancel = None
defer.returnValue(False)
@@ -284,7 +284,7 @@
transaction.commit()
# See if we think there's an active build on the builder.
- buildqueue = self.builder.getBuildQueue()
+ buildqueue = self.builder.currentjob
# Scan the slave and get the logtail, or collect the build if
# it's ready. Yes, "updateBuild" is a bad name.
=== modified file 'lib/lp/buildmaster/model/builder.py'
--- lib/lp/buildmaster/model/builder.py 2013-08-31 10:20:49 +0000
+++ lib/lp/buildmaster/model/builder.py 2013-09-02 08:37:02 +0000
@@ -231,7 +231,7 @@
"""See IBuilder."""
self.gotFailure()
if self.currentjob is not None:
- build_farm_job = self.getCurrentBuildFarmJob()
+ build_farm_job = self.currentjob.specific_job.build
build_farm_job.gotFailure()
logger.info(
"Builder %s failure count: %s, job '%s' failure count: %s" % (
@@ -242,22 +242,6 @@
"Builder %s failure count: %s" % (
self.name, self.failure_count))
- def getBuildQueue(self):
- """See `IBuilder`."""
- # Return a single BuildQueue for the builder provided it's
- # currently running a job.
- return IStore(BuildQueue).find(
- BuildQueue,
- BuildQueue.job == Job.id,
- BuildQueue.builder == self.id,
- Job._status == JobStatus.RUNNING,
- Job.date_started != None).one()
-
- def getCurrentBuildFarmJob(self):
- """See `IBuilder`."""
- # Don't make this a property, it's masking a few queries.
- return self.currentjob.specific_job.build
-
class BuilderSet(object):
"""See IBuilderSet"""
=== modified file 'lib/lp/buildmaster/model/buildfarmjob.py'
--- lib/lp/buildmaster/model/buildfarmjob.py 2013-06-20 05:50:00 +0000
+++ lib/lp/buildmaster/model/buildfarmjob.py 2013-09-02 08:37:02 +0000
@@ -9,7 +9,6 @@
]
import datetime
-import hashlib
import pytz
from storm.expr import (
@@ -24,12 +23,10 @@
Storm,
)
from storm.store import Store
-from zope.component import getUtility
from zope.interface import (
classProvides,
implements,
)
-from zope.security.proxy import removeSecurityProxy
from lp.buildmaster.enums import (
BuildFarmJobType,
@@ -41,7 +38,6 @@
IBuildFarmJobSet,
IBuildFarmJobSource,
)
-from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet
from lp.services.database.enumcol import DBEnum
from lp.services.database.interfaces import (
IMasterStore,
@@ -79,38 +75,6 @@
"""See `IBuildFarmJobOld`."""
raise NotImplementedError
- def getLogFileName(self):
- """See `IBuildFarmJobOld`."""
- return 'buildlog.txt'
-
- def getName(self):
- """See `IBuildFarmJobOld`."""
- raise NotImplementedError
-
- def getTitle(self):
- """See `IBuildFarmJob`."""
- return self.build.title
-
- def generateSlaveBuildCookie(self):
- """See `IBuildFarmJobOld`."""
- buildqueue = getUtility(IBuildQueueSet).getByJob(self.job)
-
- if buildqueue.processor is None:
- processor = '*'
- else:
- processor = repr(buildqueue.processor.id)
-
- contents = ';'.join([
- repr(removeSecurityProxy(self.job).id),
- self.job.date_created.isoformat(),
- repr(buildqueue.id),
- buildqueue.job_type.name,
- processor,
- self.getName(),
- ])
-
- return hashlib.sha1(contents).hexdigest()
-
def cleanUp(self):
"""See `IBuildFarmJob`.
=== modified file 'lib/lp/buildmaster/model/buildfarmjobbehavior.py'
--- lib/lp/buildmaster/model/buildfarmjobbehavior.py 2013-09-02 01:51:25 +0000
+++ lib/lp/buildmaster/model/buildfarmjobbehavior.py 2013-09-02 08:37:02 +0000
@@ -64,9 +64,6 @@
The default behavior is that we don't add any extra values."""
pass
- def generateSlaveBuildCookie(self):
- return self.buildfarmjob.generateSlaveBuildCookie()
-
def getBuildCookie(self):
"""See `IPackageBuild`."""
return '%s-%s' % (self.build.job_type.name, self.build.id)
@@ -126,11 +123,14 @@
d.addCallback(got_file, filename, out_file, out_file_name)
return d
+ def getLogFileName(self):
+ """Return the preferred file name for this job's log."""
+ return 'buildlog.txt'
+
def getLogFromSlave(self, queue_item):
- """See `IPackageBuild`."""
+ """Return a Deferred which fires when the log is in the librarian."""
d = self.transferSlaveFileToLibrarian(
- SLAVE_LOG_FILENAME, queue_item.getLogFileName(),
- self.build.is_private)
+ SLAVE_LOG_FILENAME, self.getLogFileName(), self.build.is_private)
return d
@defer.inlineCallbacks
=== modified file 'lib/lp/buildmaster/model/buildqueue.py'
--- lib/lp/buildmaster/model/buildqueue.py 2013-08-27 11:35:09 +0000
+++ lib/lp/buildmaster/model/buildqueue.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -15,7 +15,6 @@
timedelta,
)
from itertools import groupby
-import logging
from operator import attrgetter
import pytz
@@ -24,13 +23,11 @@
ForeignKey,
IntCol,
IntervalCol,
- SQLObjectNotFound,
StringCol,
)
from zope.component import getSiteManager
from zope.interface import implements
-from lp.app.errors import NotFoundError
from lp.buildmaster.enums import BuildFarmJobType
from lp.buildmaster.interfaces.buildfarmjob import IBuildFarmJob
from lp.buildmaster.interfaces.buildqueue import (
@@ -189,25 +186,12 @@
def score(self):
"""See `IBuildQueue`."""
- # Grab any logger instance available.
- logger = logging.getLogger()
- name = self.specific_job.getName()
-
if self.manual:
- logger.debug(
- "%s (%d) MANUALLY RESCORED" % (name, self.lastscore))
return
-
# Allow the `IBuildFarmJob` instance with the data/logic specific to
# the job at hand to calculate the score as appropriate.
self.lastscore = self.specific_job.score()
- def getLogFileName(self):
- """See `IBuildQueue`."""
- # Allow the `IBuildFarmJob` instance with the data/logic specific to
- # the job at hand to calculate the log file name as appropriate.
- return self.specific_job.getLogFileName()
-
def markAsBuilding(self, builder):
"""See `IBuildQueue`."""
self.builder = builder
@@ -235,10 +219,6 @@
self.specific_job.jobCancel()
self.destroySelf()
- def setDateStarted(self, timestamp):
- """See `IBuildQueue`."""
- self.job.date_started = timestamp
-
def _getFreeBuildersCount(self, processor, virtualized):
"""How many builders capable of running jobs for the given processor
and virtualization combination are idle/free at present?"""
@@ -534,44 +514,10 @@
"""Utility to deal with BuildQueue content class."""
implements(IBuildQueueSet)
- def __init__(self):
- self.title = "The Launchpad build queue"
-
- def __iter__(self):
- """See `IBuildQueueSet`."""
- return iter(BuildQueue.select())
-
- def __getitem__(self, buildqueue_id):
- """See `IBuildQueueSet`."""
- try:
- return BuildQueue.get(buildqueue_id)
- except SQLObjectNotFound:
- raise NotFoundError(buildqueue_id)
-
def get(self, buildqueue_id):
"""See `IBuildQueueSet`."""
return BuildQueue.get(buildqueue_id)
- def getByJob(self, job):
- """See `IBuildQueueSet`."""
- return IStore(BuildQueue).find(BuildQueue, BuildQueue.job == job).one()
-
- def count(self):
- """See `IBuildQueueSet`."""
- return BuildQueue.select().count()
-
def getByBuilder(self, builder):
"""See `IBuildQueueSet`."""
return BuildQueue.selectOneBy(builder=builder)
-
- def getActiveBuildJobs(self):
- """See `IBuildQueueSet`."""
- return IStore(BuildQueue).find(
- BuildQueue,
- BuildQueue.job == Job.id,
- # XXX Michael Nelson 2010-02-22 bug=499421
- # Avoid corrupt build jobs where the builder is None.
- BuildQueue.builder != None,
- # status is a property. Let's use _status.
- Job._status == JobStatus.RUNNING,
- Job.date_started != None)
=== modified file 'lib/lp/buildmaster/tests/mock_slaves.py'
--- lib/lp/buildmaster/tests/mock_slaves.py 2013-08-29 12:09:40 +0000
+++ lib/lp/buildmaster/tests/mock_slaves.py 2013-09-02 08:37:02 +0000
@@ -240,7 +240,7 @@
class TrivialBehavior:
- def generateSlaveBuildCookie(self):
+ def getBuildCookie(self):
return 'trivial'
=== modified file 'lib/lp/buildmaster/tests/test_builder.py'
--- lib/lp/buildmaster/tests/test_builder.py 2013-08-30 05:37:38 +0000
+++ lib/lp/buildmaster/tests/test_builder.py 2013-09-02 08:37:02 +0000
@@ -11,7 +11,6 @@
IBuilder,
IBuilderSet,
)
-from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet
from lp.buildmaster.model.buildqueue import BuildQueue
from lp.buildmaster.tests.mock_slaves import make_publisher
from lp.services.database.interfaces import IStore
@@ -47,26 +46,6 @@
flush_database_updates()
self.assertEqual(0, builder.failure_count)
- def test_getCurrentBuildFarmJob(self):
- bq = self.factory.makeSourcePackageRecipeBuildJob(3333)
- builder = self.factory.makeBuilder()
- bq.markAsBuilding(builder)
- self.assertEqual(
- bq, builder.getCurrentBuildFarmJob().buildqueue_record)
-
- def test_getBuildQueue(self):
- buildqueueset = getUtility(IBuildQueueSet)
- active_jobs = buildqueueset.getActiveBuildJobs()
- [active_job] = active_jobs
- builder = active_job.builder
-
- bq = builder.getBuildQueue()
- self.assertEqual(active_job, bq)
-
- active_job.builder = None
- bq = builder.getBuildQueue()
- self.assertIs(None, bq)
-
def test_setting_builderok_resets_failure_count(self):
builder = removeSecurityProxy(self.factory.makeBuilder())
builder.failure_count = 1
=== modified file 'lib/lp/buildmaster/tests/test_buildfarmjobbehavior.py'
--- lib/lp/buildmaster/tests/test_buildfarmjobbehavior.py 2013-09-02 01:51:25 +0000
+++ lib/lp/buildmaster/tests/test_buildfarmjobbehavior.py 2013-09-02 08:37:02 +0000
@@ -24,7 +24,6 @@
from lp.buildmaster.tests.mock_slaves import WaitingSlave
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.services.config import config
-from lp.services.database.constants import UTC_NOW
from lp.soyuz.interfaces.processor import IProcessorFamilySet
from lp.testing import TestCaseWithFactory
from lp.testing.factory import LaunchpadObjectFactory
@@ -69,51 +68,13 @@
return spr.createBuild(
distroarchseries=distroarchseries, pocket=pocket, archive=archive)
- def _makeBuildQueue(self):
- """Create a `BuildQueue` object."""
- return self.factory.makeSourcePackageRecipeBuildJob()
-
- def _changeBuildFarmJobName(self, buildfarmjob):
- """Manipulate `buildfarmjob` so that its `getName` changes."""
- name = buildfarmjob.getName() + 'x'
- removeSecurityProxy(buildfarmjob).getName = FakeMethod(result=name)
-
- def test_cookie_baseline(self):
- buildfarmjob = self.factory.makeTranslationTemplatesBuildJob()
-
- cookie = buildfarmjob.generateSlaveBuildCookie()
-
- self.assertNotEqual(None, cookie)
- self.assertNotEqual(0, len(cookie))
- self.assertTrue(len(cookie) > 10)
-
- self.assertEqual(cookie, buildfarmjob.generateSlaveBuildCookie())
-
- def test_cookie_includes_job_name(self):
- # The cookie is a hash that includes the job's name.
- buildfarmjob = self.factory.makeTranslationTemplatesBuildJob()
- cookie = buildfarmjob.generateSlaveBuildCookie()
- self._changeBuildFarmJobName(removeSecurityProxy(buildfarmjob))
-
- self.assertNotEqual(cookie, buildfarmjob.generateSlaveBuildCookie())
- self.assertNotIn(buildfarmjob.getName(), cookie)
-
- def test_cookie_includes_more_than_name(self):
- # Two build jobs with the same name still get different cookies.
- buildfarmjob1 = self.factory.makeTranslationTemplatesBuildJob()
- buildfarmjob1 = removeSecurityProxy(buildfarmjob1)
- buildfarmjob2 = self.factory.makeTranslationTemplatesBuildJob(
- branch=buildfarmjob1.branch)
- buildfarmjob2 = removeSecurityProxy(buildfarmjob2)
-
- name_factory = FakeMethod(result="same-name")
- buildfarmjob1.getName = name_factory
- buildfarmjob2.getName = name_factory
-
- self.assertEqual(buildfarmjob1.getName(), buildfarmjob2.getName())
- self.assertNotEqual(
- buildfarmjob1.generateSlaveBuildCookie(),
- buildfarmjob2.generateSlaveBuildCookie())
+ def test_getBuildCookie(self):
+ buildfarmjob = self.factory.makeTranslationTemplatesBuildJob()
+ build = buildfarmjob.build
+ behavior = self._makeBehavior(buildfarmjob)
+ self.assertEqual(
+ '%s-%s' % (build.job_type.name, build.id),
+ behavior.getBuildCookie())
def test_getUploadDirLeaf(self):
# getUploadDirLeaf returns the current time, followed by the build
@@ -171,8 +132,7 @@
# For the moment, we require a builder for the build so that
# handleStatus_OK can get a reference to the slave.
self.builder = self.factory.makeBuilder()
- self.build.buildqueue_record.builder = self.builder
- self.build.buildqueue_record.setDateStarted(UTC_NOW)
+ self.build.buildqueue_record.markAsBuilding(self.builder)
self.slave = WaitingSlave('BuildStatus.OK')
self.slave.valid_file_hashes.append('test_file_hash')
self.interactor = BuilderInteractor(self.builder, self.slave)
=== modified file 'lib/lp/buildmaster/tests/test_buildqueue.py'
--- lib/lp/buildmaster/tests/test_buildqueue.py 2013-06-20 05:50:00 +0000
+++ lib/lp/buildmaster/tests/test_buildqueue.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Test BuildQueue features."""
@@ -15,7 +15,6 @@
getGlobalSiteManager,
getUtility,
)
-from zope.interface.verify import verifyObject
from zope.security.proxy import removeSecurityProxy
from lp.buildmaster.enums import (
@@ -24,7 +23,6 @@
)
from lp.buildmaster.interfaces.builder import IBuilderSet
from lp.buildmaster.interfaces.buildfarmjob import IBuildFarmJob
-from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet
from lp.buildmaster.model.builder import specific_job_classes
from lp.buildmaster.model.buildfarmjob import BuildFarmJobMixin
from lp.buildmaster.model.buildqueue import (
@@ -32,7 +30,6 @@
get_builder_data,
)
from lp.services.database.interfaces import IStore
-from lp.services.job.model.job import Job
from lp.soyuz.enums import (
ArchivePurpose,
PackagePublishingStatus,
@@ -132,7 +129,7 @@
def set_remaining_time_for_running_job(bq, remainder):
"""Set remaining running time for job."""
offset = bq.estimated_duration.seconds - remainder
- bq.setDateStarted(
+ removeSecurityProxy(bq.job).date_started = (
datetime.now(utc) - timedelta(seconds=offset))
@@ -200,40 +197,6 @@
builder.builderok = False
-class TestBuildQueueSet(TestCaseWithFactory):
- """Test for `BuildQueueSet`."""
-
- layer = LaunchpadZopelessLayer
-
- def setUp(self):
- super(TestBuildQueueSet, self).setUp()
- self.buildqueueset = getUtility(IBuildQueueSet)
-
- def test_baseline(self):
- verifyObject(IBuildQueueSet, self.buildqueueset)
-
- def test_getByJob_none(self):
- job = Job()
- self.assertEquals(None, self.buildqueueset.getByJob(job))
-
- def test_getByJob(self):
- job = Job()
- buildqueue = BuildQueue(job=job.id)
- self.assertEquals(buildqueue, self.buildqueueset.getByJob(job))
-
- def test_getActiveBuildJobs_no_builder_bug499421(self):
- # An active build queue item that does not have a builder will
- # not be included in the results and so will not block the
- # buildd-manager.
- active_jobs = self.buildqueueset.getActiveBuildJobs()
- self.assertEqual(1, active_jobs.count())
- active_job = active_jobs[0]
- active_job.builder = None
- self.assertTrue(
- self.buildqueueset.getActiveBuildJobs().is_empty(),
- "An active build job must have a builder.")
-
-
class TestBuildQueueBase(TestCaseWithFactory):
"""Setup the test publisher and some builders."""
=== modified file 'lib/lp/buildmaster/tests/test_manager.py'
--- lib/lp/buildmaster/tests/test_manager.py 2013-08-31 16:17:48 +0000
+++ lib/lp/buildmaster/tests/test_manager.py 2013-09-02 08:37:02 +0000
@@ -30,6 +30,9 @@
BuilderSlave,
)
from lp.buildmaster.interfaces.builder import IBuilderSet
+from lp.buildmaster.interfaces.buildfarmjobbehavior import (
+ IBuildFarmJobBehavior,
+ )
from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet
from lp.buildmaster.manager import (
assessFailureCounts,
@@ -407,7 +410,8 @@
transaction.commit()
login(ANONYMOUS)
buildqueue = builder.currentjob
- slave.build_id = buildqueue.specific_job.generateSlaveBuildCookie()
+ behavior = IBuildFarmJobBehavior(buildqueue.specific_job)
+ slave.build_id = behavior.getBuildCookie()
self.assertBuildingJob(buildqueue, builder)
# Now set the build to CANCELLING.
@@ -574,7 +578,7 @@
@defer.inlineCallbacks
def test_equal_failures_reset_job(self):
self.builder.gotFailure()
- self.builder.getCurrentBuildFarmJob().gotFailure()
+ self.build.gotFailure()
yield self._assessFailureCounts("failnotes")
self.assertIs(None, self.builder.currentjob)
@@ -582,8 +586,8 @@
@defer.inlineCallbacks
def test_job_failing_more_than_builder_fails_job(self):
- self.builder.getCurrentBuildFarmJob().gotFailure()
- self.builder.getCurrentBuildFarmJob().gotFailure()
+ self.build.gotFailure()
+ self.build.gotFailure()
self.builder.gotFailure()
yield self._assessFailureCounts("failnotes")
=== modified file 'lib/lp/code/model/recipebuilder.py'
--- lib/lp/code/model/recipebuilder.py 2013-08-28 08:03:32 +0000
+++ lib/lp/code/model/recipebuilder.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Code to build recipes on the buildfarm."""
@@ -142,7 +142,7 @@
# obtaining results so we know we are referring to the right
# database object in subsequent runs.
buildid = "%s-%s" % (self.build.id, build_queue_id)
- cookie = self.buildfarmjob.generateSlaveBuildCookie()
+ cookie = self.getBuildCookie()
chroot_sha1 = chroot.content.sha1
logger.info(
"Initiating build %s on %s" % (buildid, self._builder.url))
=== modified file 'lib/lp/code/model/sourcepackagerecipebuild.py'
--- lib/lp/code/model/sourcepackagerecipebuild.py 2013-08-28 04:40:32 +0000
+++ lib/lp/code/model/sourcepackagerecipebuild.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Implementation code for source package builds."""
@@ -471,8 +471,5 @@
store.add(specific_job)
return specific_job
- def getName(self):
- return "%s-%s" % (self.id, self.build_id)
-
def score(self):
return 2505 + self.build.archive.relative_build_score
=== modified file 'lib/lp/code/model/tests/test_recipebuilder.py'
--- lib/lp/code/model/tests/test_recipebuilder.py 2013-09-02 01:51:25 +0000
+++ lib/lp/code/model/tests/test_recipebuilder.py 2013-09-02 08:37:02 +0000
@@ -319,8 +319,7 @@
self.assertEquals(["ensurepresent", "build"],
[call[0] for call in slave.call_log])
build_args = slave.call_log[1][1:]
- self.assertEquals(
- build_args[0], job.buildfarmjob.generateSlaveBuildCookie())
+ self.assertEquals(build_args[0], job.getBuildCookie())
self.assertEquals(build_args[1], "sourcepackagerecipe")
self.assertEquals(build_args[3], [])
distroarchseries = job.build.distroseries.architectures[0]
=== modified file 'lib/lp/code/model/tests/test_sourcepackagerecipebuild.py'
--- lib/lp/code/model/tests/test_sourcepackagerecipebuild.py 2013-06-20 05:50:00 +0000
+++ lib/lp/code/model/tests/test_sourcepackagerecipebuild.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for source package builds."""
@@ -121,12 +121,6 @@
title = "%s recipe build" % spb.recipe.base_branch.unique_name
self.assertEqual(spb.title, title)
- def test_getTitle(self):
- # A recipe build job's title is the same as its build's title.
- spb = self.makeSourcePackageRecipeBuild()
- job = spb.makeJob()
- self.assertEqual(job.getTitle(), spb.title)
-
def test_distribution(self):
# A source package recipe build has a distribution derived from
# its series.
=== modified file 'lib/lp/soyuz/browser/tests/builder-views.txt'
--- lib/lp/soyuz/browser/tests/builder-views.txt 2013-08-27 07:49:25 +0000
+++ lib/lp/soyuz/browser/tests/builder-views.txt 2013-09-02 08:37:02 +0000
@@ -207,7 +207,8 @@
>>> import datetime
>>> import pytz
- >>> private_job.setDateStarted(
+ >>> from zope.security.proxy import removeSecurityProxy
+ >>> removeSecurityProxy(private_job.job).date_started = (
... datetime.datetime.now(pytz.UTC) - datetime.timedelta(10))
>>> print admin_view.current_build_duration
10 days...
@@ -364,7 +365,6 @@
processor queue in the PPA category.
>>> import datetime
- >>> from zope.security.proxy import removeSecurityProxy
>>> login('foo.bar@xxxxxxxxxxxxx')
>>> any_failed_build = cprov.archive.getBuildRecords(
... build_state=BuildStatus.FAILEDTOBUILD)[0]
=== modified file 'lib/lp/soyuz/browser/tests/test_builder.py'
--- lib/lp/soyuz/browser/tests/test_builder.py 2013-01-07 07:43:32 +0000
+++ lib/lp/soyuz/browser/tests/test_builder.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for the lp.soyuz.browser.builder module."""
@@ -9,7 +9,8 @@
from zope.component import getUtility
from lp.buildmaster.interfaces.builder import IBuilderSet
-from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet
+from lp.buildmaster.model.buildqueue import BuildQueue
+from lp.services.database.interfaces import IStore
from lp.services.job.model.job import Job
from lp.soyuz.browser.tests.test_builder_views import BuildCreationMixin
from lp.testing import (
@@ -71,8 +72,8 @@
jobset = getUtility(ITranslationTemplatesBuildJobSource)
branch = self.factory.makeBranch()
specific_job = jobset.create(branch)
- queueset = getUtility(IBuildQueueSet)
- queue = queueset.getByJob(specific_job.job)
+ queue = IStore(BuildQueue).find(
+ BuildQueue, job=specific_job.job).one()
queue.markAsBuilding(self.factory.makeBuilder())
nb_objects = 2
=== modified file 'lib/lp/soyuz/model/binarypackagebuildbehavior.py'
--- lib/lp/soyuz/model/binarypackagebuildbehavior.py 2013-08-22 04:07:24 +0000
+++ lib/lp/soyuz/model/binarypackagebuildbehavior.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Builder behavior for binary package builds."""
@@ -37,6 +37,29 @@
logger.info("startBuild(%s, %s, %s, %s)", self._builder.url,
spr.name, spr.version, self.build.pocket.title)
+ def getLogFileName(self):
+ """See `IBuildPackageJob`."""
+ sourcename = self.build.source_package_release.name
+ version = self.build.source_package_release.version
+ # we rely on previous storage of current buildstate
+ # in the state handling methods.
+ state = self.build.status.name
+
+ dar = self.build.distro_arch_series
+ distroname = dar.distroseries.distribution.name
+ distroseriesname = dar.distroseries.name
+ archname = dar.architecturetag
+
+ # logfilename format:
+ # buildlog_<DISTRIBUTION>_<DISTROSeries>_<ARCHITECTURE>_\
+ # <SOURCENAME>_<SOURCEVERSION>_<BUILDSTATE>.txt
+ # as:
+ # buildlog_ubuntu_dapper_i386_foo_1.0-ubuntu0_FULLYBUILT.txt
+ # it fix request from bug # 30617
+ return ('buildlog_%s-%s-%s.%s_%s_%s.txt' % (
+ distroname, distroseriesname, archname, sourcename, version,
+ state))
+
def _buildFilemapStructure(self, ignored, logger):
# Build filemap structure with the files required in this build
# and send them to the slave.
@@ -72,7 +95,7 @@
# obtaining results so we know we are referring to the right
# database object in subsequent runs.
buildid = "%s-%s" % (self.build.id, build_queue_id)
- cookie = self.buildfarmjob.generateSlaveBuildCookie()
+ cookie = self.getBuildCookie()
chroot_sha1 = chroot.content.sha1
logger.debug(
"Initiating build %s on %s" % (buildid, self._builder.url))
=== modified file 'lib/lp/soyuz/model/buildpackagejob.py'
--- lib/lp/soyuz/model/buildpackagejob.py 2013-06-20 05:50:00 +0000
+++ lib/lp/soyuz/model/buildpackagejob.py 2013-09-02 08:37:02 +0000
@@ -103,33 +103,6 @@
return score
- def getLogFileName(self):
- """See `IBuildPackageJob`."""
- sourcename = self.build.source_package_release.name
- version = self.build.source_package_release.version
- # we rely on previous storage of current buildstate
- # in the state handling methods.
- state = self.build.status.name
-
- dar = self.build.distro_arch_series
- distroname = dar.distroseries.distribution.name
- distroseriesname = dar.distroseries.name
- archname = dar.architecturetag
-
- # logfilename format:
- # buildlog_<DISTRIBUTION>_<DISTROSeries>_<ARCHITECTURE>_\
- # <SOURCENAME>_<SOURCEVERSION>_<BUILDSTATE>.txt
- # as:
- # buildlog_ubuntu_dapper_i386_foo_1.0-ubuntu0_FULLYBUILT.txt
- # it fix request from bug # 30617
- return ('buildlog_%s-%s-%s.%s_%s_%s.txt' % (
- distroname, distroseriesname, archname, sourcename, version,
- state))
-
- def getName(self):
- """See `IBuildPackageJob`."""
- return self.build.source_package_release.name
-
@property
def processor(self):
"""See `IBuildFarmJob`."""
@@ -233,7 +206,7 @@
build = getUtility(IBinaryPackageBuildSet).getByQueueEntry(job)
distroseries = build.distro_arch_series.distroseries
if (
- build.pocket == PackagePublishingPocket.SECURITY or
+ build.pocket == PackagePublishingPocket.SECURITY or
(distroseries.status == SeriesStatus.OBSOLETE and
not build.archive.permit_obsolete_series_uploads)):
# We never build anything in the security pocket, or for obsolete
=== modified file 'lib/lp/soyuz/tests/test_binarypackagebuildbehavior.py'
--- lib/lp/soyuz/tests/test_binarypackagebuildbehavior.py 2013-08-27 11:35:09 +0000
+++ lib/lp/soyuz/tests/test_binarypackagebuildbehavior.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for BinaryPackageBuildBehavior."""
@@ -98,9 +98,7 @@
in order to trick the slave into building correctly.
:return: A list of the calls we expect to be made.
"""
- job = removeSecurityProxy(
- interactor._current_build_behavior).buildfarmjob
- build_id = job.generateSlaveBuildCookie()
+ cookie = interactor._current_build_behavior.getBuildCookie()
ds_name = build.distro_arch_series.distroseries.name
suite = ds_name + pocketsuffix[build.pocket]
archives = get_sources_list_for_building(
@@ -129,7 +127,7 @@
'suite': suite,
}
build_log = [
- ('build', build_id, 'binarypackage', chroot.content.sha1,
+ ('build', cookie, 'binarypackage', chroot.content.sha1,
filemap_names, extra_args)]
if interactor.builder.virtualized:
result = [('echo', 'ping')] + upload_logs + build_log
=== modified file 'lib/lp/soyuz/tests/test_buildpackagejob.py'
--- lib/lp/soyuz/tests/test_buildpackagejob.py 2013-06-20 05:50:00 +0000
+++ lib/lp/soyuz/tests/test_buildpackagejob.py 2013-09-02 08:37:02 +0000
@@ -216,11 +216,6 @@
bpj = bq.specific_job
self.assertEqual(bpj.virtualized, False)
- def test_getTitle(self):
- # Test that BuildPackageJob returns the title of the build.
- build, bq = find_job(self, 'gcc', '386')
- self.assertEqual(bq.specific_job.getTitle(), build.title)
-
def test_providesInterfaces(self):
# Ensure that a BuildPackageJob generates an appropriate cookie.
build, bq = find_job(self, 'gcc', '386')
=== modified file 'lib/lp/translations/model/translationtemplatesbuildbehavior.py'
--- lib/lp/translations/model/translationtemplatesbuildbehavior.py 2013-09-02 01:51:25 +0000
+++ lib/lp/translations/model/translationtemplatesbuildbehavior.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""An `IBuildFarmJobBehavior` for `TranslationTemplatesBuildJob`.
@@ -13,6 +13,7 @@
import logging
import os
+import re
import tempfile
import transaction
@@ -44,6 +45,14 @@
# Filename for the tarball of templates that the slave builds.
templates_tarball_path = 'translation-templates.tar.gz'
+ unsafe_chars = '[^a-zA-Z0-9_+-]'
+
+ def getLogFileName(self):
+ """See `IBuildFarmJob`."""
+ safe_name = re.sub(
+ self.unsafe_chars, '_', self.buildfarmjob.branch.unique_name)
+ return "translationtemplates_%s_%d.txt" % (safe_name, self.build.id)
+
def dispatchBuildToSlave(self, build_queue_item, logger):
"""See `IBuildFarmJobBehavior`."""
chroot = self._getChroot()
@@ -55,8 +64,6 @@
d = self._interactor.slave.cacheFile(logger, chroot)
def got_cache_file(ignored):
- cookie = self.buildfarmjob.generateSlaveBuildCookie()
-
args = {
'arch_tag': self._getDistroArchSeries().architecturetag,
'branch_url': self.buildfarmjob.branch.composePublicURL(),
@@ -65,7 +72,8 @@
filemap = {}
return self._interactor.slave.build(
- cookie, self.build_type, chroot_sha1, filemap, args)
+ self.getBuildCookie(), self.build_type, chroot_sha1, filemap,
+ args)
return d.addCallback(got_cache_file)
def _getChroot(self):
@@ -79,7 +87,7 @@
"""See `IBuildFarmJobBehavior`."""
logger.info(
"Starting templates build %s for %s." % (
- self.buildfarmjob.getName(),
+ self.getBuildCookie(),
self.buildfarmjob.branch.bzr_identity))
def _readTarball(self, buildqueue, filemap, logger):
@@ -131,10 +139,10 @@
from lp.buildmaster.manager import BUILDD_MANAGER_LOG_NAME
logger = logging.getLogger(BUILDD_MANAGER_LOG_NAME)
logger.info(
- "Templates generation job %s for %s finished with status %s." % (
- queue_item.specific_job.getName(),
+ "Processing finished %s build %s (%s) from builder %s" % (
+ status, self.getBuildCookie(),
queue_item.specific_job.branch.bzr_identity,
- status))
+ queue_item.builder.name))
if status == 'OK':
self.build.updateStatus(
=== modified file 'lib/lp/translations/model/translationtemplatesbuildjob.py'
--- lib/lp/translations/model/translationtemplatesbuildjob.py 2013-06-20 05:50:00 +0000
+++ lib/lp/translations/model/translationtemplatesbuildjob.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -9,7 +9,6 @@
from datetime import timedelta
import logging
-import re
from storm.store import Store
from zope.component import getUtility
@@ -21,7 +20,6 @@
from lp.buildmaster.enums import BuildFarmJobType
from lp.buildmaster.interfaces.buildfarmbranchjob import IBuildFarmBranchJob
-from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet
from lp.buildmaster.model.buildfarmjob import BuildFarmJobOld
from lp.buildmaster.model.buildqueue import BuildQueue
from lp.code.interfaces.branchjob import IRosettaUploadJobSource
@@ -60,8 +58,6 @@
duration_estimate = timedelta(seconds=10)
- unsafe_chars = '[^a-zA-Z0-9_+-]'
-
def score(self):
"""See `IBuildFarmJob`."""
# Hard-code score for now. Most PPA jobs start out at 2505;
@@ -69,20 +65,6 @@
# higher priority.
return HARDCODED_TRANSLATIONTEMPLATESBUILD_SCORE
- def getLogFileName(self):
- """See `IBuildFarmJob`."""
- sanitized_name = re.sub(self.unsafe_chars, '_', self.getName())
- return "translationtemplates_%s" % sanitized_name
-
- def getName(self):
- """See `IBuildFarmJob`."""
- buildqueue = getUtility(IBuildQueueSet).getByJob(self.job)
- return '%s-%d' % (self.branch.name, buildqueue.id)
-
- def getTitle(self):
- """See `IBuildFarmJob`."""
- return '%s translation templates build' % self.branch.bzr_identity
-
def cleanUp(self):
"""See `IBuildFarmJob`."""
# This class is not itself database-backed. But it delegates to
=== modified file 'lib/lp/translations/stories/buildfarm/xx-build-summary.txt'
--- lib/lp/translations/stories/buildfarm/xx-build-summary.txt 2013-08-27 09:17:07 +0000
+++ lib/lp/translations/stories/buildfarm/xx-build-summary.txt 2013-09-02 08:37:02 +0000
@@ -12,11 +12,12 @@
>>> from testtools.monkey import patch
>>> from zope.component import getUtility
>>> from lp.app.interfaces.launchpad import ILaunchpadCelebrities
+ >>> from lp.buildmaster.model.buildqueue import BuildQueue
+ >>> from lp.app.enums import ServiceUsage
+ >>> from lp.buildmaster.interactor import BuilderSlave
+ >>> from lp.services.database.interfaces import IStore
>>> from lp.services.librarian.interfaces import (
... ILibraryFileAliasSet)
- >>> from lp.app.enums import ServiceUsage
- >>> from lp.buildmaster.interactor import BuilderSlave
- >>> from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet
>>> from lp.testing.factory import (
... remove_security_proxy_and_shout_at_engineer)
>>> from lp.testing.fakemethod import FakeMethod
@@ -45,7 +46,8 @@
>>> naked_productseries.translations_autoimport_mode = (
... TranslationsBranchImportMode.IMPORT_TEMPLATES)
>>> specific_job = factory.makeTranslationTemplatesBuildJob(branch=branch)
- >>> buildqueue = getUtility(IBuildQueueSet).getByJob(specific_job.job)
+ >>> buildqueue = IStore(BuildQueue).find(
+ ... BuildQueue, job=specific_job.job).one()
>>> fake_chroot = getUtility(ILibraryFileAliasSet)[1]
>>> ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
=== modified file 'lib/lp/translations/tests/test_translationtemplatesbuildbehavior.py'
--- lib/lp/translations/tests/test_translationtemplatesbuildbehavior.py 2013-09-02 01:51:25 +0000
+++ lib/lp/translations/tests/test_translationtemplatesbuildbehavior.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Unit tests for TranslationTemplatesBuildBehavior."""
@@ -20,12 +20,13 @@
from lp.buildmaster.interfaces.buildfarmjobbehavior import (
IBuildFarmJobBehavior,
)
-from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet
+from lp.buildmaster.model.buildqueue import BuildQueue
from lp.buildmaster.tests.mock_slaves import (
SlaveTestHelpers,
WaitingSlave,
)
from lp.services.config import config
+from lp.services.database.interfaces import IStore
from lp.services.librarian.interfaces import ILibraryFileAliasSet
from lp.services.librarian.utils import copy_and_close
from lp.testing import TestCaseWithFactory
@@ -54,9 +55,6 @@
self.date_started = datetime.datetime.now(pytz.UTC)
self.destroySelf = FakeMethod()
- def getLogFileName(self):
- return self.specific_job.getLogFileName()
-
class MakeBehaviorMixin(object):
"""Provide common test methods."""
@@ -103,7 +101,13 @@
def _getBuildQueueItem(self, behavior):
"""Get `BuildQueue` for an `IBuildFarmJobBehavior`."""
job = removeSecurityProxy(behavior.buildfarmjob.job)
- return getUtility(IBuildQueueSet).getByJob(job.id)
+ return IStore(BuildQueue).find(BuildQueue, job=job).one()
+
+ def test_getLogFileName(self):
+ # Each job has a unique log file name.
+ b1 = self.makeBehavior()
+ b2 = self.makeBehavior()
+ self.assertNotEqual(b1.getLogFileName(), b2.getLogFileName())
def test_dispatchBuildToSlave_no_chroot_fails(self):
# dispatchBuildToSlave will fail if the chroot does not exist.
=== modified file 'lib/lp/translations/tests/test_translationtemplatesbuildjob.py'
--- lib/lp/translations/tests/test_translationtemplatesbuildjob.py 2013-06-20 05:50:00 +0000
+++ lib/lp/translations/tests/test_translationtemplatesbuildjob.py 2013-09-02 08:37:02 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -96,23 +96,6 @@
self.assertEquals(expected_processor, buildqueue.processor)
- def test_getName(self):
- # Each job gets a unique name.
- other_job = self.jobset.create(self.branch)
- self.assertNotEqual(self.specific_job.getName(), other_job.getName())
-
- def test_getTitle(self):
- self.jobset.create(self.branch)
- self.assertEqual(
- '%s translation templates build' % self.branch.bzr_identity,
- self.specific_job.getTitle())
-
- def test_getLogFileName(self):
- # Each job has a unique log file name.
- other_job = self.jobset.create(self.branch)
- self.assertNotEqual(
- self.specific_job.getLogFileName(), other_job.getLogFileName())
-
def test_score(self):
# For now, these jobs always score themselves at 2510. In the
# future however the scoring system is to be revisited.
@@ -122,7 +105,7 @@
# TranslationTemplatesBuildJob has its own customized cleanup
# behaviour, since it's actually a BranchJob.
job = removeSecurityProxy(self.specific_job.job)
- buildqueue = getUtility(IBuildQueueSet).getByJob(job)
+ buildqueue = IStore(BuildQueue).find(BuildQueue, job=job).one()
job_id = job.id
store = Store.of(job)
Follow ups