← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:get-sources-list-accept-behaviour into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:get-sources-list-accept-behaviour into launchpad:master with ~cjwatson/launchpad:snap-build-macaroon-snap-base as a prerequisite.

Commit message:
Pass behaviour rather than build to get_sources_list_for_building

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/401322

It's straightforward to get a build from a build behaviour, but not necessarily the other way round (since the behaviour has additional state such as the builder).  Refactor get_sources_list_for_building and its callers to pass down the behaviour, since that will be useful shortly.

No functional change: this is just preparation for later work.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:get-sources-list-accept-behaviour into launchpad:master.
diff --git a/lib/lp/buildmaster/interfaces/buildfarmjobbehaviour.py b/lib/lp/buildmaster/interfaces/buildfarmjobbehaviour.py
index e9a0b8d..4d768d8 100644
--- a/lib/lp/buildmaster/interfaces/buildfarmjobbehaviour.py
+++ b/lib/lp/buildmaster/interfaces/buildfarmjobbehaviour.py
@@ -25,6 +25,8 @@ class IBuildFarmJobBehaviour(Interface):
         "A list of `BuildBaseImageType`s indicating which types of base "
         "images can be used for this build.")
 
+    build = Attribute("The `IBuildFarmJob` to build.")
+
     archive = Attribute("The `Archive` to build against.")
 
     distro_arch_series = Attribute("The `DistroArchSeries` to build against.")
diff --git a/lib/lp/code/model/recipebuilder.py b/lib/lp/code/model/recipebuilder.py
index 532fbbf..dd88550 100644
--- a/lib/lp/code/model/recipebuilder.py
+++ b/lib/lp/code/model/recipebuilder.py
@@ -86,7 +86,7 @@ class RecipeBuildBehaviour(BuildFarmJobBehaviourBase):
             None).name
         args['archives'], args['trusted_keys'] = (
             yield get_sources_list_for_building(
-                self.build, self.distro_arch_series, None,
+                self, self.distro_arch_series, None,
                 tools_source=config.builddmaster.bzr_builder_sources_list,
                 logger=logger))
         # XXX cjwatson 2017-07-26: This duplicates "series", which is common
diff --git a/lib/lp/code/model/tests/test_recipebuilder.py b/lib/lp/code/model/tests/test_recipebuilder.py
index b353d30..b578a5f 100644
--- a/lib/lp/code/model/tests/test_recipebuilder.py
+++ b/lib/lp/code/model/tests/test_recipebuilder.py
@@ -181,8 +181,7 @@ class TestAsyncRecipeBuilder(TestRecipeBuilderBase):
         job = self.makeJob(with_builder=True)
         distroarchseries = job.build.distroseries.architectures[0]
         expected_archives, expected_trusted_keys = (
-            yield get_sources_list_for_building(
-                job.build, distroarchseries, None))
+            yield get_sources_list_for_building(job, distroarchseries, None))
         expected_archives.insert(
             0, "deb http://foo %s main" % job.build.distroseries.name)
         args = yield job.extraBuildArgs()
