launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25423
[Merge] ~twom/launchpad:stats-can-the-builders-count into launchpad:master
Tom Wardill has proposed merging ~twom/launchpad:stats-can-the-builders-count into launchpad:master.
Commit message:
Add counts for build dispatches
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/391610
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:stats-can-the-builders-count into launchpad:master.
diff --git a/lib/lp/buildmaster/model/buildfarmjobbehaviour.py b/lib/lp/buildmaster/model/buildfarmjobbehaviour.py
index fa44fb9..4c32813 100644
--- a/lib/lp/buildmaster/model/buildfarmjobbehaviour.py
+++ b/lib/lp/buildmaster/model/buildfarmjobbehaviour.py
@@ -34,6 +34,7 @@ from lp.services.config import config
from lp.services.helpers import filenameToContentType
from lp.services.librarian.interfaces import ILibraryFileAliasSet
from lp.services.librarian.utils import copy_and_close
+from lp.services.statsd.interfaces.statsd_client import IStatsdClient
from lp.services.utils import sanitise_urls
from lp.services.webapp import canonical_url
@@ -152,6 +153,11 @@ class BuildFarmJobBehaviourBase:
(status, info) = yield self._slave.build(
cookie, builder_type, chroot.content.sha1, filename_to_sha1, args)
+ # Update stats
+ job_type = getattr(self.build, 'job_type', 'UNKNOWN')
+ getUtility(IStatsdClient).incr(
+ 'build.count,job_type={}'.format(job_type))
+
logger.info(
"Job %s (%s) started on %s: %s %s"
% (cookie, self.build.title, self._builder.url, status, info))
diff --git a/lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py b/lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py
index 8cbda44..ea82569 100644
--- a/lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py
+++ b/lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py
@@ -22,6 +22,7 @@ from zope.security.proxy import removeSecurityProxy
from lp.archiveuploader.uploadprocessor import parse_build_upload_leaf_name
from lp.buildmaster.enums import (
BuildBaseImageType,
+ BuildFarmJobType,
BuildStatus,
)
from lp.buildmaster.interactor import (
@@ -44,6 +45,7 @@ from lp.buildmaster.tests.mock_slaves import (
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.services.config import config
from lp.services.log.logger import BufferLogger
+from lp.services.statsd.tests import StatsMixin
from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
from lp.testing import (
TestCase,
@@ -55,6 +57,7 @@ from lp.testing.fakemethod import FakeMethod
from lp.testing.layers import (
LaunchpadZopelessLayer,
ZopelessDatabaseLayer,
+ ZopelessLayer,
)
from lp.testing.mail_helpers import pop_notifications
@@ -155,8 +158,9 @@ class TestBuildFarmJobBehaviourBase(TestCaseWithFactory):
self.assertIs(False, behaviour.extraBuildArgs()["fast_cleanup"])
-class TestDispatchBuildToSlave(TestCase):
+class TestDispatchBuildToSlave(StatsMixin, TestCase):
+ layer = ZopelessLayer
run_tests_with = AsynchronousDeferredRunTest
def makeBehaviour(self, das):
@@ -260,6 +264,20 @@ class TestDispatchBuildToSlave(TestCase):
self.assertDispatched(
slave, logger, 'chroot-fooix-bar-y86.tar.gz', 'chroot')
+ @defer.inlineCallbacks
+ def test_dispatchBuildToSlave_stats(self):
+ self.setUpStats()
+ behaviour = self.makeBehaviour(FakeDistroArchSeries())
+ builder = MockBuilder()
+ slave = OkSlave()
+ logger = BufferLogger()
+ behaviour.setBuilder(builder, slave)
+ yield behaviour.dispatchBuildToSlave(logger)
+ self.assertEqual(1, self.stats_client.incr.call_count)
+ self.assertEqual(
+ self.stats_client.incr.call_args_list[0][0],
+ ('build.count,job_type=UNKNOWN',))
+
class TestGetUploadMethodsMixin:
"""Tests for `IPackageBuild` that need objects from the rest of LP."""
diff --git a/lib/lp/soyuz/interfaces/binarypackagerelease.py b/lib/lp/soyuz/interfaces/binarypackagerelease.py
index 2ee397e..592d515 100644
--- a/lib/lp/soyuz/interfaces/binarypackagerelease.py
+++ b/lib/lp/soyuz/interfaces/binarypackagerelease.py
@@ -90,6 +90,8 @@ class IBinaryPackageRelease(Interface):
name = Attribute("Binary Package Name")
sourcepackagename = Attribute(
"The name of the source package from where this binary was built.")
+ sourcepackageversion = Attribute(
+ "The version of the source package from where this binary was built.")
def addFile(file):
"""Create a BinaryPackageFile record referencing this build
diff --git a/lib/lp/soyuz/interfaces/publishing.py b/lib/lp/soyuz/interfaces/publishing.py
index 4443284..162fb17 100644
--- a/lib/lp/soyuz/interfaces/publishing.py
+++ b/lib/lp/soyuz/interfaces/publishing.py
@@ -604,8 +604,17 @@ class IBinaryPackagePublishingHistoryPublic(IPublishingView):
required=False, readonly=False)
binarypackagerelease = Attribute(
"The binary package release being published")
- source_package_name = Attribute(
- 'The source package name that built this binary.')
+ source_package_name = exported(
+ TextLine(
+ title=_("Source Package Name"),
+ description=_('The source package name that built this binary.'),
+ required=False, readonly=True))
+ source_package_version = exported(
+ TextLine(
+ title=_("Source Package Version"),
+ description=_(
+ 'The source package version that built this binary.'),
+ required=False, readonly=True))
distroarchseriesID = Int(
title=_("The DB id for the distroarchseries."),
required=False, readonly=False)
diff --git a/lib/lp/soyuz/model/binarypackagerelease.py b/lib/lp/soyuz/model/binarypackagerelease.py
index 3458b70..8866723 100644
--- a/lib/lp/soyuz/model/binarypackagerelease.py
+++ b/lib/lp/soyuz/model/binarypackagerelease.py
@@ -125,6 +125,11 @@ class BinaryPackageRelease(SQLBase):
"""See `IBinaryPackageRelease`."""
return self.build.source_package_release.sourcepackagename.name
+ @property
+ def sourcepackageversion(self):
+ """See `IBinaryPackageRelease`."""
+ return self.build.source_package_release.version
+
@cachedproperty
def files(self):
return list(
diff --git a/lib/lp/soyuz/model/publishing.py b/lib/lp/soyuz/model/publishing.py
index 33390b5..86db3c1 100644
--- a/lib/lp/soyuz/model/publishing.py
+++ b/lib/lp/soyuz/model/publishing.py
@@ -704,6 +704,11 @@ class BinaryPackagePublishingHistory(SQLBase, ArchivePublisherBase):
return self.binarypackagerelease.sourcepackagename
@property
+ def source_package_version(self):
+ """See `IBinaryPackagePublishingHistory`"""
+ return self.binarypackagerelease.sourcepackageversion
+
+ @property
def architecture_specific(self):
"""See `IBinaryPackagePublishingHistory`"""
return self.binarypackagerelease.architecturespecific