Left: | ||
Right: |
OLD | NEW |
---|---|
1 // Copyright 2012, 2013 Canonical Ltd. | 1 // Copyright 2012, 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package client_test | 4 package client_test |
5 | 5 |
6 import ( | 6 import ( |
7 "fmt" | 7 "fmt" |
8 stdtesting "testing" | 8 stdtesting "testing" |
9 "time" | 9 "time" |
10 | 10 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 // but this behavior is already tested in cmd/juju/status_test.go and | 145 // but this behavior is already tested in cmd/juju/status_test.go and |
146 // also tested live and it works. | 146 // also tested live and it works. |
147 var scenarioStatus = &api.Status{ | 147 var scenarioStatus = &api.Status{ |
148 EnvironmentName: "dummyenv", | 148 EnvironmentName: "dummyenv", |
149 Machines: map[string]api.MachineStatus{ | 149 Machines: map[string]api.MachineStatus{ |
150 "0": { | 150 "0": { |
151 Id: "0", | 151 Id: "0", |
152 InstanceId: instance.Id("i-machine-0"), | 152 InstanceId: instance.Id("i-machine-0"), |
153 AgentState: "down", | 153 AgentState: "down", |
154 AgentStateInfo: "(started)", | 154 AgentStateInfo: "(started)", |
155 AgentStateData: params.StatusData{}, | |
155 Series: "quantal", | 156 Series: "quantal", |
156 Containers: map[string]api.MachineStatus{}, | 157 Containers: map[string]api.MachineStatus{}, |
157 Jobs: []params.MachineJob{params.JobManageEnvi ron}, | 158 Jobs: []params.MachineJob{params.JobManageEnvi ron}, |
158 HasVote: false, | 159 HasVote: false, |
159 WantsVote: true, | 160 WantsVote: true, |
160 }, | 161 }, |
161 "1": { | 162 "1": { |
162 Id: "1", | 163 Id: "1", |
163 InstanceId: instance.Id("i-machine-1"), | 164 InstanceId: instance.Id("i-machine-1"), |
164 AgentState: "down", | 165 AgentState: "down", |
165 AgentStateInfo: "(started)", | 166 AgentStateInfo: "(started)", |
167 AgentStateData: params.StatusData{}, | |
166 Series: "quantal", | 168 Series: "quantal", |
167 Containers: map[string]api.MachineStatus{}, | 169 Containers: map[string]api.MachineStatus{}, |
168 Jobs: []params.MachineJob{params.JobHostUnits} , | 170 Jobs: []params.MachineJob{params.JobHostUnits} , |
169 HasVote: false, | 171 HasVote: false, |
170 WantsVote: false, | 172 WantsVote: false, |
171 }, | 173 }, |
172 "2": { | 174 "2": { |
173 Id: "2", | 175 Id: "2", |
174 InstanceId: instance.Id("i-machine-2"), | 176 InstanceId: instance.Id("i-machine-2"), |
175 AgentState: "down", | 177 AgentState: "down", |
176 AgentStateInfo: "(started)", | 178 AgentStateInfo: "(started)", |
179 AgentStateData: params.StatusData{}, | |
177 Series: "quantal", | 180 Series: "quantal", |
178 Containers: map[string]api.MachineStatus{}, | 181 Containers: map[string]api.MachineStatus{}, |
179 Jobs: []params.MachineJob{params.JobHostUnits} , | 182 Jobs: []params.MachineJob{params.JobHostUnits} , |
180 HasVote: false, | 183 HasVote: false, |
181 WantsVote: false, | 184 WantsVote: false, |
182 }, | 185 }, |
183 }, | 186 }, |
184 Services: map[string]api.ServiceStatus{ | 187 Services: map[string]api.ServiceStatus{ |
185 "logging": api.ServiceStatus{ | 188 "logging": api.ServiceStatus{ |
186 Charm: "local:quantal/logging-1", | 189 Charm: "local:quantal/logging-1", |
187 Relations: map[string][]string{ | 190 Relations: map[string][]string{ |
188 "logging-directory": []string{"wordpress"}, | 191 "logging-directory": []string{"wordpress"}, |
189 }, | 192 }, |
190 SubordinateTo: []string{"wordpress"}, | 193 SubordinateTo: []string{"wordpress"}, |
191 }, | 194 }, |
192 "mysql": api.ServiceStatus{ | 195 "mysql": api.ServiceStatus{ |
193 Charm: "local:quantal/mysql-1", | 196 Charm: "local:quantal/mysql-1", |
194 Relations: map[string][]string{}, | 197 Relations: map[string][]string{}, |
195 SubordinateTo: []string{}, | 198 SubordinateTo: []string{}, |
196 Units: map[string]api.UnitStatus{}, | 199 Units: map[string]api.UnitStatus{}, |
197 }, | 200 }, |
198 "wordpress": api.ServiceStatus{ | 201 "wordpress": api.ServiceStatus{ |
199 Charm: "local:quantal/wordpress-3", | 202 Charm: "local:quantal/wordpress-3", |
200 Relations: map[string][]string{ | 203 Relations: map[string][]string{ |
201 "logging-dir": []string{"logging"}, | 204 "logging-dir": []string{"logging"}, |
202 }, | 205 }, |
203 SubordinateTo: []string{}, | 206 SubordinateTo: []string{}, |
204 Units: map[string]api.UnitStatus{ | 207 Units: map[string]api.UnitStatus{ |
205 "wordpress/0": api.UnitStatus{ | 208 "wordpress/0": api.UnitStatus{ |
206 » » » » » AgentState: "pending", | 209 » » » » » AgentState: "down", |
207 » » » » » Machine: "1", | 210 » » » » » AgentStateInfo: "(error: blam)", |
211 » » » » » AgentStateData: params.StatusData{"foo": "bar"}, | |
fwereade
2014/05/26 06:45:34
Were we going to add the components of the "(error
menn0
2014/05/26 21:47:43
Yes that's coming (in a separate branch). This bra
fwereade
2014/05/28 08:52:38
Great, sorry for the confusion, I fear you will ha
menn0
2014/06/03 11:57:09
I haven't been making a distinction - these change
fwereade
2014/06/03 14:02:36
SGTM. We can loosen it up at that end as we need t
| |
212 » » » » » Machine: "1", | |
208 Subordinates: map[string]api.UnitStatus{ | 213 Subordinates: map[string]api.UnitStatus{ |
209 "logging/0": api.UnitStatus{ | 214 "logging/0": api.UnitStatus{ |
210 » » » » » » » AgentState: "pending", | 215 » » » » » » » AgentState: "pending ", |
216 » » » » » » » AgentStateData: params.S tatusData{}, | |
211 }, | 217 }, |
212 }, | 218 }, |
213 }, | 219 }, |
214 "wordpress/1": api.UnitStatus{ | 220 "wordpress/1": api.UnitStatus{ |
215 » » » » » AgentState: "pending", | 221 » » » » » AgentState: "pending", |
216 » » » » » Machine: "2", | 222 » » » » » AgentStateData: params.StatusData{}, |
223 » » » » » Machine: "2", | |
217 Subordinates: map[string]api.UnitStatus{ | 224 Subordinates: map[string]api.UnitStatus{ |
218 "logging/1": api.UnitStatus{ | 225 "logging/1": api.UnitStatus{ |
219 » » » » » » » AgentState: "pending", | 226 » » » » » » » AgentState: "pending ", |
227 » » » » » » » AgentStateData: params.S tatusData{}, | |
220 }, | 228 }, |
221 }, | 229 }, |
222 }, | 230 }, |
223 }, | 231 }, |
224 }, | 232 }, |
225 }, | 233 }, |
234 Relations: map[string]api.RelationStatus{ | |
235 "0": api.RelationStatus{ | |
236 Key: "logging:logging-directory wordpress:logging-dir", | |
237 }, | |
238 }, | |
226 Networks: map[string]api.NetworkStatus{}, | 239 Networks: map[string]api.NetworkStatus{}, |
227 } | 240 } |
228 | 241 |
229 // setUpScenario makes an environment scenario suitable for | 242 // setUpScenario makes an environment scenario suitable for |
230 // testing most kinds of access scenario. It returns | 243 // testing most kinds of access scenario. It returns |
231 // a list of all the entities in the scenario. | 244 // a list of all the entities in the scenario. |
232 // | 245 // |
233 // When the scenario is initialized, we have: | 246 // When the scenario is initialized, we have: |
234 // user-admin | 247 // user-admin |
235 // user-other | 248 // user-other |
236 // machine-0 | 249 // machine-0 |
237 // instance-id="i-machine-0" | 250 // instance-id="i-machine-0" |
238 // nonce="fake_nonce" | 251 // nonce="fake_nonce" |
239 // jobs=manage-environ | 252 // jobs=manage-environ |
240 // status=started, info="" | 253 // status=started, info="" |
241 // machine-1 | 254 // machine-1 |
242 // instance-id="i-machine-1" | 255 // instance-id="i-machine-1" |
243 // nonce="fake_nonce" | 256 // nonce="fake_nonce" |
244 // jobs=host-units | 257 // jobs=host-units |
245 // status=started, info="" | 258 // status=started, info="" |
246 // constraints=mem=1G | 259 // constraints=mem=1G |
247 // machine-2 | 260 // machine-2 |
248 // instance-id="i-machine-2" | 261 // instance-id="i-machine-2" |
249 // nonce="fake_nonce" | 262 // nonce="fake_nonce" |
250 // jobs=host-units | 263 // jobs=host-units |
251 // status=started, info="" | 264 // status=started, info="" |
252 // service-wordpress | 265 // service-wordpress |
253 // service-logging | 266 // service-logging |
254 // unit-wordpress-0 | 267 // unit-wordpress-0 |
255 // deployer-name=machine-1 | 268 // deployer-name=machine-1 |
269 // status=down with error and status data attached | |
256 // unit-logging-0 | 270 // unit-logging-0 |
257 // deployer-name=unit-wordpress-0 | 271 // deployer-name=unit-wordpress-0 |
258 // unit-wordpress-1 | 272 // unit-wordpress-1 |
259 // deployer-name=machine-2 | 273 // deployer-name=machine-2 |
260 // unit-logging-1 | 274 // unit-logging-1 |
261 // deployer-name=unit-wordpress-1 | 275 // deployer-name=unit-wordpress-1 |
262 // | 276 // |
263 // The passwords for all returned entities are | 277 // The passwords for all returned entities are |
264 // set to the entity name with a " password" suffix. | 278 // set to the entity name with a " password" suffix. |
265 // | 279 // |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 err = wu.AssignToMachine(m) | 335 err = wu.AssignToMachine(m) |
322 c.Assert(err, gc.IsNil) | 336 c.Assert(err, gc.IsNil) |
323 | 337 |
324 deployer, ok := wu.DeployerTag() | 338 deployer, ok := wu.DeployerTag() |
325 c.Assert(ok, gc.Equals, true) | 339 c.Assert(ok, gc.Equals, true) |
326 c.Assert(deployer, gc.Equals, fmt.Sprintf("machine-%d", i+1)) | 340 c.Assert(deployer, gc.Equals, fmt.Sprintf("machine-%d", i+1)) |
327 | 341 |
328 wru, err := rel.Unit(wu) | 342 wru, err := rel.Unit(wu) |
329 c.Assert(err, gc.IsNil) | 343 c.Assert(err, gc.IsNil) |
330 | 344 |
345 if i == 0 { | |
346 sd := params.StatusData{"foo": "bar"} | |
347 wu.SetStatus(params.StatusError, "blam", sd) | |
348 } | |
349 | |
331 // Create the subordinate unit as a side-effect of entering | 350 // Create the subordinate unit as a side-effect of entering |
332 // scope in the principal's relation-unit. | 351 // scope in the principal's relation-unit. |
333 err = wru.EnterScope(nil) | 352 err = wru.EnterScope(nil) |
334 c.Assert(err, gc.IsNil) | 353 c.Assert(err, gc.IsNil) |
335 | 354 |
336 lu, err := s.State.Unit(fmt.Sprintf("logging/%d", i)) | 355 lu, err := s.State.Unit(fmt.Sprintf("logging/%d", i)) |
337 c.Assert(err, gc.IsNil) | 356 c.Assert(err, gc.IsNil) |
338 c.Assert(lu.IsPrincipal(), gc.Equals, false) | 357 c.Assert(lu.IsPrincipal(), gc.Equals, false) |
339 deployer, ok = lu.DeployerTag() | 358 deployer, ok = lu.DeployerTag() |
340 c.Assert(ok, gc.Equals, true) | 359 c.Assert(ok, gc.Equals, true) |
341 c.Assert(deployer, gc.Equals, fmt.Sprintf("unit-wordpress-%d", i )) | 360 c.Assert(deployer, gc.Equals, fmt.Sprintf("unit-wordpress-%d", i )) |
342 setDefaultPassword(c, lu) | 361 setDefaultPassword(c, lu) |
343 add(lu) | 362 add(lu) |
344 } | 363 } |
345 return | 364 return |
346 } | 365 } |
OLD | NEW |