Merge lp://qastaging/~allenap/maas/log-power-on-a-bit-later into lp://qastaging/~maas-committers/maas/trunk

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 3153
Proposed branch: lp://qastaging/~allenap/maas/log-power-on-a-bit-later
Merge into: lp://qastaging/~maas-committers/maas/trunk
Diff against target: 104 lines (+25/-24)
2 files modified
src/provisioningserver/rpc/power.py (+3/-4)
src/provisioningserver/rpc/tests/test_power.py (+22/-20)
To merge this branch: bzr merge lp://qastaging/~allenap/maas/log-power-on-a-bit-later
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+236629@code.qastaging.launchpad.net

Commit message

Only log the start of a power change in change_power_state().

Previously it was logged in maybe_change_power_state().

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

The change itself makes sense, but I'm lost with the test.

Before I go into my main question with the test: when injecting unhandled exceptions, I'd recommend creating an ad-hoc exception class over just picking an existing exception class. Otherwise the reader is left wondering if your choice of exception has any significance. For a while I was wondering why you seemed to be saying that division was difficult, and I still don't see what you mean by “This doesn't get any easier”!

But now the main thing. How does the test establish that power_change_starting is called “first”? I don't see anything to prove that anything else doesn't happen before the exception. That must have been the purpose of the cheating that your comment mentions, so did you forget a check?

review: Needs Fixing
Revision history for this message
Gavin Panella (allenap) wrote :

> The change itself makes sense, but I'm lost with the test.
>
> Before I go into my main question with the test: when injecting
> unhandled exceptions, I'd recommend creating an ad-hoc exception class
> over just picking an existing exception class. Otherwise the reader is
> left wondering if your choice of exception has any significance. For a
> while I was wondering why you seemed to be saying that division was
> difficult, and I still don't see what you mean by “This doesn't get
> any easier”!

Okay, good point, done.

>
> But now the main thing. How does the test establish that
> power_change_starting is called “first”? I don't see anything to prove
> that anything else doesn't happen before the exception. That must have
> been the purpose of the cheating that your comment mentions, so did
> you forget a check?

That it's called first isn't /that/ interesting, just that it's called
early on. I've added some comments to explain what the intent is, and
I've changed the name of the test. The sentinel argument values lend
some weight to "happens early on" because they would probably cause
failures later on in the change_power_state(). The comments also explain
that the exception "cheat" also avoids doing set-up for later parts of
change_power_state(), again lending weight to "happens early on".

Thanks!

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Wonderful, thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.