~rogpeppe/juju-core/128-jujud-bootstrap-do-not-use-bootstrapped-environment

« back to all changes in this revision

Viewing changes to cmd/jujud/bootstrap_test.go

  • Committer: Roger Peppe
  • Date: 2012-10-12 13:51:07 UTC
  • Revision ID: roger.peppe@canonical.com-20121012135107-03ajfd8mlijzc2ri
cmd/{jujud, juju}: do not use bootstrapped state when testing bootstrap

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
var _ = Suite(&BootstrapSuite{})
17
17
 
 
18
func (s *BootstrapSuite) SetUpTest(c *C) {
 
19
        s.JujuConnSuite.SetUpTest(c)
 
20
        s.JujuConnSuite.Reset(c, false)
 
21
}
 
22
 
18
23
func initBootstrapCommand(args []string) (*BootstrapCommand, error) {
19
24
        c := &BootstrapCommand{}
20
25
        return c, initCmd(c, args)
61
66
        err = cmd.Run(nil)
62
67
        c.Assert(err, IsNil)
63
68
 
64
 
        machines, err := s.State.AllMachines()
 
69
        st, err := state.Open(&state.Info{Addrs: []string{s.stateAddr(c)}})
 
70
        c.Assert(err, IsNil)
 
71
        defer st.Close()
 
72
        machines, err := st.AllMachines()
65
73
        c.Assert(err, IsNil)
66
74
        c.Assert(len(machines), Equals, 1)
67
75
 
70
78
        c.Assert(instid, Equals, "over9000")
71
79
}
72
80
 
 
81
func (s *BootstrapSuite) stateAddr(c *C) string {
 
82
        return s.StateInfo(c).Addrs[0]
 
83
}
 
84
 
73
85
func (s *BootstrapSuite) TestMachinerWorkers(c *C) {
74
86
        args := []string{
75
 
                "--state-servers", s.StateInfo(c).Addrs[0],
 
87
                "--state-servers", s.stateAddr(c),
76
88
                "--instance-id", "over9000",
77
89
                "--env-config", b64yaml{
78
90
                        "name":            "dummyenv",
86
98
        err = cmd.Run(nil)
87
99
        c.Assert(err, IsNil)
88
100
 
89
 
        m, err := s.State.Machine(0)
 
101
        st, err := state.Open(&state.Info{Addrs: []string{s.stateAddr(c)}})
 
102
        c.Assert(err, IsNil)
 
103
        defer st.Close()
 
104
        m, err := st.Machine(0)
90
105
        c.Assert(err, IsNil)
91
106
        c.Assert(m.Workers(), DeepEquals, []state.WorkerKind{state.MachinerWorker, state.ProvisionerWorker, state.FirewallerWorker})
92
107
}
105
120
 
106
121
func (s *BootstrapSuite) TestInitialPassword(c *C) {
107
122
        args := []string{
108
 
                "--state-servers", s.StateInfo(c).Addrs[0],
 
123
                "--state-servers", s.stateAddr(c),
109
124
                "--instance-id", "over9000",
110
125
                "--env-config", b64yaml{
111
126
                        "name":            "dummyenv",
169
184
        for i, t := range base64ConfigTests {
170
185
                c.Logf("test %d", i)
171
186
                args := []string{"--state-servers"}
172
 
                args = append(args, s.StateInfo(c).Addrs...)
 
187
                args = append(args, s.stateAddr(c))
173
188
                args = append(args, "--instance-id", "over9000")
174
189
                args = append(args, t.input...)
175
190
                cmd, err := initBootstrapCommand(args)