Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(18832)

Issue 11034044: Azure provider: Destroy() and StopInstances().

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 9 months ago by rvb
Modified:
10 years, 9 months ago
Reviewers:
mp+173657, jtv.canonical, jameinel
Visibility:
Public.

Description

Azure provider: Destroy() and StopInstances(). This branch implements environ's Destroy() and StopInstances() in the Azure provider. As always with the provider code, most of the non-obvious code is in the tests. Since the testing utilities provided by gwacl return a slice of the fake requests made, it's tempting to make an extensive usage of that information and basically duplicate the unit-tests for the called gwacl methods. Instead of doing that, I chose a middle ground and checked that the requests look right without going too deep; this should be sufficient to test that the provider methods have the expected behavior and get tests to fail if the gwacl methods change significantly. https://code.launchpad.net/~rvb/juju-core/az-destroy/+merge/173657 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 22
Unified diffs Side-by-side diffs Delta from patch set Stats (+228 lines, -7 lines) Patch
A [revision details] View 1 chunk +2 lines, -0 lines 0 comments Download
M environs/azure/environ.go View 2 chunks +62 lines, -4 lines 6 comments Download
M environs/azure/environ_test.go View 4 chunks +164 lines, -3 lines 16 comments Download

Messages

Total messages: 6
rvb
Please take a look.
10 years, 9 months ago (2013-07-09 07:06:44 UTC) #1
jameinel
I don't think you have to change this, but there are a couple bits that ...
10 years, 9 months ago (2013-07-09 08:00:44 UTC) #2
jtv.canonical
LGTM, thoroughly tested, but as always a few notes still. https://codereview.appspot.com/11034044/diff/1/environs/azure/environ.go File environs/azure/environ.go (right): https://codereview.appspot.com/11034044/diff/1/environs/azure/environ.go#newcode134 ...
10 years, 9 months ago (2013-07-09 09:05:34 UTC) #3
rvb
On 2013/07/09 09:05:34, jtv.canonical wrote: > LGTM, thoroughly tested, but as always a few notes ...
10 years, 9 months ago (2013-07-09 10:12:41 UTC) #4
jtv.canonical
On 2013/07/09 10:12:41, rvb wrote: > https://codereview.appspot.com/11034044/diff/1/environs/azure/environ_test.go#newcode351 > > environs/azure/environ_test.go:351: // When destroying a hosted ...
10 years, 9 months ago (2013-07-09 10:35:29 UTC) #5
rvb
10 years, 9 months ago (2013-07-09 13:46:52 UTC) #6
Thanks for the review!

On 2013/07/09 08:00:44, jameinel wrote:
> I don't think you have to change this, but there are a couple bits that might
> make it easier to support.
> 
> 'makeService' is a bit confusing because Juju has a 'service' concept. So
> clarifying what you are creating here would be nice.

Good point, I've renamed all the helpers (for instance
s/makeService/makeAzureService).

> Just asserting that we call GET seems a bit weak, vs at least asserting what
> *type* of thing you are GETing.

You're right, I've improved the tests to check that they target the right
objects.

> I do still prefer the double approach to the mocking-HTTP requests. Mostly
> because when you do change gwacl to fix things, it can easily break the
> juju-core test suite without the juju-core code itself actually being
incorrect.
> (eg you discover that you know enough that you can just DELETE the services
> without needing to GET their details first.)

This is a bit late for this and we deliberately choose not to do a test double
in gwacl.  This saves a lot of code in gwacl but the drawback is that some of
gwacl's internal leak into the tests of third party applications, such as the
juju provider, which use gwacl.  Again, this is a tradeoff and the main goal is
to allow us to move quickly.  It maintenance is easier this way, once this is
all stabilized (I'm talking about gwacl here and how we map Juju services onto
gwacl objects), it might be good to move to a model where all the tests will be
based on a test double.


> 
>
https://codereview.appspot.com/11034044/diff/1/environs/azure/environ_test.go...
> environs/azure/environ_test.go:351: // When destroying a hosted service, gwacl
> first issues a Get reques
> typo: request

Fixed.

>
https://codereview.appspot.com/11034044/diff/1/environs/azure/environ_test.go...
> environs/azure/environ_test.go:390: responses :=
buildDestroyServiceResponses(c,
> services)
> How does this match up with the 1 instance == 1 service model that JTV has
> brought up might be changing?

This works under that assumption, you're right… I've added a comment in the code
(the actual code for StopInstances, not the test code).
 
> Given that Juju has its own notion of what a service is, maybe the helper
could
> be "makeAzureService" to distinguish and avoid confusion?

Done.

>
https://codereview.appspot.com/11034044/diff/1/environs/azure/environ_test.go...
> environs/azure/environ_test.go:403: c.Check((*requests)[3].Method, Equals,
> "DELETE")
> It feels like this could use slightly more assertion if we are going to do it
> this way.
> Specifically that we are GET and or DELETE a service (somehow the "service1"
is
> in the content, or something). To handle the "I wanted to delete a service,
but
> I actually just deleted an instance" or something along those lines.
> 
>
https://codereview.appspot.com/11034044/diff/1/environs/azure/environ_test.go...
> environs/azure/environ_test.go:456:
> c.Check(strings.HasSuffix(transport.Exchanges[2].Request.URL.String(),
> "blob-2"), IsTrue)
> Like this one is actually asserting that you are DELETEing something "blob-1"
> related. (Otherwise this test could have passed if you just DELETE services.)
> 
>
https://codereview.appspot.com/11034044/diff/1/environs/azure/environ_test.go...
> environs/azure/environ_test.go:496: c.Check((*requests), HasLen,
> 1+len(services)*2)
> So I think what I'd like to see is not testing of the formatting of the
requests
> (that belongs in lp:gwacl), but slightly more sanity checking than just GET.
So
> something that shows it is a GET of all instances, and then a GET + DELETE of
a
> given service, etc.

Fixed.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b