Merge lp:~axwalk/juju-core/lp1246983-cli-api-resolved into lp:~go-bot/juju-core/trunk

Proposed by Andrew Wilkins
Status: Merged
Approved by: Andrew Wilkins
Approved revision: no longer in the source branch.
Merged at revision: 2029
Proposed branch: lp:~axwalk/juju-core/lp1246983-cli-api-resolved
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 63 lines (+17/-13)
2 files modified
cmd/juju/resolved.go (+6/-10)
state/apiserver/client/client_test.go (+11/-3)
To merge this branch: bzr merge lp:~axwalk/juju-core/lp1246983-cli-api-resolved
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+193564@code.launchpad.net

Commit message

cmd/juju: use API for resolved

Partially fixes #1246983

https://codereview.appspot.com/20670044/

Description of the change

cmd/juju: use API for resolved

Partially fixes #1246983

https://codereview.appspot.com/20670044/

To post a comment you must log in.
Revision history for this message
Andrew Wilkins (axwalk) wrote :

Reviewers: mp+193564_code.launchpad.net,

Message:
Please take a look.

Description:
cmd/juju: use API for resolved

Partially fixes #1246983

https://code.launchpad.net/~axwalk/juju-core/lp1246983-cli-api-resolved/+merge/193564

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/20670044/

Affected files (+8, -10 lines):
   [revision details]
   cmd/juju/resolved.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-20131031053536-8t30819l7xwprtxb
+New revision: <email address hidden>

Index: cmd/juju/resolved.go
=== modified file 'cmd/juju/resolved.go'
--- cmd/juju/resolved.go 2013-08-13 19:07:35 +0000
+++ cmd/juju/resolved.go 2013-11-01 09:26:22 +0000
@@ -48,14 +48,10 @@
  }

  func (c *ResolvedCommand) Run(_ *cmd.Context) error {
- conn, err := juju.NewConnFromName(c.EnvName)
- if err != nil {
- return err
- }
- defer conn.Close()
- unit, err := conn.State.Unit(c.UnitName)
- if err != nil {
- return err
- }
- return unit.Resolve(c.Retry)
+ client, err := juju.NewAPIClientFromName(c.EnvName)
+ if err != nil {
+ return err
+ }
+ defer client.Close()
+ return client.Resolved(c.UnitName, c.Retry)
  }

Revision history for this message
John A Meinel (jameinel) wrote :

This code is nice and straightforward, but because I was digging around
with the other test changes, I noticed that the tests of the API don't
actually exercise the Retry logic.

I'm not going to block landing this on writing those tests, because you
aren't *reducing* test coverage at all. But could you try to add some
coverage while we're away from it?

If the test is too fiddly or time consuming, file a tech-debt bug, link
to it in the source code and you can land this.

https://codereview.appspot.com/20670044/

Revision history for this message
Andrew Wilkins (axwalk) wrote :

On 2013/11/02 20:30:56, john2 wrote:
> This code is nice and straightforward, but because I was digging
around with the
> other test changes, I noticed that the tests of the API don't actually
exercise
> the Retry logic.

> I'm not going to block landing this on writing those tests, because
you aren't
> *reducing* test coverage at all. But could you try to add some
coverage while
> we're away from it?

> If the test is too fiddly or time consuming, file a tech-debt bug,
link to it in
> the source code and you can land this.

I've expanded TestClientUnitResolved to ensure that if retry is true,
the correct resolved mode is set.

https://codereview.appspot.com/20670044/

Revision history for this message
Andrew Wilkins (axwalk) wrote :
Revision history for this message
John A Meinel (jameinel) wrote :

LGTM

https://codereview.appspot.com/20670044/diff/20001/state/apiserver/client/client_test.go
File state/apiserver/client/client_test.go (right):

