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

« back to all changes in this revision

Viewing changes to state/state_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:
24
24
        statetesting "launchpad.net/juju-core/state/testing"
25
25
        "launchpad.net/juju-core/testing"
26
26
        jc "launchpad.net/juju-core/testing/checkers"
27
 
        "launchpad.net/juju-core/tools"
28
27
        "launchpad.net/juju-core/version"
29
28
)
30
29
 
449
448
                c.Assert(err, gc.IsNil)
450
449
                err = m.SetProvisioned(instance.Id(fmt.Sprintf("foo-%d", i)), "fake_nonce", nil)
451
450
                c.Assert(err, gc.IsNil)
452
 
                err = m.SetAgentTools(newTools("7.8.9-foo-bar", "http://arble.tgz"))
 
451
                err = m.SetAgentVersion(version.MustParseBinary("7.8.9-foo-bar"))
453
452
                c.Assert(err, gc.IsNil)
454
453
                err = m.Destroy()
455
454
                c.Assert(err, gc.IsNil)
463
462
                c.Assert(string(instId), gc.Equals, fmt.Sprintf("foo-%d", i))
464
463
                tools, err := m.AgentTools()
465
464
                c.Check(err, gc.IsNil)
466
 
                c.Check(tools, gc.DeepEquals, newTools("7.8.9-foo-bar", "http://arble.tgz"))
 
465
                c.Check(tools.Version, gc.DeepEquals, version.MustParseBinary("7.8.9-foo-bar"))
467
466
                c.Assert(m.Life(), gc.Equals, state.Dying)
468
467
        }
469
468
}
1078
1077
        wc.AssertOneChange()
1079
1078
 
1080
1079
        // Alter the machine: not reported.
1081
 
        tools := &tools.Tools{
1082
 
                Version: version.Binary{
1083
 
                        Number: version.MustParse("1.2.3"),
1084
 
                        Series: "gutsy",
1085
 
                        Arch:   "ppc",
1086
 
                },
1087
 
                URL:    "http://canonical.com/",
1088
 
                Size:   10,
1089
 
                SHA256: "1234",
1090
 
        }
1091
 
        err = machine.SetAgentTools(tools)
 
1080
        vers := version.MustParseBinary("1.2.3-gutsy-ppc")
 
1081
        err = machine.SetAgentVersion(vers)
1092
1082
        c.Assert(err, gc.IsNil)
1093
1083
        wc.AssertNoChange()
1094
1084
}