@@ -273,8 +272,7 @@ class TestAsyncRecipeBuilder(TestRecipeBuilderBase):
         job = self.makeJob(with_builder=True)
         distroarchseries = job.build.distroseries.architectures[0]
         expected_archives, expected_trusted_keys = (
-            yield get_sources_list_for_building(
-                job.build, distroarchseries, None))
+            yield get_sources_list_for_building(job, distroarchseries, None))
         logger = BufferLogger()
         extra_args = yield job.extraBuildArgs(logger)
         self.assertEqual({
@@ -308,8 +306,7 @@ class TestAsyncRecipeBuilder(TestRecipeBuilderBase):
         distroarchseries = job.build.distroseries.architectures[0]
         args = yield job.extraBuildArgs()
         expected_archives, expected_trusted_keys = (
-            yield get_sources_list_for_building(
-                job.build, distroarchseries, None))
+            yield get_sources_list_for_building(job, distroarchseries, None))
         self.assertEqual(args["archives"], expected_archives)
         self.assertEqual(args["trusted_keys"], expected_trusted_keys)
 
@@ -318,8 +315,7 @@ class TestAsyncRecipeBuilder(TestRecipeBuilderBase):
         job = self.makeJob(git=True, with_builder=True)
         distroarchseries = job.build.distroseries.architectures[0]
         expected_archives, expected_trusted_keys = (
-            yield get_sources_list_for_building(
-                job.build, distroarchseries, None))
+            yield get_sources_list_for_building(job, distroarchseries, None))
         extra_args = yield job.extraBuildArgs()
         self.assertEqual({
             'arch_tag': 'i386',
diff --git a/lib/lp/oci/model/ocirecipebuildbehaviour.py b/lib/lp/oci/model/ocirecipebuildbehaviour.py
index f76c6dc..e8a60f5 100644
--- a/lib/lp/oci/model/ocirecipebuildbehaviour.py
+++ b/lib/lp/oci/model/ocirecipebuildbehaviour.py
@@ -128,7 +128,7 @@ class OCIRecipeBuildBehaviour(SnapProxyMixin, BuildFarmJobBehaviourBase):
         args["name"] = build.recipe.name
         args["archives"], args["trusted_keys"] = (
             yield get_sources_list_for_building(
-                build, build.distro_arch_series, None,
+                self, build.distro_arch_series, None,
                 tools_source=None, tools_fingerprint=None,
                 logger=logger))
 
diff --git a/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py b/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
index 1fe69f3..0fb7574 100644
--- a/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
+++ b/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
@@ -381,7 +381,7 @@ class TestAsyncOCIRecipeBuildBehaviour(
         job = self.makeJob(git_ref=ref)
         expected_archives, expected_trusted_keys = (
             yield get_sources_list_for_building(
-                job.build, job.build.distro_arch_series, None))
+                job, job.build.distro_arch_series, None))
         for archive_line in expected_archives:
             self.assertIn('universe', archive_line)
         with dbuser(config.builddmaster.dbuser):
@@ -431,7 +431,7 @@ class TestAsyncOCIRecipeBuildBehaviour(
         job = self.makeJob(git_ref=ref, recipe=recipe)
         expected_archives, expected_trusted_keys = (
             yield get_sources_list_for_building(
-                job.build, job.build.distro_arch_series, None))
+                job, job.build.distro_arch_series, None))
         for archive_line in expected_archives:
             self.assertIn('universe', archive_line)
         with dbuser(config.builddmaster.dbuser):
@@ -487,7 +487,7 @@ class TestAsyncOCIRecipeBuildBehaviour(
         job = self.makeJob(git_ref=ref.repository.getRefByPath("HEAD"))
         expected_archives, expected_trusted_keys = (
             yield get_sources_list_for_building(
-                job.build, job.build.distro_arch_series, None))
+                job, job.build.distro_arch_series, None))
         for archive_line in expected_archives:
             self.assertIn('universe', archive_line)
         with dbuser(config.builddmaster.dbuser):
diff --git a/lib/lp/snappy/model/snapbuildbehaviour.py b/lib/lp/snappy/model/snapbuildbehaviour.py
index f554268..dda949b 100644
--- a/lib/lp/snappy/model/snapbuildbehaviour.py
+++ b/lib/lp/snappy/model/snapbuildbehaviour.py
@@ -176,7 +176,7 @@ class SnapBuildBehaviour(SnapProxyMixin, BuildFarmJobBehaviourBase):
             archive_dependencies.extend(build.snap_base.dependencies)
         args["archives"], args["trusted_keys"] = (
             yield get_sources_list_for_building(
-                build, build.distro_arch_series, None,
+                self, build.distro_arch_series, None,
                 archive_dependencies=archive_dependencies,
                 tools_source=tools_source, tools_fingerprint=tools_fingerprint,
                 logger=logger))
diff --git a/lib/lp/snappy/tests/test_snapbuildbehaviour.py b/lib/lp/snappy/tests/test_snapbuildbehaviour.py
index d223596..1d80326 100644
--- a/lib/lp/snappy/tests/test_snapbuildbehaviour.py
+++ b/lib/lp/snappy/tests/test_snapbuildbehaviour.py
@@ -340,7 +340,7 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
         job = self.makeJob(branch=branch)
         expected_archives, expected_trusted_keys = (
             yield get_sources_list_for_building(
-                job.build, job.build.distro_arch_series, None))
+                job, job.build.distro_arch_series, None))
         for archive_line in expected_archives:
             self.assertIn('universe', archive_line)
         with dbuser(config.builddmaster.dbuser):