https://codereview.appspot.com/20670044/diff/20001/state/apiserver/client/client_test.go#newcode375
state/apiserver/client/client_test.go:375: }}
I would actually say that this is a case where having 2 tests is clearer
about what is going on. Possibly a helper function that takes the
parameters if there is too much repeated code.

But meh, good enough.

https://codereview.appspot.com/20670044/

Revision history for this message
Andrew Wilkins (axwalk) wrote :

https://codereview.appspot.com/20670044/diff/20001/state/apiserver/client/client_test.go
File state/apiserver/client/client_test.go (right):

https://codereview.appspot.com/20670044/diff/20001/state/apiserver/client/client_test.go#newcode375
state/apiserver/client/client_test.go:375: }}
On 2013/11/05 04:43:13, jameinel wrote:
> I would actually say that this is a case where having 2 tests is
clearer about
> what is going on. Possibly a helper function that takes the parameters
if there
> is too much repeated code.

Agreed; changing to two tests.

> But meh, good enough.

https://codereview.appspot.com/20670044/

Revision history for this message
Go Bot (go-bot) wrote :

Attempt to merge into lp:juju-core failed due to conflicts:

text conflict in state/apiserver/client/client_test.go

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmd/juju/resolved.go'
2--- cmd/juju/resolved.go 2013-08-13 19:07:35 +0000
3+++ cmd/juju/resolved.go 2013-11-05 05:12:50 +0000
4@@ -48,14 +48,10 @@
5 }
6
7 func (c *ResolvedCommand) Run(_ *cmd.Context) error {
8- conn, err := juju.NewConnFromName(c.EnvName)
9- if err != nil {
10- return err
11- }
12- defer conn.Close()
13- unit, err := conn.State.Unit(c.UnitName)
14- if err != nil {
15- return err
16- }
17- return unit.Resolve(c.Retry)
18+ client, err := juju.NewAPIClientFromName(c.EnvName)
19+ if err != nil {
20+ return err
21+ }
22+ defer client.Close()
23+ return client.Resolved(c.UnitName, c.Retry)
24 }
25
26=== modified file 'state/apiserver/client/client_test.go'
27--- state/apiserver/client/client_test.go 2013-11-05 04:13:50 +0000
28+++ state/apiserver/client/client_test.go 2013-11-05 05:12:50 +0000
29@@ -448,7 +448,7 @@
30 }
31 }
32
33-func (s *clientSuite) TestClientUnitResolved(c *gc.C) {
34+func (s *clientSuite) testClientUnitResolved(c *gc.C, retry bool, expectedResolvedMode state.ResolvedMode) {
35 // Setup:
36 s.setUpScenario(c)
37 u, err := s.State.Unit("wordpress/0")
38@@ -456,7 +456,7 @@
39 err = u.SetStatus(params.StatusError, "gaaah", nil)
40 c.Assert(err, gc.IsNil)
41 // Code under test:
42- err = s.APIState.Client().Resolved("wordpress/0", false)
43+ err = s.APIState.Client().Resolved("wordpress/0", retry)
44 c.Assert(err, gc.IsNil)
45 // Freshen the unit's state.
46 err = u.Refresh()
47@@ -464,7 +464,15 @@
48 // And now the actual test assertions: we set the unit as resolved via
49 // the API so it should have a resolved mode set.
50 mode := u.Resolved()
51- c.Assert(mode, gc.Equals, state.ResolvedNoHooks)
52+ c.Assert(mode, gc.Equals, expectedResolvedMode)
53+}
54+
55+func (s *clientSuite) TestClientUnitResolved(c *gc.C) {
56+ s.testClientUnitResolved(c, false, state.ResolvedNoHooks)
57+}
58+
59+func (s *clientSuite) TestClientUnitResolvedRetry(c *gc.C) {
60+ s.testClientUnitResolved(c, true, state.ResolvedRetryHooks)
61 }
62
63 func (s *clientSuite) TestClientServiceDeployCharmErrors(c *gc.C) {

Subscribers

People subscribed via source and target branches

to status/vote changes: