Merge lp://staging/~benji/landscape-client/better-self-signed-cert-ux-3 into lp://staging/~landscape/landscape-client/trunk

Proposed by Benji York
Status: Merged
Approved by: Benji York
Approved revision: 831
Merged at revision: 812
Proposed branch: lp://staging/~benji/landscape-client/better-self-signed-cert-ux-3
Merge into: lp://staging/~landscape/landscape-client/trunk
Diff against target: 1345 lines (+604/-570)
4 files modified
landscape/broker/amp.py (+15/-0)
landscape/configuration.py (+108/-90)
landscape/tests/helpers.py (+1/-0)
landscape/tests/test_configuration.py (+480/-480)
To merge this branch: bzr merge lp://staging/~benji/landscape-client/better-self-signed-cert-ux-3
Reviewer Review Type Date Requested Status
Björn Tillenius (community) Approve
Chris Glass (community) Abstain
Данило Шеган (community) Approve
Review via email: mp+250841@code.staging.launchpad.net

Commit message

This branch is a pure refactoring of the way the client configuration
communicates so as to separate the UI and network code in preparation
for better SSL error handling and user interaction.

Tests were then able to be improved -- but not as far as we would like.

Notes from Chris:

Most of the code breaks out nested function declaration to make them
easier to test, using functools.partial to keep the invocation sane in a
twisted context (test them "flat", use functools to pass closures to
event handlers).

We used manual stubs instead of mocks for readability and personal
preference [of both of us].

Description of the change

This branch is a pure refactoring of the way the client configuration communicates so as to separate the UI and network code in preparation for better SSL error handling and user interaction.

Tests were then able to be improved -- but not as far as we would like.

Notes from Chris:

Most of the code breaks out nested function declaration to make them easier to test, using functools.partial to keep the invocation sane in a twisted context (test them "flat", use functools to pass closures to event handlers).

We used manual stubs instead of mocks for readability and personal preference (of both of us).

To post a comment you must log in.
Revision history for this message
Chris Glass (tribaal) wrote :

Looks good, and seems to work.

The merge description is wrong however - this branch "only" refactors the current code to make it easier to grok and test, but there is currently no functional improvement (that should come in a subsequent branch).

Note (can be used in the change description):
Most of the code breaks out nested function declaration to make them easier to test, using functools.partial to keep the invocation sane in a twisted context (test them "flat", use functools to pass closures to event handlers).

Note 2:
We used manual stubs instead of mocks for readability and personal preference (of both of us).

I'll comment again when I will have performed actual manual tests (give me a couple of hours :) )

Revision history for this message
Benji York (benji) wrote :

> Looks good, and seems to work.
>
> The merge description is wrong however

I've fixed the MP description and incorporated your notes below.

> I'll comment again when I will have performed actual manual tests (give me a
> couple of hours :) )

/me crosses fingers.

Revision history for this message
Chris Glass (tribaal) wrote :

Summary testing succeeded.

+1

review: Approve
Revision history for this message
Данило Шеган (danilo) wrote :

Seems to work fine against my self-signed Landscape. A few comments inline.

I am not too happy with the tests, since you seem to be mostly testing the wiring, and never that it actually works well together. I do understand that coming up with proper tests would require even more work, and with the understanding that this does not make the code base any worse, I am approving it.

Finally, I am not sure it's such a great idea to have Chris do one of the reviews _if_ he has contributed a lot of code/opinions while you were developing this branch. But you guys know best how much his mind is already "tainted" with the approach :)

review: Approve
Revision history for this message
Chris Glass (tribaal) wrote :

I will abstain from this one since I peer-programmed some of it.

review: Abstain
Revision history for this message
Chris Glass (tribaal) wrote :

Good point Danilo, I added another review slot and abstained.

Revision history for this message
Björn Tillenius (bjornt) wrote :

Why couldn't this be broken up into smaller branches?

Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

> Why couldn't this be broken up into smaller branches?

Agreed. I didn't look at the code in detail, but I was expecting to see at least 2 branches: one for the pure refactoring of the registration code and one for adding the new functionality.

Revision history for this message
Chris Glass (tribaal) wrote :

Free, this *is* the pure refactoring branch.

Revision history for this message
Björn Tillenius (bjornt) wrote :

> Free, this *is* the pure refactoring branch.

In that case, the MP description is wrong. It says that more info is provided to the user and more error conditions are handled.

Revision history for this message
Benji York (benji) wrote :

> > Free, this *is* the pure refactoring branch.
>
> In that case, the MP description is wrong. It says that more info is provided
> to the user and more error conditions are handled.

I had some sort of edit failure and didn't get the MP description corrected. It is right now.

Revision history for this message
Benji York (benji) wrote :

> Why couldn't this be broken up into smaller branches?

It surely could have been, but given the nigh untestable nature of the current code structure (even after our refactoring), one large branch was the least risky way to proceed without undue exploratory testing, especially given Chris' upcoming disconnectedness.

Revision history for this message
Benji York (benji) wrote :

> Seems to work fine against my self-signed Landscape. A few comments inline.
>
> I am not too happy with the tests

As are we. Unfortunately, better tests would have required much more refactoring as well as having some place to put integration tests, which were expressly forbid when the idea of adding some to the existing test base was floated.