@@ -380,7 +380,7 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
         job = self.makeJob(git_ref=ref)
         expected_archives, expected_trusted_keys = (
             yield get_sources_list_for_building(
-                job.build, job.build.distro_arch_series, None))
+                job, job.build.distro_arch_series, None))
         for archive_line in expected_archives:
             self.assertIn('universe', archive_line)
         with dbuser(config.builddmaster.dbuser):
@@ -411,7 +411,7 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
         job = self.makeJob(git_ref=ref.repository.getRefByPath("HEAD"))
         expected_archives, expected_trusted_keys = (
             yield get_sources_list_for_building(
-                job.build, job.build.distro_arch_series, None))
+                job, job.build.distro_arch_series, None))
         for archive_line in expected_archives:
             self.assertIn('universe', archive_line)
         with dbuser(config.builddmaster.dbuser):
@@ -445,7 +445,7 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
         job = self.makeJob(git_ref=ref, private=True)
         expected_archives, expected_trusted_keys = (
             yield get_sources_list_for_building(
-                job.build, job.build.distro_arch_series, None))
+                job, job.build.distro_arch_series, None))
         for archive_line in expected_archives:
             self.assertIn('universe', archive_line)
         args = yield job.extraBuildArgs()
@@ -489,7 +489,7 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
         job = self.makeJob(git_ref=ref)
         expected_archives, expected_trusted_keys = (
             yield get_sources_list_for_building(
-                job.build, job.build.distro_arch_series, None))
+                job, job.build.distro_arch_series, None))
         for archive_line in expected_archives:
             self.assertIn('universe', archive_line)
         with dbuser(config.builddmaster.dbuser):
@@ -520,7 +520,7 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
         job = self.makeJob(git_ref=ref)
         expected_archives, expected_trusted_keys = (
             yield get_sources_list_for_building(
-                job.build, job.build.distro_arch_series, None))
+                job, job.build.distro_arch_series, None))
         for archive_line in expected_archives:
             self.assertIn('universe', archive_line)
         with dbuser(config.builddmaster.dbuser):
@@ -617,7 +617,7 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
         job = self.makeJob(channels={"snapcraft": "edge"})
         expected_archives, expected_trusted_keys = (
             yield get_sources_list_for_building(
-                job.build, job.build.distro_arch_series, None))
+                job, job.build.distro_arch_series, None))
         with dbuser(config.builddmaster.dbuser):
             args = yield job.extraBuildArgs()
         self.assertFalse(isProxy(args["channels"]))
@@ -629,7 +629,7 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
         job = self.makeJob(channels={"snapcraft": "apt"})
         expected_archives, expected_trusted_keys = (
             yield get_sources_list_for_building(
-                job.build, job.build.distro_arch_series, None))
+                job, job.build.distro_arch_series, None))
         with dbuser(config.builddmaster.dbuser):
             args = yield job.extraBuildArgs()
         self.assertNotIn("channels", args)
@@ -643,7 +643,7 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
         job = self.makeJob()
         expected_archives, expected_trusted_keys = (
             yield get_sources_list_for_building(
-                job.build, job.build.distro_arch_series, None))
+                job, job.build.distro_arch_series, None))
         with dbuser(config.builddmaster.dbuser):
             args = yield job.extraBuildArgs()
         self.assertFalse(isProxy(args["channels"]))
@@ -658,7 +658,7 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
         job = self.makeJob(channels={"snapcraft": "apt"})
         expected_archives, expected_trusted_keys = (
             yield get_sources_list_for_building(
-                job.build, job.build.distro_arch_series, None))
+                job, job.build.distro_arch_series, None))
         with dbuser(config.builddmaster.dbuser):
             args = yield job.extraBuildArgs()
         self.assertNotIn("channels", args)
