Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Delta Between Two Patch Sets: cmd/jujud/bootstrap_test.go

Issue 7950044: state/api/params: add CharmURL to ServiceInfo
Left Patch Set: Created 12 years ago
Right Patch Set: state/api/params: add CharmURL to ServiceInfo Created 12 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « cmd/jujud/bootstrap.go ('k') | cmd/jujud/upgrade.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 package main 1 package main
2 2
3 import ( 3 import (
4 "encoding/base64" 4 "encoding/base64"
5 . "launchpad.net/gocheck" 5 . "launchpad.net/gocheck"
6 "launchpad.net/goyaml" 6 "launchpad.net/goyaml"
7 "launchpad.net/juju-core/constraints" 7 "launchpad.net/juju-core/constraints"
8 "launchpad.net/juju-core/environs/agent" 8 "launchpad.net/juju-core/environs/agent"
9 "launchpad.net/juju-core/state" 9 "launchpad.net/juju-core/state"
10 "launchpad.net/juju-core/testing" 10 "launchpad.net/juju-core/testing"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 func (s *BootstrapSuite) TestInitializeEnvironment(c *C) { 60 func (s *BootstrapSuite) TestInitializeEnvironment(c *C) {
61 _, cmd, err := s.initBootstrapCommand(c, "--env-config", testConfig) 61 _, cmd, err := s.initBootstrapCommand(c, "--env-config", testConfig)
62 c.Assert(err, IsNil) 62 c.Assert(err, IsNil)
63 err = cmd.Run(nil) 63 err = cmd.Run(nil)
64 c.Assert(err, IsNil) 64 c.Assert(err, IsNil)
65 65
66 st, err := state.Open(&state.Info{ 66 st, err := state.Open(&state.Info{
67 Addrs: []string{testing.MgoAddr}, 67 Addrs: []string{testing.MgoAddr},
68 CACert: []byte(testing.CACert), 68 CACert: []byte(testing.CACert),
69 » }) 69 » }, state.DefaultDialTimeout)
70 c.Assert(err, IsNil) 70 c.Assert(err, IsNil)
71 defer st.Close() 71 defer st.Close()
72 machines, err := st.AllMachines() 72 machines, err := st.AllMachines()
73 c.Assert(err, IsNil) 73 c.Assert(err, IsNil)
74 c.Assert(len(machines), Equals, 1) 74 c.Assert(len(machines), Equals, 1)
75 75
76 instid, ok := machines[0].InstanceId() 76 instid, ok := machines[0].InstanceId()
77 c.Assert(ok, Equals, true) 77 c.Assert(ok, Equals, true)
78 c.Assert(instid, Equals, state.InstanceId("dummy.instance.id")) 78 c.Assert(instid, Equals, state.InstanceId("dummy.instance.id"))
79 79
80 cons, err := st.EnvironConstraints() 80 cons, err := st.EnvironConstraints()
81 c.Assert(err, IsNil) 81 c.Assert(err, IsNil)
82 c.Assert(cons, DeepEquals, constraints.Value{}) 82 c.Assert(cons, DeepEquals, constraints.Value{})
83 } 83 }
84 84
85 func (s *BootstrapSuite) TestSetConstraints(c *C) { 85 func (s *BootstrapSuite) TestSetConstraints(c *C) {
86 tcons := constraints.Value{Mem: uint64p(2048), CpuCores: uint64p(2)} 86 tcons := constraints.Value{Mem: uint64p(2048), CpuCores: uint64p(2)}
87 _, cmd, err := s.initBootstrapCommand(c, "--env-config", testConfig, "-- constraints", tcons.String()) 87 _, cmd, err := s.initBootstrapCommand(c, "--env-config", testConfig, "-- constraints", tcons.String())
88 c.Assert(err, IsNil) 88 c.Assert(err, IsNil)
89 err = cmd.Run(nil) 89 err = cmd.Run(nil)
90 c.Assert(err, IsNil) 90 c.Assert(err, IsNil)
91 91
92 st, err := state.Open(&state.Info{ 92 st, err := state.Open(&state.Info{
93 Addrs: []string{testing.MgoAddr}, 93 Addrs: []string{testing.MgoAddr},
94 CACert: []byte(testing.CACert), 94 CACert: []byte(testing.CACert),
95 » }) 95 » }, state.DefaultDialTimeout)
96 c.Assert(err, IsNil) 96 c.Assert(err, IsNil)
97 defer st.Close() 97 defer st.Close()
98 cons, err := st.EnvironConstraints() 98 cons, err := st.EnvironConstraints()
99 c.Assert(err, IsNil) 99 c.Assert(err, IsNil)
100 c.Assert(cons, DeepEquals, tcons) 100 c.Assert(cons, DeepEquals, tcons)
101 } 101 }
102 102
103 func uint64p(v uint64) *uint64 { 103 func uint64p(v uint64) *uint64 {
104 return &v 104 return &v
105 } 105 }
106 106
107 func (s *BootstrapSuite) TestMachinerWorkers(c *C) { 107 func (s *BootstrapSuite) TestMachinerWorkers(c *C) {
108 _, cmd, err := s.initBootstrapCommand(c, "--env-config", testConfig) 108 _, cmd, err := s.initBootstrapCommand(c, "--env-config", testConfig)
109 c.Assert(err, IsNil) 109 c.Assert(err, IsNil)
110 err = cmd.Run(nil) 110 err = cmd.Run(nil)
111 c.Assert(err, IsNil) 111 c.Assert(err, IsNil)
112 112
113 st, err := state.Open(&state.Info{ 113 st, err := state.Open(&state.Info{
114 Addrs: []string{testing.MgoAddr}, 114 Addrs: []string{testing.MgoAddr},
115 CACert: []byte(testing.CACert), 115 CACert: []byte(testing.CACert),
116 » }) 116 » }, state.DefaultDialTimeout)
117 c.Assert(err, IsNil) 117 c.Assert(err, IsNil)
118 defer st.Close() 118 defer st.Close()
119 m, err := st.Machine("0") 119 m, err := st.Machine("0")
120 c.Assert(err, IsNil) 120 c.Assert(err, IsNil)
121 c.Assert(m.Jobs(), DeepEquals, []state.MachineJob{state.JobManageEnviron , state.JobServeAPI}) 121 c.Assert(m.Jobs(), DeepEquals, []state.MachineJob{state.JobManageEnviron , state.JobServeAPI})
122 } 122 }
123 123
124 func testOpenState(c *C, info *state.Info, expectErr error) { 124 func testOpenState(c *C, info *state.Info, expectErr error) {
125 » st, err := state.Open(info) 125 » st, err := state.Open(info, state.DefaultDialTimeout)
126 if st != nil { 126 if st != nil {
127 st.Close() 127 st.Close()
128 } 128 }
129 if expectErr != nil { 129 if expectErr != nil {
130 c.Assert(state.IsUnauthorizedError(err), Equals, true) 130 c.Assert(state.IsUnauthorizedError(err), Equals, true)
131 } else { 131 } else {
132 c.Assert(err, IsNil) 132 c.Assert(err, IsNil)
133 } 133 }
134 } 134 }
135 135
(...skipping 12 matching lines...) Expand all
148 info := &state.Info{ 148 info := &state.Info{
149 Addrs: []string{testing.MgoAddr}, 149 Addrs: []string{testing.MgoAddr},
150 CACert: []byte(testing.CACert), 150 CACert: []byte(testing.CACert),
151 } 151 }
152 testOpenState(c, info, state.Unauthorizedf("some auth problem")) 152 testOpenState(c, info, state.Unauthorizedf("some auth problem"))
153 153
154 info.EntityName, info.Password = "machine-0", "foo" 154 info.EntityName, info.Password = "machine-0", "foo"
155 testOpenState(c, info, nil) 155 testOpenState(c, info, nil)
156 156
157 info.EntityName = "" 157 info.EntityName = ""
158 » st, err := state.Open(info) 158 » st, err := state.Open(info, state.DefaultDialTimeout)
159 c.Assert(err, IsNil) 159 c.Assert(err, IsNil)
160 defer st.Close() 160 defer st.Close()
161 161
162 // Reset password so the tests can continue to use the same server. 162 // Reset password so the tests can continue to use the same server.
163 err = st.SetAdminMongoPassword("") 163 err = st.SetAdminMongoPassword("")
164 c.Assert(err, IsNil) 164 c.Assert(err, IsNil)
165 } 165 }
166 166
167 var base64ConfigTests = []struct { 167 var base64ConfigTests = []struct {
168 input []string 168 input []string
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 return base64.StdEncoding.EncodeToString(data) 217 return base64.StdEncoding.EncodeToString(data)
218 } 218 }
219 219
220 var testConfig = b64yaml{ 220 var testConfig = b64yaml{
221 "name": "dummyenv", 221 "name": "dummyenv",
222 "type": "dummy", 222 "type": "dummy",
223 "state-server": false, 223 "state-server": false,
224 "authorized-keys": "i-am-a-key", 224 "authorized-keys": "i-am-a-key",
225 "ca-cert": testing.CACert, 225 "ca-cert": testing.CACert,
226 }.encode() 226 }.encode()
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b