~rogpeppe/juju-core/438-local-instance-Addresses

« back to all changes in this revision

Viewing changes to state/api/provisioner/provisioner_test.go

[r=fwereade],[bug=1234035] Fix upgrade 1.14 -> 1.15

This adds a Tools() API call to provisioner API,
similarly to the upgrader API. Common code factored
out into apiserver/common/tools.go.

SetAgentTools() renamed to SetAgentVersion() in
machine and unit state types. Also renamed a few
types in params to be shorter or better reflect
what are they about. Added DEPRECATE(v1.18) tags
to bits of the API that need cleanup.

Live tested on EC2 - after copying the tools from
/tools/releases/ to /tools/ the upgrade proceeds
and finishes successfully.

https://codereview.appspot.com/14231044/

R=fwereade, jameinel

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
        statetesting "launchpad.net/juju-core/state/testing"
21
21
        coretesting "launchpad.net/juju-core/testing"
22
22
        jc "launchpad.net/juju-core/testing/checkers"
 
23
        "launchpad.net/juju-core/tools"
 
24
        "launchpad.net/juju-core/version"
23
25
)
24
26
 
25
27
func TestAll(t *stdtesting.T) {
360
362
        c.Assert(err, gc.IsNil)
361
363
        c.Assert(caCert, gc.DeepEquals, s.State.CACert())
362
364
}
 
365
 
 
366
func (s *provisionerSuite) TestToolsWrongMachine(c *gc.C) {
 
367
        tools, err := s.provisioner.Tools("42")
 
368
        c.Assert(err, gc.ErrorMatches, "permission denied")
 
369
        c.Assert(err, jc.Satisfies, params.IsCodeUnauthorized)
 
370
        c.Assert(tools, gc.IsNil)
 
371
}
 
372
 
 
373
func (s *provisionerSuite) TestTools(c *gc.C) {
 
374
        cur := version.Current
 
375
        curTools := &tools.Tools{Version: cur, URL: ""}
 
376
        curTools.Version.Minor++
 
377
        s.machine.SetAgentVersion(cur)
 
378
        // Provisioner.Tools returns the *desired* set of tools, not the
 
379
        // currently running set. We want to be upgraded to cur.Version
 
380
        stateTools, err := s.provisioner.Tools(s.machine.Tag())
 
381
        c.Assert(err, gc.IsNil)
 
382
        c.Assert(stateTools.Version, gc.Equals, cur)
 
383
        c.Assert(stateTools.URL, gc.Not(gc.Equals), "")
 
384
}