diff --git a/lib/lp/soyuz/adapters/archivedependencies.py b/lib/lp/soyuz/adapters/archivedependencies.py
index c005651..ff1d117 100644
--- a/lib/lp/soyuz/adapters/archivedependencies.py
+++ b/lib/lp/soyuz/adapters/archivedependencies.py
@@ -250,8 +250,8 @@ def expand_dependencies(archive, distro_arch_series, pocket, component,
 
 
 @defer.inlineCallbacks
-def get_sources_list_for_building(build, distroarchseries, sourcepackagename,
-                                  archive_dependencies=None,
+def get_sources_list_for_building(behaviour, distroarchseries,
+                                  sourcepackagename, archive_dependencies=None,
                                   tools_source=None, tools_fingerprint=None,
                                   logger=None):
     """Return sources.list entries and keys required to build the given item.
@@ -264,7 +264,8 @@ def get_sources_list_for_building(build, distroarchseries, sourcepackagename,
 
     The keys are in an arbitrary order.
 
-    :param build: a context `IBuild`.
+    :param behaviour: the `IBuildFarmJobBehaviour` for the context
+        `IBuildFarmJob`.
     :param distroarchseries: A `IDistroArchSeries`
     :param sourcepackagename: A source package name (as text)
     :param archive_dependencies: a sequence of `IArchiveDependency` objects
@@ -280,6 +281,7 @@ def get_sources_list_for_building(build, distroarchseries, sourcepackagename,
         sources.list entries (lines) and a list of base64-encoded public
         keys.
     """
+    build = behaviour.build
     if archive_dependencies is None:
         archive_dependencies = build.archive.dependencies
     deps = expand_dependencies(
diff --git a/lib/lp/soyuz/adapters/tests/test_archivedependencies.py b/lib/lp/soyuz/adapters/tests/test_archivedependencies.py
index 1945a52..4eaeab0 100644
--- a/lib/lp/soyuz/adapters/tests/test_archivedependencies.py
+++ b/lib/lp/soyuz/adapters/tests/test_archivedependencies.py
@@ -23,6 +23,9 @@ from zope.security.proxy import removeSecurityProxy
 from lp.archivepublisher.interfaces.archivegpgsigningkey import (
     IArchiveGPGSigningKey,
     )
+from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
+    IBuildFarmJobBehaviour,
+    )
 from lp.registry.interfaces.distribution import IDistributionSet
 from lp.registry.interfaces.pocket import PackagePublishingPocket
 from lp.services.config import config
@@ -203,9 +206,10 @@ class TestSourcesList(TestCaseWithFactory):
             else:
                 prefix = archive_or_prefix + " "
             expected_lines.extend([prefix + suffix for suffix in suffixes])
+        behaviour = IBuildFarmJobBehaviour(build)
         sources_list, trusted_keys = yield get_sources_list_for_building(
-            build, build.distro_arch_series, build.source_package_release.name,
-            **kwargs)
+            behaviour, build.distro_arch_series,
+            build.source_package_release.name, **kwargs)
         self.assertEqual(expected_lines, sources_list)
         key_matchers = [
             Base64KeyMatches(self.fingerprints[key_name])
diff --git a/lib/lp/soyuz/model/binarypackagebuildbehaviour.py b/lib/lp/soyuz/model/binarypackagebuildbehaviour.py
index 3ff5603..6b74f46 100644
--- a/lib/lp/soyuz/model/binarypackagebuildbehaviour.py
+++ b/lib/lp/soyuz/model/binarypackagebuildbehaviour.py
@@ -165,7 +165,7 @@ class BinaryPackageBuildBehaviour(BuildFarmJobBehaviourBase):
 
         args['archives'], args['trusted_keys'] = (
             yield get_sources_list_for_building(
-                build, das, build.source_package_release.name, logger=logger))
+                self, das, build.source_package_release.name, logger=logger))
         args['build_debug_symbols'] = build.archive.build_debug_symbols
 
         defer.returnValue(args)
diff --git a/lib/lp/soyuz/model/livefsbuildbehaviour.py b/lib/lp/soyuz/model/livefsbuildbehaviour.py
index 4182c79..c439559 100644
--- a/lib/lp/soyuz/model/livefsbuildbehaviour.py
+++ b/lib/lp/soyuz/model/livefsbuildbehaviour.py
@@ -98,7 +98,7 @@ class LiveFSBuildBehaviour(BuildFarmJobBehaviourBase):
         args["datestamp"] = build.version
         args["archives"], args["trusted_keys"] = (
             yield get_sources_list_for_building(
-                build, build.distro_arch_series, None, logger=logger))
+                self, build.distro_arch_series, None, logger=logger))
         defer.returnValue(args)
 
     def verifySuccessfulBuild(self):
diff --git a/lib/lp/soyuz/tests/test_archive.py b/lib/lp/soyuz/tests/test_archive.py
index 419d552..a49ccd3 100644
--- a/lib/lp/soyuz/tests/test_archive.py
+++ b/lib/lp/soyuz/tests/test_archive.py
@@ -44,6 +44,9 @@ from lp.buildmaster.enums import (
     BuildQueueStatus,
     BuildStatus,
     )
