Merge lp:~jtv/launchpad/bug-537866 into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Jeroen T. Vermeulen on 2010-03-12 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | not available |
| Proposed branch: | lp:~jtv/launchpad/bug-537866 |
| Merge into: | lp:launchpad |
| Diff against target: |
695 lines (+372/-77) 9 files modified
lib/lp/buildmaster/interfaces/buildfarmjobbehavior.py (+1/-1) lib/lp/buildmaster/model/buildfarmjobbehavior.py (+94/-10) lib/lp/buildmaster/tests/test_buildfarmjobbehavior.py (+80/-8) lib/lp/code/model/recipebuilder.py (+11/-2) lib/lp/soyuz/doc/buildd-slavescanner.txt (+4/-3) lib/lp/testing/factory.py (+87/-40) lib/lp/translations/doc/translationtemplatesbuildbehavior.txt (+41/-12) lib/lp/translations/model/translationtemplatesbuildbehavior.py (+17/-1) lib/lp/translations/tests/test_translationtemplatesbuildbehavior.py (+37/-0) |
| To merge this branch: | bzr merge lp:~jtv/launchpad/bug-537866 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Guilherme Salgado (community) | 2010-03-12 | Approve on 2010-03-12 | |
|
Review via email:
|
|||
Commit Message
Fix branch_url passed to the slave; fix slave build id verification for TranslationTemp
Description of the Change
= Bug 537866 =
Two bugs with generating translation templates in the build farm based on bzr branches are fixed here:
* Despite the TranslationTemp
* BuildFarmJobBeh
The first of these is a simple matter of using the stored parameters instead of recomputing them. Technically it may be nicer to compute the branch URL in TranslationTemp
The second happens because the base BuildFarmJobBeh
In order to avoid code duplication in doing so, I extracted two helpers from the base verifySlaveBuildID: one verifies the Build id contained in the name, and the other the BuildQueue id. The main method just extracts those two parts, calls the helpers, and finally checks that the objects are properly matched. The two helpers ended up so similar that I couldn't help creating yet a third helper that implements either, depending on some customizing parameters.
Implementing the tests required me to produce a realistic Build object. This hurts, but a _relatively_ easy way to do it was to create a SourcePackageRe
To test:
{{{
./bin/test -vv -t test_translatio
}}}
For Q/A, go through the instructions at https:/
No lint.
Jeroen
| Jeroen T. Vermeulen (jtv) wrote : | # |
This is scary. Some arbitrary characters seem to have changed in the code after I last ran "make lint" and the tests. The duplicate test method names (where the word "Queue" was missing in two places) may have been an omission on my part as I continued adding tests at a late stage, though I think these were from an earlier state that I also ran through lint. The "utem" and missing spaces definitely passed lint since I last worked on them.
I hope it's simply because of the mouse cursor moving and activating a different window while I'm typing (as it likes to do for some reason—I know there's a setting for that but I guess my touchpad driver doesn't obey it) but in the past few hours I've also had unexpected characters appearing when copy/pasting. I'll reboot as soon as possible.
Anyway, I've removed the two helper methods from the interface and updated the doc strings.
| Guilherme Salgado (salgado) wrote : | # |
I was doing a second pass on this but then you told me you've got some
more things you need to change here, so I'm sending what I have so far.
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -3,10 +3,18 @@
>
> """Unit tests for BuildFarmJobBeh
>
> -from unittest import TestCase, TestLoader
> +from unittest import TestLoader
> +
> +from zope.component import getUtility
> +
> +from canonical.
> +from lp.testing import TestCaseWithFactory
>
> from lp.buildmaster.
> +from lp.buildmaster.
> from lp.buildmaster.
> +from lp.registry.
> +from lp.soyuz.
>
>
> class FakeBuildFarmJob:
> @@ -14,27 +22,90 @@
> pass
>
>
> -class TestBuildFarmJo
> +class TestBuildFarmJo
> """Test very small, basic bits of BuildFarmJobBeh
>
> - def setUp(self):
> - self.behavior = BuildFarmJobBeh
> + layer = ZopelessDatabas
> +
> + def _makeBehavior(self, buildfarmjob=None):
> + """Create a `BuildFarmJobBe
> + if buildfarmjob is None:
> + buildfarmjob = FakeBuildFarmJob()
> + return BuildFarmJobBeh
> +
> + def _makeBuild(self):
> + """Create a `Build` object."""
> + x86 = getUtility(
> + distroarchseries = self.factory.
> + architecturetag
> + distroseries = distroarchserie
> + archive = self.factory.
> + distribution=
> + pocket = PackagePublishi
> + spr = self.factory.
> +
> + return spr.createBuild(
> + distroarchserie
> +
> + def _makeBuildQueue
> + """Create a `BuildQueue` object."""
> + return self.factory.
>
> def test_extractBui
> # extractBuildStatus picks the name of the build status out of a
> # dict describing the slave's status.
> slave_status = {'build_status': 'BuildStatus.
> + behavior = self._makeBehav
> self.assertEqual(
> BuildStatus.
> - self.behavior.
> + behavior.
>
> def test_extractBui
> # extractBuildStatus errors out when the status string is not
> # of the form it expects.
> slave_status = ...
| Jeroen T. Vermeulen (jtv) wrote : | # |
> I was doing a second pass on this but then you told me you've got some
> more things you need to change here, so I'm sending what I have so far.
That's right. The latest change was in the translationtemp
> > === modified file 'lib/lp/
> > --- lib/lp/
> > +++ lib/lp/
> > @@ -2007,46 +2007,35 @@
> > def getAnySourcePac
> > return SourcePackageUr
> >
> > - def makeSourcePacka
> > - distroseries=None,
> maintainer=None,
> > - creator=None, component=None,
> > - section=None, urgency=None,
> > - version=None, archive=None,
> > - builddepends=None,
> > - builddependsind
> > - build_conflicts
> > - build_conflicts
> > - architecturehin
> > - dateremoved=None,
> > - date_uploaded=
> > - pocket=None,
> > - status=None,
> > - scheduleddeleti
> > - dsc_standards_
> > - dsc_format='1.0',
> > - dsc_binaries=
> > - ):
> > - if sourcepackagename is None:
> > - sourcepackagename = self.makeSource
> > - spn = sourcepackagename
> > + def makeSPR(self, archive=None, sourcepackagena
> distroseries=None,
>
> Why not makeSourcePacka
> existing ones and avoids the abbreviation, which are not good anyway.
Sure. It's only 5 lines extra; I thought it would be worse. I admit it: I abbreviated to avoid having to line up the parameters on all the following lines behind the opening parenthesis.
> > + if sourcepackagename is None:
> > + sourcepackagename = self.makeSource
> > + spn = sourcepackagename
>
> Would you mind dropping the line above and using 'sourcepackagename' in the
> single place that uses it below?
Not at all. I was just copying over the original code, but now that it's broken down into more manageable pieces, might as well clean up a bit more.
> > @@ -2064,12 +2053,13 @@
> > if creator is None:
> > creator = self.makePerson()
> >
> > + if dscsigningkey is None:
> > + gpg_key = self.makeGPGKey
>
> This is broken now -- gpg_key is no longer used, so y...
| Guilherme Salgado (salgado) wrote : | # |
On Fri, 2010-03-12 at 20:24 +0000, Jeroen T. Vermeulen wrote:
> > > + def makeSourcePacka
> > > + distroseries=None,
> > maintainer=None,
> > > + creator=None, component=None,
> > > + section=None, urgency=None,
> > > + version=None, archive=None,
> > > + builddepends=None,
> > > + builddependsind
> > > + build_conflicts
> > > + build_conflicts
> > > + architecturehin
> > > + dateremoved=None,
> > > + date_uploaded=
> > > + pocket=None,
> > > + status=None,
> > > + scheduleddeleti
> > > + dsc_standards_
> > > + dsc_format='1.0',
> > > + dsc_binaries=
> > > + ):
> > > + if pocket is None:
> > > + pocket = self.getAnyPocket()
> > > +
> > > + if status is None:
> > > + status = PackagePublishi
> > > +
> > > + spr = self.makeSPR(
> > > + archive=archive,
> > > + sourcepackagena
> > > + distroseries=
> > > + maintainer=
> > > + creator=creator, component=
> > > + section=section,
> > > + urgency=urgency,
> > > + version=version,
> > > + builddepends=
> > > + builddependsind
> > > + build_conflicts
> > > + build_conflicts
> > > + architecturehin
> > > + dsc_standards_
> > > + dsc_format=
> > > + dsc_binaries=
> > > + date_uploaded=
> > >
> > > sspph = SourcePackagePu
> > > - distroseries=
> > > + distroseries=
> >
> > Is this change needed? Couldn't you keep using the distroseries passed as
> > argument?
>
> Again, you're right. I just need to create a distroseries here if I don't already have one, so it adds a tiny bit of duplication.
>
Oh, it wasn't clear to me that you were doing that because makeSPR would
create the distro when None was given to it. If there was a comment I
wouldn't have complained here.
Anyway, I'm happy if you want to leave this tiny bit of duplication but
I'd also be happy with what you had before, a...

Hi Jeroen,
I found a few issues that I'd like you to address before I do a proper
review of this branch.
review needsfixing
> === modified file 'lib/lp/ buildmaster/ interfaces/ buildfarmjobbeh avior.py' buildmaster/ interfaces/ buildfarmjobbeh avior.py 2010-01-21 05:03:16 +0000 buildmaster/ interfaces/ buildfarmjobbeh avior.py 2010-03-12 13:56:29 +0000 msg=E0211, E0213 slaveStatus( ). d(raw_id) :
> --- lib/lp/
> +++ lib/lp/
> @@ -1,4 +1,4 @@
> -# Copyright 2009 Canonical Ltd. This software is licensed under the
> +# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
> # GNU Affero General Public License version 3 (see the file LICENSE).
>
> # pylint: disable-
> @@ -57,6 +57,28 @@
> of IBuilder.
> """
>
> + def getVerifiedBuil
> + """Verify the `Build` id component of a slave build id.
I find it a bit odd that the method's name implies it's used to get
something but its docstring says it just verifies. How about
"""Return the `Build` object with the given id.
...
"""
I'd also like the docstring to state what sort of verification is done.
Oh, and does this need to be part of the public interface? ISTM that
it's only used internally, so it could be left out of the interface, no?
> + dQueue( raw_id) :
> + By default, a `BuildFarmJob` has an identifying name of the form
> + "b-q", where b is the id of its `Build` and q is the id of its
> + `BuildQueue` record.
> +
> + Use `getVerifiedBuild` to verify the "b" part, and retrieve the
> + associated `Build`.
> + """
> +
> + def getVerifiedBuil
> + """Verify the `BuildQueue` id component of a slave build id.
Same here.
> + ldQueue` to verify the "q" part, and retrieve dID(slave_ build_id) : buildmaster/ model/buildfarm jobbehavior. py' buildmaster/ model/buildfarm jobbehavior. py 2010-03-05 13:52:32 +0000 buildmaster/ model/buildfarm jobbehavior. py 2010-03-12 13:56:29 +0000 msg=E0211, E0213 roxy, isinstance as zisinstance librarian. interfaces import ILibrarianClient launchpad. webapp. interfaces import NotFoundError interfaces. bui...
> + By default, a `BuildFarmJob` has an identifying name of the form
> + "b-q", where b is the id of its `Build` and q is the id of its
> + `BuildQueue` record.
> +
> + Use `getVerifiedBui
> + the associated `BuildQueue` object.
> + """
> +
> def verifySlaveBuil
> """Verify that a slave's build ID shows no signs of corruption.
>
>
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -1,4 +1,4 @@
> -# Copyright 2009 Canonical Ltd. This software is licensed under the
> +# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
> # GNU Affero General Public License version 3 (see the file LICENSE).
>
> # pylint: disable-
> @@ -17,17 +17,22 @@
> import xmlrpclib
>
> from sqlobject import SQLObjectNotFound
> +
> from zope.component import getUtility
> from zope.interface import implements
> -from zope.security.proxy import removeSecurityProxy
> +from zope.security.proxy import removeSecurityP
>
> from canonical import encoding
> from canonical.
> +
> +from canonical.
> from lp.buildmaster.