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

Side by Side Diff: state/apiserver/client/api_test.go

Issue 93480044: state/api{,server}: more info from FullStatus API
Patch Set: Created 9 years, 10 months 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:
View unified diff | Download patch
« no previous file with comments | « state/api/client.go ('k') | state/apiserver/client/perm_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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/19 07:46:24 How does this look in practice? The repetition of
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 },
226 Networks: map[string]api.NetworkStatus{}, 234 Networks: map[string]api.NetworkStatus{},
227 } 235 }
228 236
229 // setUpScenario makes an environment scenario suitable for 237 // setUpScenario makes an environment scenario suitable for
(...skipping 15 matching lines...) Expand all
245 // status=started, info="" 253 // status=started, info=""
246 // constraints=mem=1G 254 // constraints=mem=1G
247 // machine-2 255 // machine-2
248 // instance-id="i-machine-2" 256 // instance-id="i-machine-2"
249 // nonce="fake_nonce" 257 // nonce="fake_nonce"
250 // jobs=host-units 258 // jobs=host-units
251 // status=started, info="" 259 // status=started, info=""
252 // service-wordpress 260 // service-wordpress
253 // service-logging 261 // service-logging
254 // unit-wordpress-0 262 // unit-wordpress-0
255 // deployer-name=machine-1 263 // deployer-name=machine-1
264 // status=down with error and status data attached
256 // unit-logging-0 265 // unit-logging-0
257 // deployer-name=unit-wordpress-0 266 // deployer-name=unit-wordpress-0
258 // unit-wordpress-1 267 // unit-wordpress-1
259 // deployer-name=machine-2 268 // deployer-name=machine-2
260 // unit-logging-1 269 // unit-logging-1
261 // deployer-name=unit-wordpress-1 270 // deployer-name=unit-wordpress-1
262 // 271 //
263 // The passwords for all returned entities are 272 // The passwords for all returned entities are
264 // set to the entity name with a " password" suffix. 273 // set to the entity name with a " password" suffix.
265 // 274 //
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 err = wu.AssignToMachine(m) 330 err = wu.AssignToMachine(m)
322 c.Assert(err, gc.IsNil) 331 c.Assert(err, gc.IsNil)
323 332
324 deployer, ok := wu.DeployerTag() 333 deployer, ok := wu.DeployerTag()
325 c.Assert(ok, gc.Equals, true) 334 c.Assert(ok, gc.Equals, true)
326 c.Assert(deployer, gc.Equals, fmt.Sprintf("machine-%d", i+1)) 335 c.Assert(deployer, gc.Equals, fmt.Sprintf("machine-%d", i+1))
327 336
328 wru, err := rel.Unit(wu) 337 wru, err := rel.Unit(wu)
329 c.Assert(err, gc.IsNil) 338 c.Assert(err, gc.IsNil)
330 339
340 if i == 0 {
341 sd := params.StatusData{"foo": "bar"}
342 wu.SetStatus(params.StatusError, "blam", sd)
343 }
344
331 // Create the subordinate unit as a side-effect of entering 345 // Create the subordinate unit as a side-effect of entering
332 // scope in the principal's relation-unit. 346 // scope in the principal's relation-unit.
333 err = wru.EnterScope(nil) 347 err = wru.EnterScope(nil)
334 c.Assert(err, gc.IsNil) 348 c.Assert(err, gc.IsNil)
335 349
336 lu, err := s.State.Unit(fmt.Sprintf("logging/%d", i)) 350 lu, err := s.State.Unit(fmt.Sprintf("logging/%d", i))
337 c.Assert(err, gc.IsNil) 351 c.Assert(err, gc.IsNil)
338 c.Assert(lu.IsPrincipal(), gc.Equals, false) 352 c.Assert(lu.IsPrincipal(), gc.Equals, false)
339 deployer, ok = lu.DeployerTag() 353 deployer, ok = lu.DeployerTag()
340 c.Assert(ok, gc.Equals, true) 354 c.Assert(ok, gc.Equals, true)
341 c.Assert(deployer, gc.Equals, fmt.Sprintf("unit-wordpress-%d", i )) 355 c.Assert(deployer, gc.Equals, fmt.Sprintf("unit-wordpress-%d", i ))
342 setDefaultPassword(c, lu) 356 setDefaultPassword(c, lu)
343 add(lu) 357 add(lu)
344 } 358 }
345 return 359 return
346 } 360 }
OLDNEW
« no previous file with comments | « state/api/client.go ('k') | state/apiserver/client/perm_test.go » ('j') | no next file with comments »

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