+from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
+    IBuildFarmJobBehaviour,
+    )
 from lp.buildmaster.interfaces.processor import IProcessorSet
 from lp.registry.enums import (
     PersonVisibility,
@@ -1883,8 +1886,9 @@ class TestArchiveDependencies(TestCaseWithFactory):
                 PackagePublishingPocket.RELEASE)
             build = self.factory.makeBinaryPackageBuild(archive=p3a,
                 distroarchseries=bpph.distroarchseries)
+            behaviour = IBuildFarmJobBehaviour(build)
             sources_list, trusted_keys = yield get_sources_list_for_building(
-                build, build.distro_arch_series,
+                behaviour, build.distro_arch_series,
                 build.source_package_release.name)
             matches = MatchesRegex(
                 "deb http://buildd:sekrit@xxxxxxxxxxxxxxxxxxxxxxxxxx/";
@@ -2140,8 +2144,10 @@ class TestOverlays(TestCaseWithFactory):
         self._createDep(
             test_publisher, series11, 'series12', 'depdistro4', 'multiverse',
             PackagePublishingPocket.UPDATES)
+        behaviour = IBuildFarmJobBehaviour(build)
         sources_list, trusted_keys = yield get_sources_list_for_building(
-            build, build.distro_arch_series, build.source_package_release.name)
+            behaviour, build.distro_arch_series,
+            build.source_package_release.name)
 
         self.assertThat(
             "\n".join(sources_list),
diff --git a/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py b/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py
index 35390f3..cc27742 100644
--- a/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py
+++ b/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py
@@ -94,22 +94,24 @@ class TestBinaryBuildPackageBehaviour(StatsMixin, TestCaseWithFactory):
         self.setUpStats()
 
     @defer.inlineCallbacks
-    def assertExpectedInteraction(self, call_log, builder, build, chroot,
-                                  archive, archive_purpose, component=None,
-                                  extra_uploads=None, filemap_names=None):
+    def assertExpectedInteraction(self, call_log, builder, build, behaviour,
+                                  chroot, archive, archive_purpose,
+                                  component=None, extra_uploads=None,
+                                  filemap_names=None):
         expected = yield self.makeExpectedInteraction(
-            builder, build, chroot, archive, archive_purpose, component,
-            extra_uploads, filemap_names)
+            builder, build, behaviour, chroot, archive, archive_purpose,
+            component, extra_uploads, filemap_names)
         self.assertEqual(expected, call_log)
 
     @defer.inlineCallbacks
