I have a few comments about the tests which you can take or
leave. Other than that, all good as far as I can tell :)
Gavin.
[...]
> === added file 'lib/lp/soyuz/tests/test_builder.py'
> --- lib/lp/soyuz/tests/test_builder.py 1970-01-01 00:00:00 +0000
> +++ lib/lp/soyuz/tests/test_builder.py 2009-10-14 10:55:53 +0000
> @@ -0,0 +1,116 @@
> +# Copyright 2009 Canonical Ltd. This software is licensed under the
> +# GNU Affero General Public License version 3 (see the file LICENSE).
> +
> +"""Test Builder features."""
> +
> +import unittest
> +
> +from zope.component import getUtility
> +
> +from canonical.testing import LaunchpadZopelessLayer
> +from lp.soyuz.interfaces.archive import ArchivePurpose
> +from lp.soyuz.interfaces.builder import IBuilderSet
> +from lp.soyuz.interfaces.build import BuildStatus
> +from lp.soyuz.interfaces.publishing import PackagePublishingStatus
> +from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
> +from lp.testing import TestCaseWithFactory
> +
> +
> +class TestFindBuildCandidate(TestCaseWithFactory):
> +
> + layer = LaunchpadZopelessLayer
> +
> + def setUp(self):
> + """Publish some builds for the test archive."""
> + super(TestFindBuildCandidate, self).setUp()
> + self.publisher = SoyuzTestPublisher()
> + self.publisher.prepareBreezyAutotest()
> +
> + # Create two PPAs and add some builds to each.
> + self.ppa_joe = self.factory.makeArchive(name="joesppa")
> + self.ppa_jim = self.factory.makeArchive(name="jimsppa")
> +
> + self.publisher.getPubSource(
> + sourcename="gedit", status=PackagePublishingStatus.PUBLISHED,
> + archive=self.ppa_joe).createMissingBuilds()
> + self.publisher.getPubSource(
> + sourcename="firefox", status=PackagePublishingStatus.PUBLISHED,
> + archive=self.ppa_joe).createMissingBuilds()
> +
> + self.publisher.getPubSource(
> + sourcename="gedit", status=PackagePublishingStatus.PUBLISHED,
> + archive=self.ppa_jim).createMissingBuilds()
> + self.publisher.getPubSource(
> + sourcename="firefox", status=PackagePublishingStatus.PUBLISHED,
> + archive=self.ppa_jim).createMissingBuilds()
> +
> + # Create two i386 builders ready to build PPA builds.
> + builder_set = getUtility(IBuilderSet)
> + self.builder1 = self.factory.makeBuilder(name='bob2')
> + self.builder2 = self.factory.makeBuilder(name='frog2')
> +
> + # Grab the first build, ensure that it is what we expect
> + # (ie. the first build from joesppa) and set it building.
> + self.first_job = self.builder1.findBuildCandidate()
> + self.failUnlessEqual('joesppa', self.first_job.build.archive.name)
> + self.failUnlessEqual(
> + u'i386 build of gedit 666 in ubuntutest breezy-autotest RELEASE',
> + self.first_job.build.title)
> + self.first_job.build.buildstate = BuildStatus.BUILDING
> + self.first_job.build.builder = self.builder1
That looks like a lot of set-up. If there's anything there that's
specific to only one test_* method, consider moving it out.
> +
> + def test_findBuildCandidate_first_build_started(self):
> + # Once a build for an ppa+arch has started, a second one for the
> + # same ppa+arch will not be a candidate.
> + next_job = self.builder2.findBuildCandidate()
> + self.failIfEqual('joesppa', next_job.build.archive.name)
> +
> + def test_findBuildCandidate_first_build_finished(self):
> + # When joe's first ppa build finishes, his second i386 build
> + # will be the next build candidate.
> + self.first_job.build.buildstate = BuildStatus.FAILEDTOBUILD
> + next_job = self.builder2.findBuildCandidate()
> + self.failUnlessEqual('joesppa', next_job.build.archive.name)
> +
> + def test_findBuildCandidate_for_private_ppa(self):
> + # If a ppa is private it will be able to have parallel builds
> + # for the one architecture.
> + self.ppa_joe.private = True
> + self.ppa_joe.buildd_secret = 'sekrit'
> + next_job = self.builder2.findBuildCandidate()
> + self.failUnlessEqual('joesppa', next_job.build.archive.name)
> +
> + def test_findBuildCandidate_for_non_ppa(self):
> + # Normal archives are not restricted to serial builds per
> + # arch.
> + non_ppa = self.factory.makeArchive(
> + name="primary", purpose=ArchivePurpose.PRIMARY)
> +
> + gedit_build = self.publisher.getPubSource(
> + sourcename="gedit", status=PackagePublishingStatus.PUBLISHED,
> + archive=non_ppa).createMissingBuilds()[0]
> + firefox_build = self.publisher.getPubSource(
> + sourcename="firefox", status=PackagePublishingStatus.PUBLISHED,
> + archive=non_ppa).createMissingBuilds()[0]
> +
> + # Rescore our primary builds so that they'll be returned before
> + # the PPA ones.
> + gedit_build.buildqueue_record.manualScore(3000)
> + firefox_build.buildqueue_record.manualScore(3000)
> +
> + next_job = self.builder2.findBuildCandidate()
> + self.failUnlessEqual('primary', next_job.build.archive.name)
> + self.failUnlessEqual(
> + 'gedit', next_job.build.sourcepackagerelease.name)
> +
> + # Now even if we set the build building, we'll still get the
> + # second non-ppa build for the same archive as the next candidate.
> + next_job.build.buildstate = BuildStatus.BUILDING
> + next_job.build.builder = self.builder2
> + next_job = self.builder2.findBuildCandidate()
> + self.failUnlessEqual('primary', next_job.build.archive.name)
> + self.failUnlessEqual(
> + 'firefox', next_job.build.sourcepackagerelease.name)
Ah, a lot of that looks similar to what's in setUp(). Maybe split
these out into two TestCases, one for PPAs, one for other archives? Or
is the rescoring stuff relevant? (Sorry for my continued Soyuz
ignorance.)
Hi Michael,
I have a few comments about the tests which you can take or
leave. Other than that, all good as far as I can tell :)
Gavin.
[...] soyuz/tests/ test_builder. py' soyuz/tests/ test_builder. py 1970-01-01 00:00:00 +0000 soyuz/tests/ test_builder. py 2009-10-14 10:55:53 +0000 ssLayer interfaces. archive import ArchivePurpose interfaces. builder import IBuilderSet interfaces. build import BuildStatus interfaces. publishing import PackagePublishi ngStatus tests.test_ publishing import SoyuzTestPublisher ndidate( TestCaseWithFac tory): ssLayer uildCandidate, self).setUp() her() prepareBreezyAu totest( ) makeArchive( name="joesppa" ) makeArchive( name="jimsppa" ) getPubSource( PackagePublishi ngStatus. PUBLISHED, self.ppa_ joe).createMiss ingBuilds( ) getPubSource( "firefox" , status= PackagePublishi ngStatus. PUBLISHED, self.ppa_ joe).createMiss ingBuilds( ) getPubSource( PackagePublishi ngStatus. PUBLISHED, self.ppa_ jim).createMiss ingBuilds( ) getPubSource( "firefox" , status= PackagePublishi ngStatus. PUBLISHED, self.ppa_ jim).createMiss ingBuilds( ) IBuilderSet) makeBuilder( name='bob2' ) makeBuilder( name='frog2' ) findBuildCandid ate() Equal(' joesppa' , self.first_ job.build. archive. name) Equal( job.build. title) job.build. buildstate = BuildStatus. BUILDING job.build. builder = self.builder1
> === added file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -0,0 +1,116 @@
> +# Copyright 2009 Canonical Ltd. This software is licensed under the
> +# GNU Affero General Public License version 3 (see the file LICENSE).
> +
> +"""Test Builder features."""
> +
> +import unittest
> +
> +from zope.component import getUtility
> +
> +from canonical.testing import LaunchpadZopele
> +from lp.soyuz.
> +from lp.soyuz.
> +from lp.soyuz.
> +from lp.soyuz.
> +from lp.soyuz.
> +from lp.testing import TestCaseWithFactory
> +
> +
> +class TestFindBuildCa
> +
> + layer = LaunchpadZopele
> +
> + def setUp(self):
> + """Publish some builds for the test archive."""
> + super(TestFindB
> + self.publisher = SoyuzTestPublis
> + self.publisher.
> +
> + # Create two PPAs and add some builds to each.
> + self.ppa_joe = self.factory.
> + self.ppa_jim = self.factory.
> +
> + self.publisher.
> + sourcename="gedit", status=
> + archive=
> + self.publisher.
> + sourcename=
> + archive=
> +
> + self.publisher.
> + sourcename="gedit", status=
> + archive=
> + self.publisher.
> + sourcename=
> + archive=
> +
> + # Create two i386 builders ready to build PPA builds.
> + builder_set = getUtility(
> + self.builder1 = self.factory.
> + self.builder2 = self.factory.
> +
> + # Grab the first build, ensure that it is what we expect
> + # (ie. the first build from joesppa) and set it building.
> + self.first_job = self.builder1.
> + self.failUnless
> + self.failUnless
> + u'i386 build of gedit 666 in ubuntutest breezy-autotest RELEASE',
> + self.first_
> + self.first_
> + self.first_
That looks like a lot of set-up. If there's anything there that's
specific to only one test_* method, consider moving it out.
> + andidate_ first_build_ started( self): findBuildCandid ate() l('joesppa' , next_job. build.archive. name) andidate_ first_build_ finished( self): job.build. buildstate = BuildStatus. FAILEDTOBUILD findBuildCandid ate() Equal(' joesppa' , next_job. build.archive. name) andidate_ for_private_ ppa(self) : joe.private = True joe.buildd_ secret = 'sekrit' findBuildCandid ate() Equal(' joesppa' , next_job. build.archive. name) andidate_ for_non_ ppa(self) : makeArchive( ArchivePurpose. PRIMARY) getPubSource( PackagePublishi ngStatus. PUBLISHED, non_ppa) .createMissingB uilds() [0] getPubSource( "firefox" , status= PackagePublishi ngStatus. PUBLISHED, non_ppa) .createMissingB uilds() [0] buildqueue_ record. manualScore( 3000) build.buildqueu e_record. manualScore( 3000) findBuildCandid ate() Equal(' primary' , next_job. build.archive. name) Equal( build.sourcepac kagerelease. name) build.buildstat e = BuildStatus. BUILDING build.builder = self.builder2 findBuildCandid ate() Equal(' primary' , next_job. build.archive. name) Equal( build.sourcepac kagerelease. name)
> + def test_findBuildC
> + # Once a build for an ppa+arch has started, a second one for the
> + # same ppa+arch will not be a candidate.
> + next_job = self.builder2.
> + self.failIfEqua
> +
> + def test_findBuildC
> + # When joe's first ppa build finishes, his second i386 build
> + # will be the next build candidate.
> + self.first_
> + next_job = self.builder2.
> + self.failUnless
> +
> + def test_findBuildC
> + # If a ppa is private it will be able to have parallel builds
> + # for the one architecture.
> + self.ppa_
> + self.ppa_
> + next_job = self.builder2.
> + self.failUnless
> +
> + def test_findBuildC
> + # Normal archives are not restricted to serial builds per
> + # arch.
> + non_ppa = self.factory.
> + name="primary", purpose=
> +
> + gedit_build = self.publisher.
> + sourcename="gedit", status=
> + archive=
> + firefox_build = self.publisher.
> + sourcename=
> + archive=
> +
> + # Rescore our primary builds so that they'll be returned before
> + # the PPA ones.
> + gedit_build.
> + firefox_
> +
> + next_job = self.builder2.
> + self.failUnless
> + self.failUnless
> + 'gedit', next_job.
> +
> + # Now even if we set the build building, we'll still get the
> + # second non-ppa build for the same archive as the next candidate.
> + next_job.
> + next_job.
> + next_job = self.builder2.
> + self.failUnless
> + self.failUnless
> + 'firefox', next_job.
Ah, a lot of that looks similar to what's in setUp(). Maybe split
these out into two TestCases, one for PPAs, one for other archives? Or
is the rescoring stuff relevant? (Sorry for my continued Soyuz
ignorance.)
> + TestLoader( ).loadTestsFrom Name(__ name__)
> +def test_suite():
> + return unittest.
>
[...]