Code review comment for lp:~al-maisan/launchpad/disabled-copyarch-519665

Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

On 02/10/2010 06:00 PM, Jeroen T. Vermeulen wrote:
> Review: Needs Fixing code
> I have a few additional notes that Gavin thought were worth adding:
Hello,

thanks for posing these questions, they are all pertinent and good.

> * What did the pre-imp conclude about the problem of re-enabling
> archives? Is it not going to be a problem to un-suspend jobs when
> that happens?
We already have a mechanism that takes care of suspending/un-suspending
binary build jobs when the associated archive is disabled and enabled
respectively.
Please see Archive.enable() and Archive.disable() for more detail.

The problem in this specific case is that the so called copy archives
are instantiated in a disabled state. Hence there is no

    "enabled -> disabled"

state transition for these and their binary build jobs are created in an
unsuspended state which is a bug.

Please note also that the branch at hand enforces the constraint the
binary builds for disabled archives should be (created) suspended
irrespective of archive type (although the problem manifested itself in
a copy archive context).

> * In build_not_pending_and_suspended, the "not" is ambiguous in
> scope. Can't you replace this with two separate checks?
Hmm .. maybe I can name it better. How about

    - build_in_wrong_state() plus
    - an explanation what "wrong" means in the case at hand

> * In production code we check "len(foo) == 0" to check for empty
> lists. But in tests it's nicer to compare "foo == []" so that a
> failure will give more information.
OK. Done.

> * With assertEqual, pass expected value first and actual value
> second! Again, better failure messages.
Oh, yes! Fixed that as well.

Please see also the enclosed incremental diff.

Best regards

--
Muharem Hrnjadovic <email address hidden>
Public key id : B2BBFCFC
Key fingerprint : A5A3 CC67 2B87 D641 103F 5602 219F 6B60 B2BB FCFC

1=== modified file 'lib/lp/soyuz/scripts/tests/test_populatearchive.py'
2--- lib/lp/soyuz/scripts/tests/test_populatearchive.py 2010-02-10 15:54:40 +0000
3+++ lib/lp/soyuz/scripts/tests/test_populatearchive.py 2010-02-11 06:22:10 +0000
4@@ -651,11 +651,11 @@
5
6 def testBuildsPendingAndSuspended(self):
7 """All builds in the new copy archive are pending and suspended."""
8- def build_not_pending_and_suspended(build):
9- """True if the given build is not pending and suspended."""
10- return (
11- build.buildstate != BuildStatus.NEEDSBUILD or
12- build.buildqueue_record.job.status != JobStatus.SUSPENDED)
13+ def build_in_wrong_state(build):
14+ """True if the given build is not (pending and suspended)."""
15+ return not (
16+ build.buildstate == BuildStatus.NEEDSBUILD and
17+ build.buildqueue_record.job.status == JobStatus.SUSPENDED)
18 hoary = getUtility(IDistributionSet)['ubuntu']['hoary']
19
20 # Verify that we have the right source packages in the sample data.
21@@ -667,11 +667,20 @@
22 # Make sure the right source packages were cloned.
23 self._verifyClonedSourcePackages(archive, hoary)
24
25- # Now check that we have the build records expected.
26+ # Get the binary builds generated for the copy archive at hand.
27 builds = list(getUtility(IBuildSet).getBuildsForArchive(archive))
28+ # At least one binary build was generated for the target copy archive.
29 self.assertTrue(len(builds) > 0)
30- wrong_builds = filter(build_not_pending_and_suspended, builds)
31- self.assertEqual(0, len(wrong_builds))
32+ # Now check that the binary builds and their associated job records
33+ # are in the state expected:
34+ # - binary build: pending
35+ # - job: suspended
36+ builds_in_wrong_state = filter(build_in_wrong_state, builds)
37+ self.assertEqual (
38+ [], builds_in_wrong_state,
39+ "The binary builds generated for the target copy archive "
40+ "should all be pending and suspended. However, at least one of "
41+ "the builds is in the wrong state.")
42
43 def testPrivateOriginArchive(self):
44 """Try copying from a private archive.

« Back to merge proposal