-    def makeExpectedInteraction(self, builder, build, chroot, archive,
-                                archive_purpose, component=None,
+    def makeExpectedInteraction(self, builder, build, behaviour, chroot,
+                                archive, archive_purpose, component=None,
                                 extra_uploads=None, filemap_names=None):
         """Build the log of calls that we expect to be made to the slave.
 
         :param builder: The builder we are using to build the binary package.
         :param build: The build being done on the builder.
+        :param behaviour: The build behaviour.
         :param chroot: The `LibraryFileAlias` for the chroot in which we are
             building.
         :param archive: The `IArchive` into which we are building.
@@ -123,7 +125,7 @@ class TestBinaryBuildPackageBehaviour(StatsMixin, TestCaseWithFactory):
         ds_name = das.distroseries.name
         suite = ds_name + pocketsuffix[build.pocket]
         archives, trusted_keys = yield get_sources_list_for_building(
-            build, das, build.source_package_release.name)
+            behaviour, das, build.source_package_release.name)
         arch_indep = das.isNominatedArchIndep
         if component is None:
             component = build.current_component.name
@@ -178,11 +180,11 @@ class TestBinaryBuildPackageBehaviour(StatsMixin, TestCaseWithFactory):
         bq = build.queueBuild()
         bq.markAsBuilding(builder)
         interactor = BuilderInteractor()
+        behaviour = interactor.getBuildBehaviour(bq, builder, slave)
         yield interactor._startBuild(
-            bq, vitals, builder, slave,
-            interactor.getBuildBehaviour(bq, builder, slave), BufferLogger())
+            bq, vitals, builder, slave, behaviour, BufferLogger())
         yield self.assertExpectedInteraction(
-            slave.call_log, builder, build, lf, archive,
+            slave.call_log, builder, build, behaviour, lf, archive,
             ArchivePurpose.PRIMARY, 'universe')
         self.assertEqual(1, self.stats_client.incr.call_count)
         self.assertEqual(
@@ -213,11 +215,11 @@ class TestBinaryBuildPackageBehaviour(StatsMixin, TestCaseWithFactory):
         bq = build.queueBuild()
         bq.markAsBuilding(builder)
         interactor = BuilderInteractor()
+        behaviour = interactor.getBuildBehaviour(bq, builder, slave)
         yield interactor._startBuild(
-            bq, vitals, builder, slave,
-            interactor.getBuildBehaviour(bq, builder, slave), BufferLogger())
+            bq, vitals, builder, slave, behaviour, BufferLogger())
         yield self.assertExpectedInteraction(
-            slave.call_log, builder, build, lf, archive,
+            slave.call_log, builder, build, behaviour, lf, archive,
             ArchivePurpose.PRIMARY, 'main')
 
     @defer.inlineCallbacks
@@ -236,11 +238,12 @@ class TestBinaryBuildPackageBehaviour(StatsMixin, TestCaseWithFactory):
         bq = build.queueBuild()
         bq.markAsBuilding(builder)
         interactor = BuilderInteractor()
+        behaviour = interactor.getBuildBehaviour(bq, builder, slave)
         yield interactor._startBuild(
-            bq, vitals, builder, slave,
-            interactor.getBuildBehaviour(bq, builder, slave), BufferLogger())
+            bq, vitals, builder, slave, behaviour, BufferLogger())
         yield self.assertExpectedInteraction(
-            slave.call_log, builder, build, lf, archive, ArchivePurpose.PPA)
+            slave.call_log, builder, build, behaviour, lf, archive,
+            ArchivePurpose.PPA)
         self.assertEqual(1, self.stats_client.incr.call_count)
         self.assertEqual(
             self.stats_client.incr.call_args_list[0][0],
@@ -273,11 +276,12 @@ class TestBinaryBuildPackageBehaviour(StatsMixin, TestCaseWithFactory):
         bq = build.queueBuild()
         bq.markAsBuilding(builder)
         interactor = BuilderInteractor()
+        behaviour = interactor.getBuildBehaviour(bq, builder, slave)
         yield interactor._startBuild(
-            bq, vitals, builder, slave,
-            interactor.getBuildBehaviour(bq, builder, slave), BufferLogger())
+            bq, vitals, builder, slave, behaviour, BufferLogger())
         yield self.assertExpectedInteraction(
-            slave.call_log, builder, build, lf, archive, ArchivePurpose.PPA,
+            slave.call_log, builder, build, behaviour, lf, archive,
+            ArchivePurpose.PPA,
             extra_uploads=[(sprf_url, 'buildd', 'sekrit')],
             filemap_names=[sprf.libraryfile.filename])
 
@@ -297,11 +301,11 @@ class TestBinaryBuildPackageBehaviour(StatsMixin, TestCaseWithFactory):
         bq = build.queueBuild()
         bq.markAsBuilding(builder)
         interactor = BuilderInteractor()
+        behaviour = interactor.getBuildBehaviour(bq, builder, slave)
         yield interactor._startBuild(
-            bq, vitals, builder, slave,
-            interactor.getBuildBehaviour(bq, builder, slave), BufferLogger())
+            bq, vitals, builder, slave, behaviour, BufferLogger())
         yield self.assertExpectedInteraction(
-            slave.call_log, builder, build, lf, archive,
+            slave.call_log, builder, build, behaviour, lf, archive,
             ArchivePurpose.PARTNER)
 
     def test_dont_dispatch_release_builds(self):
diff --git a/lib/lp/soyuz/tests/test_livefsbuildbehaviour.py b/lib/lp/soyuz/tests/test_livefsbuildbehaviour.py
index 4820132..8d6f33b 100644
--- a/lib/lp/soyuz/tests/test_livefsbuildbehaviour.py
+++ b/lib/lp/soyuz/tests/test_livefsbuildbehaviour.py
@@ -201,7 +201,7 @@ class TestAsyncLiveFSBuildBehaviour(TestLiveFSBuildBehaviourBase):
             with_builder=True)
         expected_archives, expected_trusted_keys = (
             yield get_sources_list_for_building(
-                job.build, job.build.distro_arch_series, None))
+                job, job.build.distro_arch_series, None))
         extra_args = yield job.extraBuildArgs()
         self.assertEqual({
             "archive_private": False,