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

« back to all changes in this revision

Viewing changes to state/api/upgrader/upgrader_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:
57
57
        c.Assert(upgrader, gc.NotNil)
58
58
}
59
59
 
60
 
func (s *upgraderSuite) TestSetToolsWrongMachine(c *gc.C) {
61
 
        err := s.st.SetTools("42", &tools.Tools{
62
 
                Version: version.Current,
63
 
        })
 
60
func (s *upgraderSuite) TestSetVersionWrongMachine(c *gc.C) {
 
61
        err := s.st.SetVersion("42", version.Current)
64
62
        c.Assert(err, gc.ErrorMatches, "permission denied")
65
63
        c.Assert(err, jc.Satisfies, params.IsCodeUnauthorized)
66
64
}
67
65
 
68
 
func (s *upgraderSuite) TestSetTools(c *gc.C) {
 
66
func (s *upgraderSuite) TestSetVersion(c *gc.C) {
69
67
        cur := version.Current
70
68
        agentTools, err := s.rawMachine.AgentTools()
71
69
        c.Assert(err, jc.Satisfies, errors.IsNotFoundError)
72
70
        c.Assert(agentTools, gc.IsNil)
73
 
        err = s.st.SetTools(s.rawMachine.Tag(), &tools.Tools{Version: cur})
 
71
        err = s.st.SetVersion(s.rawMachine.Tag(), cur)
74
72
        c.Assert(err, gc.IsNil)
75
73
        s.rawMachine.Refresh()
76
74
        agentTools, err = s.rawMachine.AgentTools()
89
87
        cur := version.Current
90
88
        curTools := &tools.Tools{Version: cur, URL: ""}
91
89
        curTools.Version.Minor++
92
 
        s.rawMachine.SetAgentTools(curTools)
 
90
        s.rawMachine.SetAgentVersion(cur)
93
91
        // Upgrader.Tools returns the *desired* set of tools, not the currently
94
92
        // running set. We want to be upgraded to cur.Version
95
93
        stateTools, err := s.st.Tools(s.rawMachine.Tag())
126
124
        cur := version.Current
127
125
        curTools := &tools.Tools{Version: cur, URL: ""}
128
126
        curTools.Version.Minor++
129
 
        s.rawMachine.SetAgentTools(curTools)
 
127
        s.rawMachine.SetAgentVersion(cur)
130
128
        // Upgrader.DesiredVersion returns the *desired* set of tools, not the
131
129
        // currently running set. We want to be upgraded to cur.Version
132
130
        stateVersion, err := s.st.DesiredVersion(s.rawMachine.Tag())