> Finally, I am not sure it's such a great idea to have Chris do one of the
> reviews _if_ he has contributed a lot of code/opinions while you were
> developing this branch.

Christ has recused himself from the review.

(I am of the opinion that his review would have been fine, given that I am not big on two-person reviews in the first place, and more so if a branch is the result of pair programming -- which this was.)

Revision history for this message
Данило Шеган (danilo) wrote :

Yes, agreed re better tests: I don't think it's worth it.

I am happy about the Christ not having an opinion on this branch :)

As for Chris, pair programming usually does lead to better code, but at the same time can result in two minds agreeing to decisions and never re-questioning them after the original agreement (I've been guilty of the same thing).

Anyway, my overall assesement is that this is improvement over the existing code (and tests are no worse) which is reflected in my approval :)

Revision history for this message
Benji York (benji) wrote :

Thanks for the good review Danilo. I fixed the things you pointed out inline. I also noticed some of the pre-existing tests were generating output to stdout, so I corrected those.

Revision history for this message
Björn Tillenius (bjornt) wrote :

Sorry, I won't have time to finish this review before my EOD. I added some initial comments inline.

Revision history for this message
Björn Tillenius (bjornt) wrote :

Ok, I have had time to look at this branch more closely now. How would you feel if I put it in Needs Fixing and requested you to rewrite the tests?

I understand that it's some work doing that, and that fakes are a small improvement over mocking, but the emphasis is on small here. The way you use fakes makes it very similar to mocking. It's still easier to read, but you're still testing the that the code is written in the same way the tests expects them to be.

I would rather that the tests were a bit more functional, in that you set up the conditions, then call register() and check what it returns. I don't care how the deferreds are set up internally. What I care about is that register() returns "success" when the registration succeeds.

It's not quite trivial, but here's an example of a test that checks that register() returns "success" when the registration is successful:

  https://pastebin.canonical.com/126660/

What do you think?

review: Needs Information
Revision history for this message
Benji York (benji) wrote :

> What do you think?

I haven't taken the time to look deeply into your proposed test approach, but I agree with everything you said. Unfortunately, the amount of time invested in this branch thus far means that the size of the marginal improvement must be very large for it to be worth it and regrettably, that's not the case.

I plan on keeping the test approach in mind for the next time we work on this code (which I hope is soon, it needs quite a bit of help).

Thank you for the review.

Revision history for this message
Björn Tillenius (bjornt) wrote :

Ok, I won't push too hard on adding better tests, since the existing tests weren't great either. But the old tests did actually tests that the async machinery really works, which your tests don't. So I would like you to at least add the test that I pasted, so you have one test that does end-to-end testing.

I'd also like you to respond to the inline comments I added here, as well as those I added previously, and push the latest revision please. I still don't see the changes you did in response to Danilo's comments.

Revision history for this message
Benji York (benji) :
827. By Benji York

docstring all the things

828. By Benji York

remove duplicate and redundant assertion

829. By Benji York

- add tests for reporting registration result to the user
- fix up tests that print to stdout so they won't

Revision history for this message
Benji York (benji) wrote :

> [...] So I would like you to at
> least add the test that I pasted, so you have one test that does end-to-end
> testing.

Done. (BTW, that diff was odd. I'm curious how you generated it. I had to hand apply it.)

> I'd also like you to respond to the inline comments I added here, as well as
> those I added previously

Done.

> and push the latest revision please.

Done.

Revision history for this message
Björn Tillenius (bjornt) wrote :

Sorry for being a pain :) But the latest diff isn't what I would expect it to be. It lacks at least one change that you said you would do (I added an inline comment), and the test I added isn't there. Instead you added a bunch of other tests that do mocking and seem redundant?

BTW, maybe the patch was odd because you looked at the wrong pastebin? ;) Although, the patch could look odd since I based it on what you pushed. Actually, looking at what you pushed, it's quite clear that you didn't push the changes you did in reply to my comments. You pushed revisions from Feb 26.

Please make it a habit to always push the latest code to LP. It's a bit complicated to review the branch when you know that there are other changes that you can't see.

830. By Benji York

- add a test that runs register() in a more full-boddied way
- use Twisted parameter passing functionality instead of partials
  - tweak parameter order to account for different calling style
- add and improve motivational comments around test assertions
- fix a test assertion that was unreachable

Revision history for this message
Benji York (benji) wrote :

> Sorry for being a pain :) But the latest diff isn't what I would expect it to
> be.

I pushed, but apparently forgot to commit beforehand.

> BTW, maybe the patch was odd because you looked at the wrong pastebin? ;)

This is the pastebin I was referring to: https://pastebin.canonical.com/126660/

The oddities I see are the blank lines with a dot in the indicator position and the lack of whitespace after the file name in the headers.

Revision history for this message
Björn Tillenius (bjornt) wrote :

Ok, let's get this branch landed now!

> This is the pastebin I was referring to: https://pastebin.canonical.com/126660/
>
> The oddities I see are the blank lines with a dot in the indicator position and the lack of
> whitespace after the file name in the headers.

Oh, that is odd indeed. I've never seen that before, but it seems to be since I copied
it from 'bzr diff | vim -' and the diff highlighter adds those periods.

review: Approve
831. By Benji York

merge from trunk

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.

Subscribers

People subscribed via source and target branches

to all changes: