~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/cmd/juju/status/status_test.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 
15
15
        "github.com/juju/cmd"
16
16
        jc "github.com/juju/testing/checkers"
 
17
        "github.com/juju/version"
17
18
        gc "gopkg.in/check.v1"
18
19
        "gopkg.in/juju/charm.v6-unstable"
19
20
        goyaml "gopkg.in/yaml.v2"
29
30
        "github.com/juju/juju/state"
30
31
        "github.com/juju/juju/state/multiwatcher"
31
32
        "github.com/juju/juju/state/presence"
 
33
        "github.com/juju/juju/status"
32
34
        "github.com/juju/juju/testcharms"
33
35
        coretesting "github.com/juju/juju/testing"
34
 
        "github.com/juju/juju/version"
 
36
        jujuversion "github.com/juju/juju/version"
35
37
)
36
38
 
37
39
func nextVersion() version.Number {
38
 
        ver := version.Current
 
40
        ver := jujuversion.Current
39
41
        ver.Patch++
40
42
        return ver
41
43
}
141
143
// shortcuts for expected output.
142
144
var (
143
145
        machine0 = M{
144
 
                "agent-state":              "started",
145
 
                "dns-name":                 "dummymodel-0.dns",
146
 
                "instance-id":              "dummymodel-0",
 
146
                "juju-status": M{
 
147
                        "current": "started",
 
148
                        "since":   "01 Apr 15 01:23+10:00",
 
149
                },
 
150
                "dns-name":    "admin-0.dns",
 
151
                "instance-id": "admin-0",
 
152
                "machine-status": M{
 
153
                        "current": "pending",
 
154
                        "since":   "01 Apr 15 01:23+10:00",
 
155
                },
147
156
                "series":                   "quantal",
148
157
                "hardware":                 "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
149
158
                "controller-member-status": "adding-vote",
150
159
        }
151
160
        machine1 = M{
152
 
                "agent-state": "started",
153
 
                "dns-name":    "dummymodel-1.dns",
154
 
                "instance-id": "dummymodel-1",
155
 
                "series":      "quantal",
156
 
                "hardware":    "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
 
161
                "juju-status": M{
 
162
                        "current": "started",
 
163
                        "since":   "01 Apr 15 01:23+10:00",
 
164
                },
 
165
                "dns-name":    "admin-1.dns",
 
166
                "instance-id": "admin-1",
 
167
                "machine-status": M{
 
168
                        "current": "pending",
 
169
                        "since":   "01 Apr 15 01:23+10:00",
 
170
                },
 
171
                "series":   "quantal",
 
172
                "hardware": "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
157
173
        }
158
174
        machine2 = M{
159
 
                "agent-state": "started",
160
 
                "dns-name":    "dummymodel-2.dns",
161
 
                "instance-id": "dummymodel-2",
162
 
                "series":      "quantal",
163
 
                "hardware":    "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
 
175
                "juju-status": M{
 
176
                        "current": "started",
 
177
                        "since":   "01 Apr 15 01:23+10:00",
 
178
                },
 
179
                "dns-name":    "admin-2.dns",
 
180
                "instance-id": "admin-2",
 
181
                "machine-status": M{
 
182
                        "current": "pending",
 
183
                        "since":   "01 Apr 15 01:23+10:00",
 
184
                },
 
185
                "series":   "quantal",
 
186
                "hardware": "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
164
187
        }
165
188
        machine3 = M{
166
 
                "agent-state": "started",
167
 
                "dns-name":    "dummymodel-3.dns",
168
 
                "instance-id": "dummymodel-3",
169
 
                "series":      "quantal",
170
 
                "hardware":    "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
 
189
                "juju-status": M{
 
190
                        "current": "started",
 
191
                        "since":   "01 Apr 15 01:23+10:00",
 
192
                },
 
193
                "dns-name":    "admin-3.dns",
 
194
                "instance-id": "admin-3",
 
195
                "machine-status": M{
 
196
                        "current": "pending",
 
197
                        "since":   "01 Apr 15 01:23+10:00",
 
198
                },
 
199
                "series":   "quantal",
 
200
                "hardware": "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
171
201
        }
172
202
        machine4 = M{
173
 
                "agent-state": "started",
174
 
                "dns-name":    "dummymodel-4.dns",
175
 
                "instance-id": "dummymodel-4",
176
 
                "series":      "quantal",
177
 
                "hardware":    "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
 
203
                "juju-status": M{
 
204
                        "current": "started",
 
205
                        "since":   "01 Apr 15 01:23+10:00",
 
206
                },
 
207
                "dns-name":    "admin-4.dns",
 
208
                "instance-id": "admin-4",
 
209
                "machine-status": M{
 
210
                        "current": "pending",
 
211
                        "since":   "01 Apr 15 01:23+10:00",
 
212
                },
 
213
                "series":   "quantal",
 
214
                "hardware": "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
178
215
        }
179
216
        machine1WithContainers = M{
180
 
                "agent-state": "started",
 
217
                "juju-status": M{
 
218
                        "current": "started",
 
219
                        "since":   "01 Apr 15 01:23+10:00",
 
220
                },
181
221
                "containers": M{
182
222
                        "1/lxc/0": M{
183
 
                                "agent-state": "started",
 
223
                                "juju-status": M{
 
224
                                        "current": "started",
 
225
                                        "since":   "01 Apr 15 01:23+10:00",
 
226
                                },
184
227
                                "containers": M{
185
228
                                        "1/lxc/0/lxc/0": M{
186
 
                                                "agent-state": "started",
187
 
                                                "dns-name":    "dummymodel-3.dns",
188
 
                                                "instance-id": "dummymodel-3",
189
 
                                                "series":      "quantal",
 
229
                                                "juju-status": M{
 
230
                                                        "current": "started",
 
231
                                                        "since":   "01 Apr 15 01:23+10:00",
 
232
                                                },
 
233
                                                "dns-name":    "admin-3.dns",
 
234
                                                "instance-id": "admin-3",
 
235
                                                "machine-status": M{
 
236
                                                        "current": "pending",
 
237
                                                        "since":   "01 Apr 15 01:23+10:00",
 
238
                                                },
 
239
                                                "series": "quantal",
190
240
                                        },
191
241
                                },
192
 
                                "dns-name":    "dummymodel-2.dns",
193
 
                                "instance-id": "dummymodel-2",
194
 
                                "series":      "quantal",
 
242
                                "dns-name":    "admin-2.dns",
 
243
                                "instance-id": "admin-2",
 
244
                                "machine-status": M{
 
245
                                        "current": "pending",
 
246
                                        "since":   "01 Apr 15 01:23+10:00",
 
247
                                },
 
248
                                "series": "quantal",
195
249
                        },
196
250
                        "1/lxc/1": M{
197
 
                                "agent-state": "pending",
 
251
                                "juju-status": M{
 
252
                                        "current": "pending",
 
253
                                        "since":   "01 Apr 15 01:23+10:00",
 
254
                                },
198
255
                                "instance-id": "pending",
199
 
                                "series":      "quantal",
200
 
                        },
201
 
                },
202
 
                "dns-name":    "dummymodel-1.dns",
203
 
                "instance-id": "dummymodel-1",
204
 
                "series":      "quantal",
205
 
                "hardware":    "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
206
 
        }
207
 
        machine1WithContainersScoped = M{
208
 
                "agent-state": "started",
209
 
                "containers": M{
210
 
                        "1/lxc/0": M{
211
 
                                "agent-state": "started",
212
 
                                "dns-name":    "dummymodel-2.dns",
213
 
                                "instance-id": "dummymodel-2",
214
 
                                "series":      "quantal",
215
 
                        },
216
 
                },
217
 
                "dns-name":    "dummymodel-1.dns",
218
 
                "instance-id": "dummymodel-1",
219
 
                "series":      "quantal",
220
 
                "hardware":    "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
 
256
                                "machine-status": M{
 
257
                                        "current": "pending",
 
258
                                        "since":   "01 Apr 15 01:23+10:00",
 
259
                                },
 
260
                                "series": "quantal",
 
261
                        },
 
262
                },
 
263
                "dns-name":    "admin-1.dns",
 
264
                "instance-id": "admin-1",
 
265
                "machine-status": M{
 
266
                        "current": "pending",
 
267
                        "since":   "01 Apr 15 01:23+10:00",
 
268
                },
 
269
 
 
270
                "series":   "quantal",
 
271
                "hardware": "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
221
272
        }
222
273
        unexposedService = M{
223
274
                "service-status": M{
263
314
                expect{
264
315
                        "simulate juju bootstrap by adding machine/0 to the state",
265
316
                        M{
266
 
                                "model": "dummymodel",
 
317
                                "model": "admin",
267
318
                                "machines": M{
268
319
                                        "0": M{
269
 
                                                "agent-state":              "pending",
270
 
                                                "instance-id":              "pending",
 
320
                                                "juju-status": M{
 
321
                                                        "current": "pending",
 
322
                                                        "since":   "01 Apr 15 01:23+10:00",
 
323
                                                },
 
324
                                                "instance-id": "pending",
 
325
                                                "machine-status": M{
 
326
                                                        "current": "pending",
 
327
                                                        "since":   "01 Apr 15 01:23+10:00",
 
328
                                                },
271
329
                                                "series":                   "quantal",
272
330
                                                "controller-member-status": "adding-vote",
273
331
                                        },
279
337
                startAliveMachine{"0"},
280
338
                setAddresses{"0", []network.Address{
281
339
                        network.NewAddress("10.0.0.1"),
282
 
                        network.NewScopedAddress("dummymodel-0.dns", network.ScopePublic),
 
340
                        network.NewScopedAddress("admin-0.dns", network.ScopePublic),
283
341
                }},
284
342
                expect{
285
343
                        "simulate the PA starting an instance in response to the state change",
286
344
                        M{
287
 
                                "model": "dummymodel",
 
345
                                "model": "admin",
288
346
                                "machines": M{
289
347
                                        "0": M{
290
 
                                                "agent-state":              "pending",
291
 
                                                "dns-name":                 "dummymodel-0.dns",
292
 
                                                "instance-id":              "dummymodel-0",
 
348
                                                "juju-status": M{
 
349
                                                        "current": "pending",
 
350
                                                        "since":   "01 Apr 15 01:23+10:00",
 
351
                                                },
 
352
                                                "dns-name":    "admin-0.dns",
 
353
                                                "instance-id": "admin-0",
 
354
                                                "machine-status": M{
 
355
                                                        "current": "pending",
 
356
                                                        "since":   "01 Apr 15 01:23+10:00",
 
357
                                                },
293
358
                                                "series":                   "quantal",
294
359
                                                "hardware":                 "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
295
360
                                                "controller-member-status": "adding-vote",
299
364
                        },
300
365
                },
301
366
 
302
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
367
                setMachineStatus{"0", status.StatusStarted, ""},
303
368
                expect{
304
369
                        "simulate the MA started and set the machine status",
305
370
                        M{
306
 
                                "model": "dummymodel",
 
371
                                "model": "admin",
307
372
                                "machines": M{
308
373
                                        "0": machine0,
309
374
                                },
315
380
                expect{
316
381
                        "simulate the MA setting the version",
317
382
                        M{
318
 
                                "model": "dummymodel",
 
383
                                "model": "admin",
319
384
                                "machines": M{
320
385
                                        "0": M{
321
 
                                                "dns-name":                 "dummymodel-0.dns",
322
 
                                                "instance-id":              "dummymodel-0",
323
 
                                                "agent-version":            "1.2.3",
324
 
                                                "agent-state":              "started",
 
386
                                                "dns-name":    "admin-0.dns",
 
387
                                                "instance-id": "admin-0",
 
388
                                                "machine-status": M{
 
389
                                                        "current": "pending",
 
390
                                                        "since":   "01 Apr 15 01:23+10:00",
 
391
                                                },
 
392
                                                "juju-status": M{
 
393
                                                        "current": "started",
 
394
                                                        "since":   "01 Apr 15 01:23+10:00",
 
395
                                                        "version": "1.2.3",
 
396
                                                },
325
397
                                                "series":                   "quantal",
326
398
                                                "hardware":                 "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
327
399
                                                "controller-member-status": "adding-vote",
336
408
                addMachine{machineId: "0", cons: machineCons, job: state.JobManageModel},
337
409
                setAddresses{"0", []network.Address{
338
410
                        network.NewAddress("10.0.0.1"),
339
 
                        network.NewScopedAddress("dummymodel-0.dns", network.ScopePublic),
 
411
                        network.NewScopedAddress("admin-0.dns", network.ScopePublic),
340
412
                }},
341
413
                startAliveMachine{"0"},
342
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
414
                setMachineStatus{"0", status.StatusStarted, ""},
343
415
                expect{
344
416
                        "machine 0 has specific hardware characteristics",
345
417
                        M{
346
 
                                "model": "dummymodel",
 
418
                                "model": "admin",
347
419
                                "machines": M{
348
420
                                        "0": M{
349
 
                                                "agent-state":              "started",
350
 
                                                "dns-name":                 "dummymodel-0.dns",
351
 
                                                "instance-id":              "dummymodel-0",
 
421
                                                "juju-status": M{
 
422
                                                        "current": "started",
 
423
                                                        "since":   "01 Apr 15 01:23+10:00",
 
424
                                                },
 
425
                                                "dns-name":    "admin-0.dns",
 
426
                                                "instance-id": "admin-0",
 
427
                                                "machine-status": M{
 
428
                                                        "current": "pending",
 
429
                                                        "since":   "01 Apr 15 01:23+10:00",
 
430
                                                },
352
431
                                                "series":                   "quantal",
353
432
                                                "hardware":                 "arch=amd64 cpu-cores=2 mem=8192M root-disk=8192M",
354
433
                                                "controller-member-status": "adding-vote",
362
441
                "instance without addresses",
363
442
                addMachine{machineId: "0", cons: machineCons, job: state.JobManageModel},
364
443
                startAliveMachine{"0"},
365
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
444
                setMachineStatus{"0", status.StatusStarted, ""},
366
445
                expect{
367
446
                        "machine 0 has no dns-name",
368
447
                        M{
369
 
                                "model": "dummymodel",
 
448
                                "model": "admin",
370
449
                                "machines": M{
371
450
                                        "0": M{
372
 
                                                "agent-state":              "started",
373
 
                                                "instance-id":              "dummymodel-0",
 
451
                                                "juju-status": M{
 
452
                                                        "current": "started",
 
453
                                                        "since":   "01 Apr 15 01:23+10:00",
 
454
                                                },
 
455
                                                "instance-id": "admin-0",
 
456
                                                "machine-status": M{
 
457
                                                        "current": "pending",
 
458
                                                        "since":   "01 Apr 15 01:23+10:00",
 
459
                                                },
374
460
                                                "series":                   "quantal",
375
461
                                                "hardware":                 "arch=amd64 cpu-cores=2 mem=8192M root-disk=8192M",
376
462
                                                "controller-member-status": "adding-vote",
386
472
                expect{
387
473
                        "machine 0 reports pending",
388
474
                        M{
389
 
                                "model": "dummymodel",
 
475
                                "model": "admin",
390
476
                                "machines": M{
391
477
                                        "0": M{
392
 
                                                "agent-state":              "pending",
393
 
                                                "instance-id":              "pending",
 
478
                                                "juju-status": M{
 
479
                                                        "current": "pending",
 
480
                                                        "since":   "01 Apr 15 01:23+10:00",
 
481
                                                },
 
482
                                                "instance-id": "pending",
 
483
                                                "machine-status": M{
 
484
                                                        "current": "pending",
 
485
                                                        "since":   "01 Apr 15 01:23+10:00",
 
486
                                                },
394
487
                                                "series":                   "quantal",
395
488
                                                "controller-member-status": "adding-vote",
396
489
                                        },
403
496
                expect{
404
497
                        "machine 0 reports missing",
405
498
                        M{
406
 
                                "model": "dummymodel",
 
499
                                "model": "admin",
407
500
                                "machines": M{
408
501
                                        "0": M{
409
 
                                                "instance-state":           "missing",
410
 
                                                "instance-id":              "i-missing",
411
 
                                                "agent-state":              "pending",
 
502
                                                "instance-id": "i-missing",
 
503
                                                "juju-status": M{
 
504
                                                        "current": "pending",
 
505
                                                        "since":   "01 Apr 15 01:23+10:00",
 
506
                                                },
 
507
                                                "machine-status": M{
 
508
                                                        "current": "unknown",
 
509
                                                        "message": "missing",
 
510
                                                        "since":   "01 Apr 15 01:23+10:00",
 
511
                                                },
412
512
                                                "series":                   "quantal",
413
513
                                                "hardware":                 "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
414
514
                                                "controller-member-status": "adding-vote",
422
522
                "add two services and expose one, then add 2 more machines and some units",
423
523
                // step 0
424
524
                addMachine{machineId: "0", job: state.JobManageModel},
425
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
525
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
426
526
                startAliveMachine{"0"},
427
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
527
                setMachineStatus{"0", status.StatusStarted, ""},
428
528
                addCharm{"dummy"},
429
529
                addService{name: "dummy-service", charm: "dummy"},
430
530
                addService{name: "exposed-service", charm: "dummy"},
431
531
                expect{
432
532
                        "no services exposed yet",
433
533
                        M{
434
 
                                "model": "dummymodel",
 
534
                                "model": "admin",
435
535
                                "machines": M{
436
536
                                        "0": machine0,
437
537
                                },
447
547
                expect{
448
548
                        "one exposed service",
449
549
                        M{
450
 
                                "model": "dummymodel",
 
550
                                "model": "admin",
451
551
                                "machines": M{
452
552
                                        "0": machine0,
453
553
                                },
460
560
 
461
561
                // step 10
462
562
                addMachine{machineId: "1", job: state.JobHostUnits},
463
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
563
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
464
564
                startAliveMachine{"1"},
465
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
565
                setMachineStatus{"1", status.StatusStarted, ""},
466
566
                addMachine{machineId: "2", job: state.JobHostUnits},
467
 
                setAddresses{"2", network.NewAddresses("dummymodel-2.dns")},
 
567
                setAddresses{"2", network.NewAddresses("admin-2.dns")},
468
568
                startAliveMachine{"2"},
469
 
                setMachineStatus{"2", state.StatusStarted, ""},
 
569
                setMachineStatus{"2", status.StatusStarted, ""},
470
570
                expect{
471
571
                        "two more machines added",
472
572
                        M{
473
 
                                "model": "dummymodel",
 
573
                                "model": "admin",
474
574
                                "machines": M{
475
575
                                        "0": machine0,
476
576
                                        "1": machine1,
486
586
                // step 19
487
587
                addAliveUnit{"dummy-service", "1"},
488
588
                addAliveUnit{"exposed-service", "2"},
489
 
                setAgentStatus{"exposed-service/0", state.StatusError, "You Require More Vespene Gas", nil},
 
589
                setAgentStatus{"exposed-service/0", status.StatusError, "You Require More Vespene Gas", nil},
490
590
                // Open multiple ports with different protocols,
491
591
                // ensure they're sorted on protocol, then number.
492
592
                openUnitPort{"exposed-service/0", "udp", 10},
496
596
                // Simulate some status with no info, while the agent is down.
497
597
                // Status used to be down, we no longer support said state.
498
598
                // now is one of: pending, started, error.
499
 
                setUnitStatus{"dummy-service/0", state.StatusTerminated, "", nil},
500
 
                setAgentStatus{"dummy-service/0", state.StatusIdle, "", nil},
 
599
                setUnitStatus{"dummy-service/0", status.StatusTerminated, "", nil},
 
600
                setAgentStatus{"dummy-service/0", status.StatusIdle, "", nil},
501
601
 
502
602
                expect{
503
603
                        "add two units, one alive (in error state), one started",
504
604
                        M{
505
 
                                "model": "dummymodel",
 
605
                                "model": "admin",
506
606
                                "machines": M{
507
607
                                        "0": machine0,
508
608
                                        "1": machine1,
525
625
                                                                        "message": "You Require More Vespene Gas",
526
626
                                                                        "since":   "01 Apr 15 01:23+10:00",
527
627
                                                                },
528
 
                                                                "agent-status": M{
 
628
                                                                "juju-status": M{
529
629
                                                                        "current": "idle",
530
630
                                                                        "since":   "01 Apr 15 01:23+10:00",
531
631
                                                                },
532
632
                                                                "open-ports": L{
533
633
                                                                        "2/tcp", "3/tcp", "2/udp", "10/udp",
534
634
                                                                },
535
 
                                                                "public-address": "dummymodel-2.dns",
 
635
                                                                "public-address": "admin-2.dns",
536
636
                                                        },
537
637
                                                },
538
638
                                        },
550
650
                                                                        "current": "terminated",
551
651
                                                                        "since":   "01 Apr 15 01:23+10:00",
552
652
                                                                },
553
 
                                                                "agent-status": M{
 
653
                                                                "juju-status": M{
554
654
                                                                        "current": "idle",
555
655
                                                                        "since":   "01 Apr 15 01:23+10:00",
556
656
                                                                },
557
 
                                                                "public-address": "dummymodel-1.dns",
 
657
                                                                "public-address": "admin-1.dns",
558
658
                                                        },
559
659
                                                },
560
660
                                        },
566
666
                addMachine{machineId: "3", job: state.JobHostUnits},
567
667
                startMachine{"3"},
568
668
                // Simulate some status with info, while the agent is down.
569
 
                setAddresses{"3", network.NewAddresses("dummymodel-3.dns")},
570
 
                setMachineStatus{"3", state.StatusStopped, "Really?"},
 
669
                setAddresses{"3", network.NewAddresses("admin-3.dns")},
 
670
                setMachineStatus{"3", status.StatusStopped, "Really?"},
571
671
                addMachine{machineId: "4", job: state.JobHostUnits},
572
 
                setAddresses{"4", network.NewAddresses("dummymodel-4.dns")},
 
672
                setAddresses{"4", network.NewAddresses("admin-4.dns")},
573
673
                startAliveMachine{"4"},
574
 
                setMachineStatus{"4", state.StatusError, "Beware the red toys"},
 
674
                setMachineStatus{"4", status.StatusError, "Beware the red toys"},
575
675
                ensureDyingUnit{"dummy-service/0"},
576
676
                addMachine{machineId: "5", job: state.JobHostUnits},
577
677
                ensureDeadMachine{"5"},
578
678
                expect{
579
679
                        "add three more machine, one with a dead agent, one in error state and one dead itself; also one dying unit",
580
680
                        M{
581
 
                                "model": "dummymodel",
 
681
                                "model": "admin",
582
682
                                "machines": M{
583
683
                                        "0": machine0,
584
684
                                        "1": machine1,
585
685
                                        "2": machine2,
586
686
                                        "3": M{
587
 
                                                "dns-name":         "dummymodel-3.dns",
588
 
                                                "instance-id":      "dummymodel-3",
589
 
                                                "agent-state":      "stopped",
590
 
                                                "agent-state-info": "Really?",
591
 
                                                "series":           "quantal",
592
 
                                                "hardware":         "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
 
687
                                                "dns-name":    "admin-3.dns",
 
688
                                                "instance-id": "admin-3",
 
689
                                                "machine-status": M{
 
690
                                                        "current": "pending",
 
691
                                                        "since":   "01 Apr 15 01:23+10:00",
 
692
                                                },
 
693
                                                "juju-status": M{
 
694
                                                        "current": "stopped",
 
695
                                                        "message": "Really?",
 
696
                                                        "since":   "01 Apr 15 01:23+10:00",
 
697
                                                },
 
698
                                                "series":   "quantal",
 
699
                                                "hardware": "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
593
700
                                        },
594
701
                                        "4": M{
595
 
                                                "dns-name":         "dummymodel-4.dns",
596
 
                                                "instance-id":      "dummymodel-4",
597
 
                                                "agent-state":      "error",
598
 
                                                "agent-state-info": "Beware the red toys",
599
 
                                                "series":           "quantal",
600
 
                                                "hardware":         "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
 
702
                                                "dns-name":    "admin-4.dns",
 
703
                                                "instance-id": "admin-4",
 
704
                                                "machine-status": M{
 
705
                                                        "current": "pending",
 
706
                                                        "since":   "01 Apr 15 01:23+10:00",
 
707
                                                },
 
708
                                                "juju-status": M{
 
709
                                                        "current": "error",
 
710
                                                        "message": "Beware the red toys",
 
711
                                                        "since":   "01 Apr 15 01:23+10:00",
 
712
                                                },
 
713
                                                "series":   "quantal",
 
714
                                                "hardware": "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
601
715
                                        },
602
716
                                        "5": M{
603
 
                                                "agent-state": "pending",
604
 
                                                "life":        "dead",
 
717
                                                "juju-status": M{
 
718
                                                        "current": "pending",
 
719
                                                        "since":   "01 Apr 15 01:23+10:00",
 
720
                                                        "life":    "dead",
 
721
                                                },
605
722
                                                "instance-id": "pending",
606
 
                                                "series":      "quantal",
 
723
                                                "machine-status": M{
 
724
                                                        "current": "pending",
 
725
                                                        "since":   "01 Apr 15 01:23+10:00",
 
726
                                                },
 
727
                                                "series": "quantal",
607
728
                                        },
608
729
                                },
609
730
                                "services": M{
623
744
                                                                        "message": "You Require More Vespene Gas",
624
745
                                                                        "since":   "01 Apr 15 01:23+10:00",
625
746
                                                                },
626
 
                                                                "agent-status": M{
 
747
                                                                "juju-status": M{
627
748
                                                                        "current": "idle",
628
749
                                                                        "since":   "01 Apr 15 01:23+10:00",
629
750
                                                                },
630
751
                                                                "open-ports": L{
631
752
                                                                        "2/tcp", "3/tcp", "2/udp", "10/udp",
632
753
                                                                },
633
 
                                                                "public-address": "dummymodel-2.dns",
 
754
                                                                "public-address": "admin-2.dns",
634
755
                                                        },
635
756
                                                },
636
757
                                        },
648
769
                                                                        "current": "terminated",
649
770
                                                                        "since":   "01 Apr 15 01:23+10:00",
650
771
                                                                },
651
 
                                                                "agent-status": M{
 
772
                                                                "juju-status": M{
652
773
                                                                        "current": "idle",
653
774
                                                                        "since":   "01 Apr 15 01:23+10:00",
654
775
                                                                },
655
 
                                                                "public-address": "dummymodel-1.dns",
 
776
                                                                "public-address": "admin-1.dns",
656
777
                                                        },
657
778
                                                },
658
779
                                        },
665
786
                        "scope status on dummy-service/0 unit",
666
787
                        []string{"dummy-service/0"},
667
788
                        M{
668
 
                                "model": "dummymodel",
 
789
                                "model": "admin",
669
790
                                "machines": M{
670
791
                                        "1": machine1,
671
792
                                },
684
805
                                                                        "current": "terminated",
685
806
                                                                        "since":   "01 Apr 15 01:23+10:00",
686
807
                                                                },
687
 
                                                                "agent-status": M{
 
808
                                                                "juju-status": M{
688
809
                                                                        "current": "idle",
689
810
                                                                        "since":   "01 Apr 15 01:23+10:00",
690
811
                                                                },
691
 
                                                                "public-address": "dummymodel-1.dns",
 
812
                                                                "public-address": "admin-1.dns",
692
813
                                                        },
693
814
                                                },
694
815
                                        },
699
820
                        "scope status on exposed-service service",
700
821
                        []string{"exposed-service"},
701
822
                        M{
702
 
                                "model": "dummymodel",
 
823
                                "model": "admin",
703
824
                                "machines": M{
704
825
                                        "2": machine2,
705
826
                                },
720
841
                                                                        "message": "You Require More Vespene Gas",
721
842
                                                                        "since":   "01 Apr 15 01:23+10:00",
722
843
                                                                },
723
 
                                                                "agent-status": M{
 
844
                                                                "juju-status": M{
724
845
                                                                        "current": "idle",
725
846
                                                                        "since":   "01 Apr 15 01:23+10:00",
726
847
                                                                },
727
848
                                                                "open-ports": L{
728
849
                                                                        "2/tcp", "3/tcp", "2/udp", "10/udp",
729
850
                                                                },
730
 
                                                                "public-address": "dummymodel-2.dns",
 
851
                                                                "public-address": "admin-2.dns",
731
852
                                                        },
732
853
                                                },
733
854
                                        },
738
859
                        "scope status on service pattern",
739
860
                        []string{"d*-service"},
740
861
                        M{
741
 
                                "model": "dummymodel",
 
862
                                "model": "admin",
742
863
                                "machines": M{
743
864
                                        "1": machine1,
744
865
                                },
757
878
                                                                        "current": "terminated",
758
879
                                                                        "since":   "01 Apr 15 01:23+10:00",
759
880
                                                                },
760
 
                                                                "agent-status": M{
 
881
                                                                "juju-status": M{
761
882
                                                                        "current": "idle",
762
883
                                                                        "since":   "01 Apr 15 01:23+10:00",
763
884
                                                                },
764
 
                                                                "public-address": "dummymodel-1.dns",
 
885
                                                                "public-address": "admin-1.dns",
765
886
                                                        },
766
887
                                                },
767
888
                                        },
772
893
                        "scope status on unit pattern",
773
894
                        []string{"e*posed-service/*"},
774
895
                        M{
775
 
                                "model": "dummymodel",
 
896
                                "model": "admin",
776
897
                                "machines": M{
777
898
                                        "2": machine2,
778
899
                                },
793
914
                                                                        "message": "You Require More Vespene Gas",
794
915
                                                                        "since":   "01 Apr 15 01:23+10:00",
795
916
                                                                },
796
 
                                                                "agent-status": M{
 
917
                                                                "juju-status": M{
797
918
                                                                        "current": "idle",
798
919
                                                                        "since":   "01 Apr 15 01:23+10:00",
799
920
                                                                },
800
921
                                                                "open-ports": L{
801
922
                                                                        "2/tcp", "3/tcp", "2/udp", "10/udp",
802
923
                                                                },
803
 
                                                                "public-address": "dummymodel-2.dns",
 
924
                                                                "public-address": "admin-2.dns",
804
925
                                                        },
805
926
                                                },
806
927
                                        },
811
932
                        "scope status on combination of service and unit patterns",
812
933
                        []string{"exposed-service", "dummy-service", "e*posed-service/*", "dummy-service/*"},
813
934
                        M{
814
 
                                "model": "dummymodel",
 
935
                                "model": "admin",
815
936
                                "machines": M{
816
937
                                        "1": machine1,
817
938
                                        "2": machine2,
831
952
                                                                        "current": "terminated",
832
953
                                                                        "since":   "01 Apr 15 01:23+10:00",
833
954
                                                                },
834
 
                                                                "agent-status": M{
 
955
                                                                "juju-status": M{
835
956
                                                                        "current": "idle",
836
957
                                                                        "since":   "01 Apr 15 01:23+10:00",
837
958
                                                                },
838
 
                                                                "public-address": "dummymodel-1.dns",
 
959
                                                                "public-address": "admin-1.dns",
839
960
                                                        },
840
961
                                                },
841
962
                                        },
855
976
                                                                        "message": "You Require More Vespene Gas",
856
977
                                                                        "since":   "01 Apr 15 01:23+10:00",
857
978
                                                                },
858
 
                                                                "agent-status": M{
 
979
                                                                "juju-status": M{
859
980
                                                                        "current": "idle",
860
981
                                                                        "since":   "01 Apr 15 01:23+10:00",
861
982
                                                                },
862
983
                                                                "open-ports": L{
863
984
                                                                        "2/tcp", "3/tcp", "2/udp", "10/udp",
864
985
                                                                },
865
 
                                                                "public-address": "dummymodel-2.dns",
 
986
                                                                "public-address": "admin-2.dns",
866
987
                                                        },
867
988
                                                },
868
989
                                        },
873
994
        test( // 5
874
995
                "a unit with a hook relation error",
875
996
                addMachine{machineId: "0", job: state.JobManageModel},
876
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
997
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
877
998
                startAliveMachine{"0"},
878
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
999
                setMachineStatus{"0", status.StatusStarted, ""},
879
1000
 
880
1001
                addMachine{machineId: "1", job: state.JobHostUnits},
881
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
1002
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
882
1003
                startAliveMachine{"1"},
883
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
1004
                setMachineStatus{"1", status.StatusStarted, ""},
884
1005
 
885
1006
                addCharm{"wordpress"},
886
1007
                addService{name: "wordpress", charm: "wordpress"},
892
1013
 
893
1014
                relateServices{"wordpress", "mysql"},
894
1015
 
895
 
                setAgentStatus{"wordpress/0", state.StatusError,
 
1016
                setAgentStatus{"wordpress/0", status.StatusError,
896
1017
                        "hook failed: some-relation-changed",
897
1018
                        map[string]interface{}{"relation-id": 0}},
898
1019
 
899
1020
                expect{
900
1021
                        "a unit with a hook relation error",
901
1022
                        M{
902
 
                                "model": "dummymodel",
 
1023
                                "model": "admin",
903
1024
                                "machines": M{
904
1025
                                        "0": machine0,
905
1026
                                        "1": machine1,
924
1045
                                                                        "message": "hook failed: some-relation-changed for mysql:server",
925
1046
                                                                        "since":   "01 Apr 15 01:23+10:00",
926
1047
                                                                },
927
 
                                                                "agent-status": M{
 
1048
                                                                "juju-status": M{
928
1049
                                                                        "current": "idle",
929
1050
                                                                        "since":   "01 Apr 15 01:23+10:00",
930
1051
                                                                },
931
 
                                                                "public-address": "dummymodel-1.dns",
 
1052
                                                                "public-address": "admin-1.dns",
932
1053
                                                        },
933
1054
                                                },
934
1055
                                        },
951
1072
                                                                        "message": "Waiting for agent initialization to finish",
952
1073
                                                                        "since":   "01 Apr 15 01:23+10:00",
953
1074
                                                                },
954
 
                                                                "agent-status": M{
 
1075
                                                                "juju-status": M{
955
1076
                                                                        "current": "allocating",
956
1077
                                                                        "since":   "01 Apr 15 01:23+10:00",
957
1078
                                                                },
958
 
                                                                "public-address": "dummymodel-1.dns",
 
1079
                                                                "public-address": "admin-1.dns",
959
1080
                                                        },
960
1081
                                                },
961
1082
                                        },
966
1087
        test( // 6
967
1088
                "a unit with a hook relation error when the agent is down",
968
1089
                addMachine{machineId: "0", job: state.JobManageModel},
969
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
1090
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
970
1091
                startAliveMachine{"0"},
971
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
1092
                setMachineStatus{"0", status.StatusStarted, ""},
972
1093
 
973
1094
                addMachine{machineId: "1", job: state.JobHostUnits},
974
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
1095
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
975
1096
                startAliveMachine{"1"},
976
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
1097
                setMachineStatus{"1", status.StatusStarted, ""},
977
1098
 
978
1099
                addCharm{"wordpress"},
979
1100
                addService{name: "wordpress", charm: "wordpress"},
985
1106
 
986
1107
                relateServices{"wordpress", "mysql"},
987
1108
 
988
 
                setAgentStatus{"wordpress/0", state.StatusError,
 
1109
                setAgentStatus{"wordpress/0", status.StatusError,
989
1110
                        "hook failed: some-relation-changed",
990
1111
                        map[string]interface{}{"relation-id": 0}},
991
1112
 
992
1113
                expect{
993
1114
                        "a unit with a hook relation error when the agent is down",
994
1115
                        M{
995
 
                                "model": "dummymodel",
 
1116
                                "model": "admin",
996
1117
                                "machines": M{
997
1118
                                        "0": machine0,
998
1119
                                        "1": machine1,
1017
1138
                                                                        "message": "hook failed: some-relation-changed for mysql:server",
1018
1139
                                                                        "since":   "01 Apr 15 01:23+10:00",
1019
1140
                                                                },
1020
 
                                                                "agent-status": M{
 
1141
                                                                "juju-status": M{
1021
1142
                                                                        "current": "idle",
1022
1143
                                                                        "since":   "01 Apr 15 01:23+10:00",
1023
1144
                                                                },
1024
 
                                                                "public-address": "dummymodel-1.dns",
 
1145
                                                                "public-address": "admin-1.dns",
1025
1146
                                                        },
1026
1147
                                                },
1027
1148
                                        },
1044
1165
                                                                        "message": "Waiting for agent initialization to finish",
1045
1166
                                                                        "since":   "01 Apr 15 01:23+10:00",
1046
1167
                                                                },
1047
 
                                                                "agent-status": M{
 
1168
                                                                "juju-status": M{
1048
1169
                                                                        "current": "allocating",
1049
1170
                                                                        "since":   "01 Apr 15 01:23+10:00",
1050
1171
                                                                },
1051
 
                                                                "public-address": "dummymodel-1.dns",
 
1172
                                                                "public-address": "admin-1.dns",
1052
1173
                                                        },
1053
1174
                                                },
1054
1175
                                        },
1066
1187
                expect{
1067
1188
                        "service shows life==dying",
1068
1189
                        M{
1069
 
                                "model": "dummymodel",
 
1190
                                "model": "admin",
1070
1191
                                "machines": M{
1071
1192
                                        "0": M{
1072
 
                                                "agent-state": "pending",
 
1193
                                                "juju-status": M{
 
1194
                                                        "current": "pending",
 
1195
                                                        "since":   "01 Apr 15 01:23+10:00",
 
1196
                                                },
1073
1197
                                                "instance-id": "pending",
1074
 
                                                "series":      "quantal",
 
1198
                                                "machine-status": M{
 
1199
                                                        "current": "pending",
 
1200
                                                        "since":   "01 Apr 15 01:23+10:00",
 
1201
                                                },
 
1202
 
 
1203
                                                "series": "quantal",
1075
1204
                                        },
1076
1205
                                },
1077
1206
                                "services": M{
1092
1221
                                                                        "message": "Waiting for agent initialization to finish",
1093
1222
                                                                        "since":   "01 Apr 15 01:23+10:00",
1094
1223
                                                                },
1095
 
                                                                "agent-status": M{
 
1224
                                                                "juju-status": M{
1096
1225
                                                                        "current": "allocating",
1097
1226
                                                                        "since":   "01 Apr 15 01:23+10:00",
1098
1227
                                                                },
1109
1238
                addService{name: "dummy-service", charm: "dummy"},
1110
1239
                addMachine{machineId: "0", job: state.JobHostUnits},
1111
1240
                startAliveMachine{"0"},
1112
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
1241
                setMachineStatus{"0", status.StatusStarted, ""},
1113
1242
                addUnit{"dummy-service", "0"},
1114
 
                setAgentStatus{"dummy-service/0", state.StatusIdle, "", nil},
1115
 
                setUnitStatus{"dummy-service/0", state.StatusActive, "", nil},
 
1243
                setAgentStatus{"dummy-service/0", status.StatusIdle, "", nil},
 
1244
                setUnitStatus{"dummy-service/0", status.StatusActive, "", nil},
1116
1245
                expect{
1117
1246
                        "unit shows that agent is lost",
1118
1247
                        M{
1119
 
                                "model": "dummymodel",
 
1248
                                "model": "admin",
1120
1249
                                "machines": M{
1121
1250
                                        "0": M{
1122
 
                                                "agent-state": "started",
1123
 
                                                "instance-id": "dummymodel-0",
1124
 
                                                "series":      "quantal",
1125
 
                                                "hardware":    "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
 
1251
                                                "juju-status": M{
 
1252
                                                        "current": "started",
 
1253
                                                        "since":   "01 Apr 15 01:23+10:00",
 
1254
                                                },
 
1255
                                                "instance-id": "admin-0",
 
1256
                                                "machine-status": M{
 
1257
                                                        "current": "pending",
 
1258
                                                        "since":   "01 Apr 15 01:23+10:00",
 
1259
                                                },
 
1260
 
 
1261
                                                "series":   "quantal",
 
1262
                                                "hardware": "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
1126
1263
                                        },
1127
1264
                                },
1128
1265
                                "services": M{
1141
1278
                                                                        "message": "agent is lost, sorry! See 'juju status-history dummy-service/0'",
1142
1279
                                                                        "since":   "01 Apr 15 01:23+10:00",
1143
1280
                                                                },
1144
 
                                                                "agent-status": M{
 
1281
                                                                "juju-status": M{
1145
1282
                                                                        "current": "lost",
1146
1283
                                                                        "message": "agent is not communicating with the server",
1147
1284
                                                                        "since":   "01 Apr 15 01:23+10:00",
1158
1295
        test( // 9
1159
1296
                "complex scenario with multiple related services",
1160
1297
                addMachine{machineId: "0", job: state.JobManageModel},
1161
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
1298
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
1162
1299
                startAliveMachine{"0"},
1163
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
1300
                setMachineStatus{"0", status.StatusStarted, ""},
1164
1301
                addCharm{"wordpress"},
1165
1302
                addCharm{"mysql"},
1166
1303
                addCharm{"varnish"},
1168
1305
                addService{name: "project", charm: "wordpress"},
1169
1306
                setServiceExposed{"project", true},
1170
1307
                addMachine{machineId: "1", job: state.JobHostUnits},
1171
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
1308
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
1172
1309
                startAliveMachine{"1"},
1173
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
1310
                setMachineStatus{"1", status.StatusStarted, ""},
1174
1311
                addAliveUnit{"project", "1"},
1175
 
                setAgentStatus{"project/0", state.StatusIdle, "", nil},
1176
 
                setUnitStatus{"project/0", state.StatusActive, "", nil},
 
1312
                setAgentStatus{"project/0", status.StatusIdle, "", nil},
 
1313
                setUnitStatus{"project/0", status.StatusActive, "", nil},
1177
1314
 
1178
1315
                addService{name: "mysql", charm: "mysql"},
1179
1316
                setServiceExposed{"mysql", true},
1180
1317
                addMachine{machineId: "2", job: state.JobHostUnits},
1181
 
                setAddresses{"2", network.NewAddresses("dummymodel-2.dns")},
 
1318
                setAddresses{"2", network.NewAddresses("admin-2.dns")},
1182
1319
                startAliveMachine{"2"},
1183
 
                setMachineStatus{"2", state.StatusStarted, ""},
 
1320
                setMachineStatus{"2", status.StatusStarted, ""},
1184
1321
                addAliveUnit{"mysql", "2"},
1185
 
                setAgentStatus{"mysql/0", state.StatusIdle, "", nil},
1186
 
                setUnitStatus{"mysql/0", state.StatusActive, "", nil},
 
1322
                setAgentStatus{"mysql/0", status.StatusIdle, "", nil},
 
1323
                setUnitStatus{"mysql/0", status.StatusActive, "", nil},
1187
1324
 
1188
1325
                addService{name: "varnish", charm: "varnish"},
1189
1326
                setServiceExposed{"varnish", true},
1190
1327
                addMachine{machineId: "3", job: state.JobHostUnits},
1191
 
                setAddresses{"3", network.NewAddresses("dummymodel-3.dns")},
 
1328
                setAddresses{"3", network.NewAddresses("admin-3.dns")},
1192
1329
                startAliveMachine{"3"},
1193
 
                setMachineStatus{"3", state.StatusStarted, ""},
 
1330
                setMachineStatus{"3", status.StatusStarted, ""},
1194
1331
                addAliveUnit{"varnish", "3"},
1195
1332
 
1196
1333
                addService{name: "private", charm: "wordpress"},
1197
1334
                setServiceExposed{"private", true},
1198
1335
                addMachine{machineId: "4", job: state.JobHostUnits},
1199
 
                setAddresses{"4", network.NewAddresses("dummymodel-4.dns")},
 
1336
                setAddresses{"4", network.NewAddresses("admin-4.dns")},
1200
1337
                startAliveMachine{"4"},
1201
 
                setMachineStatus{"4", state.StatusStarted, ""},
 
1338
                setMachineStatus{"4", status.StatusStarted, ""},
1202
1339
                addAliveUnit{"private", "4"},
1203
1340
 
1204
1341
                relateServices{"project", "mysql"},
1208
1345
                expect{
1209
1346
                        "multiples services with relations between some of them",
1210
1347
                        M{
1211
 
                                "model": "dummymodel",
 
1348
                                "model": "admin",
1212
1349
                                "machines": M{
1213
1350
                                        "0": machine0,
1214
1351
                                        "1": machine1,
1231
1368
                                                                        "current": "active",
1232
1369
                                                                        "since":   "01 Apr 15 01:23+10:00",
1233
1370
                                                                },
1234
 
                                                                "agent-status": M{
 
1371
                                                                "juju-status": M{
1235
1372
                                                                        "current": "idle",
1236
1373
                                                                        "since":   "01 Apr 15 01:23+10:00",
1237
1374
                                                                },
1238
 
                                                                "public-address": "dummymodel-1.dns",
 
1375
                                                                "public-address": "admin-1.dns",
1239
1376
                                                        },
1240
1377
                                                },
1241
1378
                                                "relations": M{
1257
1394
                                                                        "current": "active",
1258
1395
                                                                        "since":   "01 Apr 15 01:23+10:00",
1259
1396
                                                                },
1260
 
                                                                "agent-status": M{
 
1397
                                                                "juju-status": M{
1261
1398
                                                                        "current": "idle",
1262
1399
                                                                        "since":   "01 Apr 15 01:23+10:00",
1263
1400
                                                                },
1264
 
                                                                "public-address": "dummymodel-2.dns",
 
1401
                                                                "public-address": "admin-2.dns",
1265
1402
                                                        },
1266
1403
                                                },
1267
1404
                                                "relations": M{
1284
1421
                                                                        "message": "Waiting for agent initialization to finish",
1285
1422
                                                                        "since":   "01 Apr 15 01:23+10:00",
1286
1423
                                                                },
1287
 
                                                                "agent-status": M{
 
1424
                                                                "juju-status": M{
1288
1425
                                                                        "current": "allocating",
1289
1426
                                                                        "since":   "01 Apr 15 01:23+10:00",
1290
1427
                                                                },
1291
 
                                                                "public-address": "dummymodel-3.dns",
 
1428
                                                                "public-address": "admin-3.dns",
1292
1429
                                                        },
1293
1430
                                                },
1294
1431
                                                "relations": M{
1311
1448
                                                                        "message": "Waiting for agent initialization to finish",
1312
1449
                                                                        "since":   "01 Apr 15 01:23+10:00",
1313
1450
                                                                },
1314
 
                                                                "agent-status": M{
 
1451
                                                                "juju-status": M{
1315
1452
                                                                        "current": "allocating",
1316
1453
                                                                        "since":   "01 Apr 15 01:23+10:00",
1317
1454
                                                                },
1318
 
                                                                "public-address": "dummymodel-4.dns",
 
1455
                                                                "public-address": "admin-4.dns",
1319
1456
                                                        },
1320
1457
                                                },
1321
1458
                                                "relations": M{
1329
1466
        test( // 10
1330
1467
                "simple peer scenario",
1331
1468
                addMachine{machineId: "0", job: state.JobManageModel},
1332
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
1469
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
1333
1470
                startAliveMachine{"0"},
1334
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
1471
                setMachineStatus{"0", status.StatusStarted, ""},
1335
1472
                addCharm{"riak"},
1336
1473
                addCharm{"wordpress"},
1337
1474
 
1338
1475
                addService{name: "riak", charm: "riak"},
1339
1476
                setServiceExposed{"riak", true},
1340
1477
                addMachine{machineId: "1", job: state.JobHostUnits},
1341
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
1478
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
1342
1479
                startAliveMachine{"1"},
1343
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
1480
                setMachineStatus{"1", status.StatusStarted, ""},
1344
1481
                addAliveUnit{"riak", "1"},
1345
 
                setAgentStatus{"riak/0", state.StatusIdle, "", nil},
1346
 
                setUnitStatus{"riak/0", state.StatusActive, "", nil},
 
1482
                setAgentStatus{"riak/0", status.StatusIdle, "", nil},
 
1483
                setUnitStatus{"riak/0", status.StatusActive, "", nil},
1347
1484
                addMachine{machineId: "2", job: state.JobHostUnits},
1348
 
                setAddresses{"2", network.NewAddresses("dummymodel-2.dns")},
 
1485
                setAddresses{"2", network.NewAddresses("admin-2.dns")},
1349
1486
                startAliveMachine{"2"},
1350
 
                setMachineStatus{"2", state.StatusStarted, ""},
 
1487
                setMachineStatus{"2", status.StatusStarted, ""},
1351
1488
                addAliveUnit{"riak", "2"},
1352
 
                setAgentStatus{"riak/1", state.StatusIdle, "", nil},
1353
 
                setUnitStatus{"riak/1", state.StatusActive, "", nil},
 
1489
                setAgentStatus{"riak/1", status.StatusIdle, "", nil},
 
1490
                setUnitStatus{"riak/1", status.StatusActive, "", nil},
1354
1491
                addMachine{machineId: "3", job: state.JobHostUnits},
1355
 
                setAddresses{"3", network.NewAddresses("dummymodel-3.dns")},
 
1492
                setAddresses{"3", network.NewAddresses("admin-3.dns")},
1356
1493
                startAliveMachine{"3"},
1357
 
                setMachineStatus{"3", state.StatusStarted, ""},
 
1494
                setMachineStatus{"3", status.StatusStarted, ""},
1358
1495
                addAliveUnit{"riak", "3"},
1359
 
                setAgentStatus{"riak/2", state.StatusIdle, "", nil},
1360
 
                setUnitStatus{"riak/2", state.StatusActive, "", nil},
 
1496
                setAgentStatus{"riak/2", status.StatusIdle, "", nil},
 
1497
                setUnitStatus{"riak/2", status.StatusActive, "", nil},
1361
1498
 
1362
1499
                expect{
1363
1500
                        "multiples related peer units",
1364
1501
                        M{
1365
 
                                "model": "dummymodel",
 
1502
                                "model": "admin",
1366
1503
                                "machines": M{
1367
1504
                                        "0": machine0,
1368
1505
                                        "1": machine1,
1384
1521
                                                                        "current": "active",
1385
1522
                                                                        "since":   "01 Apr 15 01:23+10:00",
1386
1523
                                                                },
1387
 
                                                                "agent-status": M{
 
1524
                                                                "juju-status": M{
1388
1525
                                                                        "current": "idle",
1389
1526
                                                                        "since":   "01 Apr 15 01:23+10:00",
1390
1527
                                                                },
1391
 
                                                                "public-address": "dummymodel-1.dns",
 
1528
                                                                "public-address": "admin-1.dns",
1392
1529
                                                        },
1393
1530
                                                        "riak/1": M{
1394
1531
                                                                "machine": "2",
1396
1533
                                                                        "current": "active",
1397
1534
                                                                        "since":   "01 Apr 15 01:23+10:00",
1398
1535
                                                                },
1399
 
                                                                "agent-status": M{
 
1536
                                                                "juju-status": M{
1400
1537
                                                                        "current": "idle",
1401
1538
                                                                        "since":   "01 Apr 15 01:23+10:00",
1402
1539
                                                                },
1403
 
                                                                "public-address": "dummymodel-2.dns",
 
1540
                                                                "public-address": "admin-2.dns",
1404
1541
                                                        },
1405
1542
                                                        "riak/2": M{
1406
1543
                                                                "machine": "3",
1408
1545
                                                                        "current": "active",
1409
1546
                                                                        "since":   "01 Apr 15 01:23+10:00",
1410
1547
                                                                },
1411
 
                                                                "agent-status": M{
 
1548
                                                                "juju-status": M{
1412
1549
                                                                        "current": "idle",
1413
1550
                                                                        "since":   "01 Apr 15 01:23+10:00",
1414
1551
                                                                },
1415
 
                                                                "public-address": "dummymodel-3.dns",
 
1552
                                                                "public-address": "admin-3.dns",
1416
1553
                                                        },
1417
1554
                                                },
1418
1555
                                                "relations": M{
1428
1565
        test( // 11
1429
1566
                "one service with one subordinate service",
1430
1567
                addMachine{machineId: "0", job: state.JobManageModel},
1431
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
1568
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
1432
1569
                startAliveMachine{"0"},
1433
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
1570
                setMachineStatus{"0", status.StatusStarted, ""},
1434
1571
                addCharm{"wordpress"},
1435
1572
                addCharm{"mysql"},
1436
1573
                addCharm{"logging"},
1438
1575
                addService{name: "wordpress", charm: "wordpress"},
1439
1576
                setServiceExposed{"wordpress", true},
1440
1577
                addMachine{machineId: "1", job: state.JobHostUnits},
1441
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
1578
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
1442
1579
                startAliveMachine{"1"},
1443
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
1580
                setMachineStatus{"1", status.StatusStarted, ""},
1444
1581
                addAliveUnit{"wordpress", "1"},
1445
 
                setAgentStatus{"wordpress/0", state.StatusIdle, "", nil},
1446
 
                setUnitStatus{"wordpress/0", state.StatusActive, "", nil},
 
1582
                setAgentStatus{"wordpress/0", status.StatusIdle, "", nil},
 
1583
                setUnitStatus{"wordpress/0", status.StatusActive, "", nil},
1447
1584
 
1448
1585
                addService{name: "mysql", charm: "mysql"},
1449
1586
                setServiceExposed{"mysql", true},
1450
1587
                addMachine{machineId: "2", job: state.JobHostUnits},
1451
 
                setAddresses{"2", network.NewAddresses("dummymodel-2.dns")},
 
1588
                setAddresses{"2", network.NewAddresses("admin-2.dns")},
1452
1589
                startAliveMachine{"2"},
1453
 
                setMachineStatus{"2", state.StatusStarted, ""},
 
1590
                setMachineStatus{"2", status.StatusStarted, ""},
1454
1591
                addAliveUnit{"mysql", "2"},
1455
 
                setAgentStatus{"mysql/0", state.StatusIdle, "", nil},
1456
 
                setUnitStatus{"mysql/0", state.StatusActive, "", nil},
 
1592
                setAgentStatus{"mysql/0", status.StatusIdle, "", nil},
 
1593
                setUnitStatus{"mysql/0", status.StatusActive, "", nil},
1457
1594
 
1458
1595
                addService{name: "logging", charm: "logging"},
1459
1596
                setServiceExposed{"logging", true},
1466
1603
                addSubordinate{"mysql/0", "logging"},
1467
1604
 
1468
1605
                setUnitsAlive{"logging"},
1469
 
                setAgentStatus{"logging/0", state.StatusIdle, "", nil},
1470
 
                setUnitStatus{"logging/0", state.StatusActive, "", nil},
1471
 
                setAgentStatus{"logging/1", state.StatusError, "somehow lost in all those logs", nil},
 
1606
                setAgentStatus{"logging/0", status.StatusIdle, "", nil},
 
1607
                setUnitStatus{"logging/0", status.StatusActive, "", nil},
 
1608
                setAgentStatus{"logging/1", status.StatusError, "somehow lost in all those logs", nil},
1472
1609
 
1473
1610
                expect{
1474
1611
                        "multiples related peer units",
1475
1612
                        M{
1476
 
                                "model": "dummymodel",
 
1613
                                "model": "admin",
1477
1614
                                "machines": M{
1478
1615
                                        "0": machine0,
1479
1616
                                        "1": machine1,
1494
1631
                                                                        "current": "active",
1495
1632
                                                                        "since":   "01 Apr 15 01:23+10:00",
1496
1633
                                                                },
1497
 
                                                                "agent-status": M{
 
1634
                                                                "juju-status": M{
1498
1635
                                                                        "current": "idle",
1499
1636
                                                                        "since":   "01 Apr 15 01:23+10:00",
1500
1637
                                                                },
1504
1641
                                                                                        "current": "active",
1505
1642
                                                                                        "since":   "01 Apr 15 01:23+10:00",
1506
1643
                                                                                },
1507
 
                                                                                "agent-status": M{
 
1644
                                                                                "juju-status": M{
1508
1645
                                                                                        "current": "idle",
1509
1646
                                                                                        "since":   "01 Apr 15 01:23+10:00",
1510
1647
                                                                                },
1511
 
                                                                                "public-address": "dummymodel-1.dns",
 
1648
                                                                                "public-address": "admin-1.dns",
1512
1649
                                                                        },
1513
1650
                                                                },
1514
 
                                                                "public-address": "dummymodel-1.dns",
 
1651
                                                                "public-address": "admin-1.dns",
1515
1652
                                                        },
1516
1653
                                                },
1517
1654
                                                "relations": M{
1533
1670
                                                                        "current": "active",
1534
1671
                                                                        "since":   "01 Apr 15 01:23+10:00",
1535
1672
                                                                },
1536
 
                                                                "agent-status": M{
 
1673
                                                                "juju-status": M{
1537
1674
                                                                        "current": "idle",
1538
1675
                                                                        "since":   "01 Apr 15 01:23+10:00",
1539
1676
                                                                },
1544
1681
                                                                                        "message": "somehow lost in all those logs",
1545
1682
                                                                                        "since":   "01 Apr 15 01:23+10:00",
1546
1683
                                                                                },
1547
 
                                                                                "agent-status": M{
 
1684
                                                                                "juju-status": M{
1548
1685
                                                                                        "current": "idle",
1549
1686
                                                                                        "since":   "01 Apr 15 01:23+10:00",
1550
1687
                                                                                },
1551
 
                                                                                "public-address": "dummymodel-2.dns",
 
1688
                                                                                "public-address": "admin-2.dns",
1552
1689
                                                                        },
1553
1690
                                                                },
1554
 
                                                                "public-address": "dummymodel-2.dns",
 
1691
                                                                "public-address": "admin-2.dns",
1555
1692
                                                        },
1556
1693
                                                },
1557
1694
                                                "relations": M{
1578
1715
                        "subordinates scoped on logging",
1579
1716
                        []string{"logging"},
1580
1717
                        M{
1581
 
                                "model": "dummymodel",
 
1718
                                "model": "admin",
1582
1719
                                "machines": M{
1583
1720
                                        "1": machine1,
1584
1721
                                        "2": machine2,
1598
1735
                                                                        "current": "active",
1599
1736
                                                                        "since":   "01 Apr 15 01:23+10:00",
1600
1737
                                                                },
1601
 
                                                                "agent-status": M{
 
1738
                                                                "juju-status": M{
1602
1739
                                                                        "current": "idle",
1603
1740
                                                                        "since":   "01 Apr 15 01:23+10:00",
1604
1741
                                                                },
1608
1745
                                                                                        "current": "active",
1609
1746
                                                                                        "since":   "01 Apr 15 01:23+10:00",
1610
1747
                                                                                },
1611
 
                                                                                "agent-status": M{
 
1748
                                                                                "juju-status": M{
1612
1749
                                                                                        "current": "idle",
1613
1750
                                                                                        "since":   "01 Apr 15 01:23+10:00",
1614
1751
                                                                                },
1615
 
                                                                                "public-address": "dummymodel-1.dns",
 
1752
                                                                                "public-address": "admin-1.dns",
1616
1753
                                                                        },
1617
1754
                                                                },
1618
 
                                                                "public-address": "dummymodel-1.dns",
 
1755
                                                                "public-address": "admin-1.dns",
1619
1756
                                                        },
1620
1757
                                                },
1621
1758
                                                "relations": M{
1637
1774
                                                                        "current": "active",
1638
1775
                                                                        "since":   "01 Apr 15 01:23+10:00",
1639
1776
                                                                },
1640
 
                                                                "agent-status": M{
 
1777
                                                                "juju-status": M{
1641
1778
                                                                        "current": "idle",
1642
1779
                                                                        "since":   "01 Apr 15 01:23+10:00",
1643
1780
                                                                },
1648
1785
                                                                                        "message": "somehow lost in all those logs",
1649
1786
                                                                                        "since":   "01 Apr 15 01:23+10:00",
1650
1787
                                                                                },
1651
 
                                                                                "agent-status": M{
 
1788
                                                                                "juju-status": M{
1652
1789
                                                                                        "current": "idle",
1653
1790
                                                                                        "since":   "01 Apr 15 01:23+10:00",
1654
1791
                                                                                },
1655
 
                                                                                "public-address": "dummymodel-2.dns",
 
1792
                                                                                "public-address": "admin-2.dns",
1656
1793
                                                                        },
1657
1794
                                                                },
1658
 
                                                                "public-address": "dummymodel-2.dns",
 
1795
                                                                "public-address": "admin-2.dns",
1659
1796
                                                        },
1660
1797
                                                },
1661
1798
                                                "relations": M{
1682
1819
                        "subordinates scoped on logging",
1683
1820
                        []string{"wordpress/0"},
1684
1821
                        M{
1685
 
                                "model": "dummymodel",
 
1822
                                "model": "admin",
1686
1823
                                "machines": M{
1687
1824
                                        "1": machine1,
1688
1825
                                },
1701
1838
                                                                        "current": "active",
1702
1839
                                                                        "since":   "01 Apr 15 01:23+10:00",
1703
1840
                                                                },
1704
 
                                                                "agent-status": M{
 
1841
                                                                "juju-status": M{
1705
1842
                                                                        "current": "idle",
1706
1843
                                                                        "since":   "01 Apr 15 01:23+10:00",
1707
1844
                                                                },
1711
1848
                                                                                        "current": "active",
1712
1849
                                                                                        "since":   "01 Apr 15 01:23+10:00",
1713
1850
                                                                                },
1714
 
                                                                                "agent-status": M{
 
1851
                                                                                "juju-status": M{
1715
1852
                                                                                        "current": "idle",
1716
1853
                                                                                        "since":   "01 Apr 15 01:23+10:00",
1717
1854
                                                                                },
1718
 
                                                                                "public-address": "dummymodel-1.dns",
 
1855
                                                                                "public-address": "admin-1.dns",
1719
1856
                                                                        },
1720
1857
                                                                },
1721
 
                                                                "public-address": "dummymodel-1.dns",
 
1858
                                                                "public-address": "admin-1.dns",
1722
1859
                                                        },
1723
1860
                                                },
1724
1861
                                                "relations": M{
1744
1881
                "machines with containers",
1745
1882
                // step 0
1746
1883
                addMachine{machineId: "0", job: state.JobManageModel},
1747
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
1884
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
1748
1885
                startAliveMachine{"0"},
1749
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
1886
                setMachineStatus{"0", status.StatusStarted, ""},
1750
1887
                addCharm{"mysql"},
1751
1888
                addService{name: "mysql", charm: "mysql"},
1752
1889
                setServiceExposed{"mysql", true},
1753
1890
 
1754
1891
                // step 7
1755
1892
                addMachine{machineId: "1", job: state.JobHostUnits},
1756
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
1893
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
1757
1894
                startAliveMachine{"1"},
1758
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
1895
                setMachineStatus{"1", status.StatusStarted, ""},
1759
1896
                addAliveUnit{"mysql", "1"},
1760
 
                setAgentStatus{"mysql/0", state.StatusIdle, "", nil},
1761
 
                setUnitStatus{"mysql/0", state.StatusActive, "", nil},
 
1897
                setAgentStatus{"mysql/0", status.StatusIdle, "", nil},
 
1898
                setUnitStatus{"mysql/0", status.StatusActive, "", nil},
1762
1899
 
1763
1900
                // step 14: A container on machine 1.
1764
1901
                addContainer{"1", "1/lxc/0", state.JobHostUnits},
1765
 
                setAddresses{"1/lxc/0", network.NewAddresses("dummymodel-2.dns")},
 
1902
                setAddresses{"1/lxc/0", network.NewAddresses("admin-2.dns")},
1766
1903
                startAliveMachine{"1/lxc/0"},
1767
 
                setMachineStatus{"1/lxc/0", state.StatusStarted, ""},
 
1904
                setMachineStatus{"1/lxc/0", status.StatusStarted, ""},
1768
1905
                addAliveUnit{"mysql", "1/lxc/0"},
1769
 
                setAgentStatus{"mysql/1", state.StatusIdle, "", nil},
1770
 
                setUnitStatus{"mysql/1", state.StatusActive, "", nil},
 
1906
                setAgentStatus{"mysql/1", status.StatusIdle, "", nil},
 
1907
                setUnitStatus{"mysql/1", status.StatusActive, "", nil},
1771
1908
                addContainer{"1", "1/lxc/1", state.JobHostUnits},
1772
1909
 
1773
1910
                // step 22: A nested container.
1774
1911
                addContainer{"1/lxc/0", "1/lxc/0/lxc/0", state.JobHostUnits},
1775
 
                setAddresses{"1/lxc/0/lxc/0", network.NewAddresses("dummymodel-3.dns")},
 
1912
                setAddresses{"1/lxc/0/lxc/0", network.NewAddresses("admin-3.dns")},
1776
1913
                startAliveMachine{"1/lxc/0/lxc/0"},
1777
 
                setMachineStatus{"1/lxc/0/lxc/0", state.StatusStarted, ""},
 
1914
                setMachineStatus{"1/lxc/0/lxc/0", status.StatusStarted, ""},
1778
1915
 
1779
1916
                expect{
1780
1917
                        "machines with nested containers",
1781
1918
                        M{
1782
 
                                "model": "dummymodel",
 
1919
                                "model": "admin",
1783
1920
                                "machines": M{
1784
1921
                                        "0": machine0,
1785
1922
                                        "1": machine1WithContainers,
1799
1936
                                                                        "current": "active",
1800
1937
                                                                        "since":   "01 Apr 15 01:23+10:00",
1801
1938
                                                                },
1802
 
                                                                "agent-status": M{
 
1939
                                                                "juju-status": M{
1803
1940
                                                                        "current": "idle",
1804
1941
                                                                        "since":   "01 Apr 15 01:23+10:00",
1805
1942
                                                                },
1806
 
                                                                "public-address": "dummymodel-1.dns",
 
1943
                                                                "public-address": "admin-1.dns",
1807
1944
                                                        },
1808
1945
                                                        "mysql/1": M{
1809
1946
                                                                "machine": "1/lxc/0",
1811
1948
                                                                        "current": "active",
1812
1949
                                                                        "since":   "01 Apr 15 01:23+10:00",
1813
1950
                                                                },
1814
 
                                                                "agent-status": M{
 
1951
                                                                "juju-status": M{
1815
1952
                                                                        "current": "idle",
1816
1953
                                                                        "since":   "01 Apr 15 01:23+10:00",
1817
1954
                                                                },
1818
 
                                                                "public-address": "dummymodel-2.dns",
 
1955
                                                                "public-address": "admin-2.dns",
1819
1956
                                                        },
1820
1957
                                                },
1821
1958
                                        },
1825
1962
 
1826
1963
                // step 27: once again, with a scope on mysql/1
1827
1964
                scopedExpect{
1828
 
                        "machines with nested containers",
 
1965
                        "machines with nested containers 2",
1829
1966
                        []string{"mysql/1"},
1830
1967
                        M{
1831
 
                                "model": "dummymodel",
 
1968
                                "model": "admin",
1832
1969
                                "machines": M{
1833
1970
                                        "1": M{
1834
 
                                                "agent-state": "started",
 
1971
                                                "juju-status": M{
 
1972
                                                        "current": "started",
 
1973
                                                        "since":   "01 Apr 15 01:23+10:00",
 
1974
                                                },
1835
1975
                                                "containers": M{
1836
1976
                                                        "1/lxc/0": M{
1837
 
                                                                "agent-state": "started",
1838
 
                                                                "dns-name":    "dummymodel-2.dns",
1839
 
                                                                "instance-id": "dummymodel-2",
1840
 
                                                                "series":      "quantal",
 
1977
                                                                "juju-status": M{
 
1978
                                                                        "current": "started",
 
1979
                                                                        "since":   "01 Apr 15 01:23+10:00",
 
1980
                                                                },
 
1981
                                                                "dns-name":    "admin-2.dns",
 
1982
                                                                "instance-id": "admin-2",
 
1983
                                                                "machine-status": M{
 
1984
                                                                        "current": "pending",
 
1985
                                                                        "since":   "01 Apr 15 01:23+10:00",
 
1986
                                                                },
 
1987
 
 
1988
                                                                "series": "quantal",
1841
1989
                                                        },
1842
1990
                                                },
1843
 
                                                "dns-name":    "dummymodel-1.dns",
1844
 
                                                "instance-id": "dummymodel-1",
1845
 
                                                "series":      "quantal",
1846
 
                                                "hardware":    "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
 
1991
                                                "dns-name":    "admin-1.dns",
 
1992
                                                "instance-id": "admin-1",
 
1993
                                                "machine-status": M{
 
1994
                                                        "current": "pending",
 
1995
                                                        "since":   "01 Apr 15 01:23+10:00",
 
1996
                                                },
 
1997
 
 
1998
                                                "series":   "quantal",
 
1999
                                                "hardware": "arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M",
1847
2000
                                        },
1848
2001
                                },
1849
2002
                                "services": M{
1861
2014
                                                                        "current": "active",
1862
2015
                                                                        "since":   "01 Apr 15 01:23+10:00",
1863
2016
                                                                },
1864
 
                                                                "agent-status": M{
 
2017
                                                                "juju-status": M{
1865
2018
                                                                        "current": "idle",
1866
2019
                                                                        "since":   "01 Apr 15 01:23+10:00",
1867
2020
                                                                },
1868
 
                                                                "public-address": "dummymodel-2.dns",
 
2021
                                                                "public-address": "admin-2.dns",
1869
2022
                                                        },
1870
2023
                                                },
1871
2024
                                        },
1876
2029
        test( // 13
1877
2030
                "service with out of date charm",
1878
2031
                addMachine{machineId: "0", job: state.JobManageModel},
1879
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
2032
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
1880
2033
                startAliveMachine{"0"},
1881
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
2034
                setMachineStatus{"0", status.StatusStarted, ""},
1882
2035
                addMachine{machineId: "1", job: state.JobHostUnits},
1883
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
2036
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
1884
2037
                startAliveMachine{"1"},
1885
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
2038
                setMachineStatus{"1", status.StatusStarted, ""},
1886
2039
                addCharm{"mysql"},
1887
2040
                addService{name: "mysql", charm: "mysql"},
1888
2041
                setServiceExposed{"mysql", true},
1892
2045
                expect{
1893
2046
                        "services and units with correct charm status",
1894
2047
                        M{
1895
 
                                "model": "dummymodel",
 
2048
                                "model": "admin",
1896
2049
                                "machines": M{
1897
2050
                                        "0": machine0,
1898
2051
                                        "1": machine1,
1915
2068
                                                                        "message": "Waiting for agent initialization to finish",
1916
2069
                                                                        "since":   "01 Apr 15 01:23+10:00",
1917
2070
                                                                },
1918
 
                                                                "agent-status": M{
 
2071
                                                                "juju-status": M{
1919
2072
                                                                        "current": "allocating",
1920
2073
                                                                        "since":   "01 Apr 15 01:23+10:00",
1921
2074
                                                                },
1922
 
                                                                "public-address": "dummymodel-1.dns",
 
2075
                                                                "public-address": "admin-1.dns",
1923
2076
                                                        },
1924
2077
                                                },
1925
2078
                                        },
1930
2083
        test( // 14
1931
2084
                "unit with out of date charm",
1932
2085
                addMachine{machineId: "0", job: state.JobManageModel},
1933
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
2086
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
1934
2087
                startAliveMachine{"0"},
1935
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
2088
                setMachineStatus{"0", status.StatusStarted, ""},
1936
2089
                addMachine{machineId: "1", job: state.JobHostUnits},
1937
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
2090
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
1938
2091
                startAliveMachine{"1"},
1939
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
2092
                setMachineStatus{"1", status.StatusStarted, ""},
1940
2093
                addCharm{"mysql"},
1941
2094
                addService{name: "mysql", charm: "mysql"},
1942
2095
                setServiceExposed{"mysql", true},
1948
2101
                expect{
1949
2102
                        "services and units with correct charm status",
1950
2103
                        M{
1951
 
                                "model": "dummymodel",
 
2104
                                "model": "admin",
1952
2105
                                "machines": M{
1953
2106
                                        "0": machine0,
1954
2107
                                        "1": machine1,
1968
2121
                                                                        "current": "active",
1969
2122
                                                                        "since":   "01 Apr 15 01:23+10:00",
1970
2123
                                                                },
1971
 
                                                                "agent-status": M{
 
2124
                                                                "juju-status": M{
1972
2125
                                                                        "current": "idle",
1973
2126
                                                                        "since":   "01 Apr 15 01:23+10:00",
1974
2127
                                                                },
1975
2128
                                                                "upgrading-from": "cs:quantal/mysql-1",
1976
 
                                                                "public-address": "dummymodel-1.dns",
 
2129
                                                                "public-address": "admin-1.dns",
1977
2130
                                                        },
1978
2131
                                                },
1979
2132
                                        },
1984
2137
        test( // 15
1985
2138
                "service and unit with out of date charms",
1986
2139
                addMachine{machineId: "0", job: state.JobManageModel},
1987
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
2140
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
1988
2141
                startAliveMachine{"0"},
1989
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
2142
                setMachineStatus{"0", status.StatusStarted, ""},
1990
2143
                addMachine{machineId: "1", job: state.JobHostUnits},
1991
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
2144
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
1992
2145
                startAliveMachine{"1"},
1993
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
2146
                setMachineStatus{"1", status.StatusStarted, ""},
1994
2147
                addCharm{"mysql"},
1995
2148
                addService{name: "mysql", charm: "mysql"},
1996
2149
                setServiceExposed{"mysql", true},
2003
2156
                expect{
2004
2157
                        "services and units with correct charm status",
2005
2158
                        M{
2006
 
                                "model": "dummymodel",
 
2159
                                "model": "admin",
2007
2160
                                "machines": M{
2008
2161
                                        "0": machine0,
2009
2162
                                        "1": machine1,
2024
2177
                                                                        "current": "active",
2025
2178
                                                                        "since":   "01 Apr 15 01:23+10:00",
2026
2179
                                                                },
2027
 
                                                                "agent-status": M{
 
2180
                                                                "juju-status": M{
2028
2181
                                                                        "current": "idle",
2029
2182
                                                                        "since":   "01 Apr 15 01:23+10:00",
2030
2183
                                                                },
2031
2184
                                                                "upgrading-from": "cs:quantal/mysql-1",
2032
 
                                                                "public-address": "dummymodel-1.dns",
 
2185
                                                                "public-address": "admin-1.dns",
2033
2186
                                                        },
2034
2187
                                                },
2035
2188
                                        },
2040
2193
        test( // 16
2041
2194
                "service with local charm not shown as out of date",
2042
2195
                addMachine{machineId: "0", job: state.JobManageModel},
2043
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
2196
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
2044
2197
                startAliveMachine{"0"},
2045
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
2198
                setMachineStatus{"0", status.StatusStarted, ""},
2046
2199
                addMachine{machineId: "1", job: state.JobHostUnits},
2047
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
2200
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
2048
2201
                startAliveMachine{"1"},
2049
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
2202
                setMachineStatus{"1", status.StatusStarted, ""},
2050
2203
                addCharm{"mysql"},
2051
2204
                addService{name: "mysql", charm: "mysql"},
2052
2205
                setServiceExposed{"mysql", true},
2059
2212
                expect{
2060
2213
                        "services and units with correct charm status",
2061
2214
                        M{
2062
 
                                "model": "dummymodel",
 
2215
                                "model": "admin",
2063
2216
                                "machines": M{
2064
2217
                                        "0": machine0,
2065
2218
                                        "1": machine1,
2079
2232
                                                                        "current": "active",
2080
2233
                                                                        "since":   "01 Apr 15 01:23+10:00",
2081
2234
                                                                },
2082
 
                                                                "agent-status": M{
 
2235
                                                                "juju-status": M{
2083
2236
                                                                        "current": "idle",
2084
2237
                                                                        "since":   "01 Apr 15 01:23+10:00",
2085
2238
                                                                },
2086
2239
                                                                "upgrading-from": "cs:quantal/mysql-1",
2087
 
                                                                "public-address": "dummymodel-1.dns",
 
2240
                                                                "public-address": "admin-1.dns",
2088
2241
                                                        },
2089
2242
                                                },
2090
2243
                                        },
2095
2248
        test( // 17
2096
2249
                "deploy two services; set meter statuses on one",
2097
2250
                addMachine{machineId: "0", job: state.JobManageModel},
2098
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
2251
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
2099
2252
                startAliveMachine{"0"},
2100
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
2253
                setMachineStatus{"0", status.StatusStarted, ""},
2101
2254
 
2102
2255
                addMachine{machineId: "1", job: state.JobHostUnits},
2103
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
2256
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
2104
2257
                startAliveMachine{"1"},
2105
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
2258
                setMachineStatus{"1", status.StatusStarted, ""},
2106
2259
 
2107
2260
                addMachine{machineId: "2", job: state.JobHostUnits},
2108
 
                setAddresses{"2", network.NewAddresses("dummymodel-2.dns")},
 
2261
                setAddresses{"2", network.NewAddresses("admin-2.dns")},
2109
2262
                startAliveMachine{"2"},
2110
 
                setMachineStatus{"2", state.StatusStarted, ""},
 
2263
                setMachineStatus{"2", status.StatusStarted, ""},
2111
2264
 
2112
2265
                addMachine{machineId: "3", job: state.JobHostUnits},
2113
 
                setAddresses{"3", network.NewAddresses("dummymodel-3.dns")},
 
2266
                setAddresses{"3", network.NewAddresses("admin-3.dns")},
2114
2267
                startAliveMachine{"3"},
2115
 
                setMachineStatus{"3", state.StatusStarted, ""},
 
2268
                setMachineStatus{"3", status.StatusStarted, ""},
2116
2269
 
2117
2270
                addMachine{machineId: "4", job: state.JobHostUnits},
2118
 
                setAddresses{"4", network.NewAddresses("dummymodel-4.dns")},
 
2271
                setAddresses{"4", network.NewAddresses("admin-4.dns")},
2119
2272
                startAliveMachine{"4"},
2120
 
                setMachineStatus{"4", state.StatusStarted, ""},
 
2273
                setMachineStatus{"4", status.StatusStarted, ""},
2121
2274
 
2122
2275
                addCharm{"mysql"},
2123
2276
                addService{name: "mysql", charm: "mysql"},
2132
2285
 
2133
2286
                setServiceExposed{"mysql", true},
2134
2287
 
2135
 
                setAgentStatus{"mysql/0", state.StatusIdle, "", nil},
2136
 
                setUnitStatus{"mysql/0", state.StatusActive, "", nil},
2137
 
                setAgentStatus{"servicewithmeterstatus/0", state.StatusIdle, "", nil},
2138
 
                setUnitStatus{"servicewithmeterstatus/0", state.StatusActive, "", nil},
2139
 
                setAgentStatus{"servicewithmeterstatus/1", state.StatusIdle, "", nil},
2140
 
                setUnitStatus{"servicewithmeterstatus/1", state.StatusActive, "", nil},
2141
 
                setAgentStatus{"servicewithmeterstatus/2", state.StatusIdle, "", nil},
2142
 
                setUnitStatus{"servicewithmeterstatus/2", state.StatusActive, "", nil},
 
2288
                setAgentStatus{"mysql/0", status.StatusIdle, "", nil},
 
2289
                setUnitStatus{"mysql/0", status.StatusActive, "", nil},
 
2290
                setAgentStatus{"servicewithmeterstatus/0", status.StatusIdle, "", nil},
 
2291
                setUnitStatus{"servicewithmeterstatus/0", status.StatusActive, "", nil},
 
2292
                setAgentStatus{"servicewithmeterstatus/1", status.StatusIdle, "", nil},
 
2293
                setUnitStatus{"servicewithmeterstatus/1", status.StatusActive, "", nil},
 
2294
                setAgentStatus{"servicewithmeterstatus/2", status.StatusIdle, "", nil},
 
2295
                setUnitStatus{"servicewithmeterstatus/2", status.StatusActive, "", nil},
2143
2296
 
2144
2297
                setUnitMeterStatus{"servicewithmeterstatus/1", "GREEN", "test green status"},
2145
2298
                setUnitMeterStatus{"servicewithmeterstatus/2", "RED", "test red status"},
2147
2300
                expect{
2148
2301
                        "simulate just the two services and a bootstrap node",
2149
2302
                        M{
2150
 
                                "model": "dummymodel",
 
2303
                                "model": "admin",
2151
2304
                                "machines": M{
2152
2305
                                        "0": machine0,
2153
2306
                                        "1": machine1,
2170
2323
                                                                        "current": "active",
2171
2324
                                                                        "since":   "01 Apr 15 01:23+10:00",
2172
2325
                                                                },
2173
 
                                                                "agent-status": M{
 
2326
                                                                "juju-status": M{
2174
2327
                                                                        "current": "idle",
2175
2328
                                                                        "since":   "01 Apr 15 01:23+10:00",
2176
2329
                                                                },
2177
 
                                                                "public-address": "dummymodel-1.dns",
 
2330
                                                                "public-address": "admin-1.dns",
2178
2331
                                                        },
2179
2332
                                                },
2180
2333
                                        },
2193
2346
                                                                        "current": "active",
2194
2347
                                                                        "since":   "01 Apr 15 01:23+10:00",
2195
2348
                                                                },
2196
 
                                                                "agent-status": M{
 
2349
                                                                "juju-status": M{
2197
2350
                                                                        "current": "idle",
2198
2351
                                                                        "since":   "01 Apr 15 01:23+10:00",
2199
2352
                                                                },
2200
 
                                                                "public-address": "dummymodel-2.dns",
 
2353
                                                                "public-address": "admin-2.dns",
2201
2354
                                                        },
2202
2355
                                                        "servicewithmeterstatus/1": M{
2203
2356
                                                                "machine": "3",
2205
2358
                                                                        "current": "active",
2206
2359
                                                                        "since":   "01 Apr 15 01:23+10:00",
2207
2360
                                                                },
2208
 
                                                                "agent-status": M{
 
2361
                                                                "juju-status": M{
2209
2362
                                                                        "current": "idle",
2210
2363
                                                                        "since":   "01 Apr 15 01:23+10:00",
2211
2364
                                                                },
2213
2366
                                                                        "color":   "green",
2214
2367
                                                                        "message": "test green status",
2215
2368
                                                                },
2216
 
                                                                "public-address": "dummymodel-3.dns",
 
2369
                                                                "public-address": "admin-3.dns",
2217
2370
                                                        },
2218
2371
                                                        "servicewithmeterstatus/2": M{
2219
2372
                                                                "machine": "4",
2221
2374
                                                                        "current": "active",
2222
2375
                                                                        "since":   "01 Apr 15 01:23+10:00",
2223
2376
                                                                },
2224
 
                                                                "agent-status": M{
 
2377
                                                                "juju-status": M{
2225
2378
                                                                        "current": "idle",
2226
2379
                                                                        "since":   "01 Apr 15 01:23+10:00",
2227
2380
                                                                },
2229
2382
                                                                        "color":   "red",
2230
2383
                                                                        "message": "test red status",
2231
2384
                                                                },
2232
 
                                                                "public-address": "dummymodel-4.dns",
 
2385
                                                                "public-address": "admin-4.dns",
2233
2386
                                                        },
2234
2387
                                                },
2235
2388
                                        },
2243
2396
                expect{
2244
2397
                        "upgrade availability should be shown in model-status",
2245
2398
                        M{
2246
 
                                "model": "dummymodel",
 
2399
                                "model": "admin",
2247
2400
                                "model-status": M{
2248
2401
                                        "upgrade-available": nextVersion().String(),
2249
2402
                                },
2332
2485
        _, hc := testing.AssertStartInstanceWithConstraints(c, ctx.env, m.Id(), cons)
2333
2486
        err = m.SetProvisioned("i-missing", "fake_nonce", hc)
2334
2487
        c.Assert(err, jc.ErrorIsNil)
2335
 
        err = m.SetInstanceStatus("missing")
 
2488
        err = m.SetInstanceStatus(status.StatusUnknown, "missing", nil)
2336
2489
        c.Assert(err, jc.ErrorIsNil)
2337
2490
}
2338
2491
 
2558
2711
 
2559
2712
type setUnitStatus struct {
2560
2713
        unitName   string
2561
 
        status     state.Status
 
2714
        status     status.Status
2562
2715
        statusInfo string
2563
2716
        statusData map[string]interface{}
2564
2717
}
2572
2725
 
2573
2726
type setAgentStatus struct {
2574
2727
        unitName   string
2575
 
        status     state.Status
 
2728
        status     status.Status
2576
2729
        statusInfo string
2577
2730
        statusData map[string]interface{}
2578
2731
}
2595
2748
        curl := charm.MustParseURL(uc.charm)
2596
2749
        err = u.SetCharmURL(curl)
2597
2750
        c.Assert(err, jc.ErrorIsNil)
2598
 
        err = u.SetStatus(state.StatusActive, "", nil)
 
2751
        err = u.SetStatus(status.StatusActive, "", nil)
2599
2752
        c.Assert(err, jc.ErrorIsNil)
2600
 
        err = u.SetAgentStatus(state.StatusIdle, "", nil)
 
2753
        err = u.SetAgentStatus(status.StatusIdle, "", nil)
2601
2754
        c.Assert(err, jc.ErrorIsNil)
2602
2755
 
2603
2756
}
2655
2808
 
2656
2809
type setMachineStatus struct {
2657
2810
        machineId  string
2658
 
        status     state.Status
 
2811
        status     status.Status
2659
2812
        statusInfo string
2660
2813
}
2661
2814
 
2799
2952
        closeCalled  bool
2800
2953
}
2801
2954
 
2802
 
func newFakeApiClient(statusReturn *params.FullStatus) fakeApiClient {
2803
 
        return fakeApiClient{
2804
 
                statusReturn: statusReturn,
2805
 
        }
2806
 
}
2807
 
 
2808
2955
func (a *fakeApiClient) Status(patterns []string) (*params.FullStatus, error) {
2809
2956
        a.patternsUsed = patterns
2810
2957
        return a.statusReturn, nil
2822
2969
                addMachine{machineId: "0", job: state.JobManageModel},
2823
2970
                setAddresses{"0", network.NewAddresses("localhost")},
2824
2971
                startAliveMachine{"0"},
2825
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
2972
                setMachineStatus{"0", status.StatusStarted, ""},
2826
2973
                addCharm{"wordpress"},
2827
2974
                addCharm{"mysql"},
2828
2975
                addCharm{"logging"},
2831
2978
                addMachine{machineId: "1", job: state.JobHostUnits},
2832
2979
                setAddresses{"1", network.NewAddresses("localhost")},
2833
2980
                startAliveMachine{"1"},
2834
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
2981
                setMachineStatus{"1", status.StatusStarted, ""},
2835
2982
                addAliveUnit{"wordpress", "1"},
2836
 
                setAgentStatus{"wordpress/0", state.StatusIdle, "", nil},
2837
 
                setUnitStatus{"wordpress/0", state.StatusActive, "", nil},
 
2983
                setAgentStatus{"wordpress/0", status.StatusIdle, "", nil},
 
2984
                setUnitStatus{"wordpress/0", status.StatusActive, "", nil},
2838
2985
                addService{name: "mysql", charm: "mysql"},
2839
2986
                setServiceExposed{"mysql", true},
2840
2987
                addMachine{machineId: "2", job: state.JobHostUnits},
2841
2988
                setAddresses{"2", network.NewAddresses("10.0.0.1")},
2842
2989
                startAliveMachine{"2"},
2843
 
                setMachineStatus{"2", state.StatusStarted, ""},
 
2990
                setMachineStatus{"2", status.StatusStarted, ""},
2844
2991
                addAliveUnit{"mysql", "2"},
2845
 
                setAgentStatus{"mysql/0", state.StatusIdle, "", nil},
2846
 
                setUnitStatus{"mysql/0", state.StatusActive, "", nil},
 
2992
                setAgentStatus{"mysql/0", status.StatusIdle, "", nil},
 
2993
                setUnitStatus{"mysql/0", status.StatusActive, "", nil},
2847
2994
                addService{name: "logging", charm: "logging"},
2848
2995
                setServiceExposed{"logging", true},
2849
2996
                relateServices{"wordpress", "mysql"},
2852
2999
                addSubordinate{"wordpress/0", "logging"},
2853
3000
                addSubordinate{"mysql/0", "logging"},
2854
3001
                setUnitsAlive{"logging"},
2855
 
                setAgentStatus{"logging/0", state.StatusIdle, "", nil},
2856
 
                setUnitStatus{"logging/0", state.StatusActive, "", nil},
2857
 
                setAgentStatus{"logging/1", state.StatusError, "somehow lost in all those logs", nil},
 
3002
                setAgentStatus{"logging/0", status.StatusIdle, "", nil},
 
3003
                setUnitStatus{"logging/0", status.StatusActive, "", nil},
 
3004
                setAgentStatus{"logging/1", status.StatusError, "somehow lost in all those logs", nil},
2858
3005
        }
2859
3006
        for _, s := range steps {
2860
3007
                s.step(c, ctx)
2884
3031
        defer s.resetContext(c, ctx)
2885
3032
        steps := []stepper{
2886
3033
                addMachine{machineId: "0", job: state.JobManageModel},
2887
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
3034
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
2888
3035
                startAliveMachine{"0"},
2889
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
3036
                setMachineStatus{"0", status.StatusStarted, ""},
2890
3037
                addCharm{"wordpress"},
2891
3038
                addCharm{"mysql"},
2892
3039
                addCharm{"logging"},
2894
3041
                addService{name: "wordpress", charm: "wordpress"},
2895
3042
                setServiceExposed{"wordpress", true},
2896
3043
                addMachine{machineId: "1", job: state.JobHostUnits},
2897
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
3044
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
2898
3045
                startAliveMachine{"1"},
2899
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
3046
                setMachineStatus{"1", status.StatusStarted, ""},
2900
3047
                addAliveUnit{"wordpress", "1"},
2901
 
                setAgentStatus{"wordpress/0", state.StatusIdle, "", nil},
2902
 
                setUnitStatus{"wordpress/0", state.StatusActive, "", nil},
 
3048
                setAgentStatus{"wordpress/0", status.StatusIdle, "", nil},
 
3049
                setUnitStatus{"wordpress/0", status.StatusActive, "", nil},
2903
3050
 
2904
3051
                addService{name: "mysql", charm: "mysql"},
2905
3052
                setServiceExposed{"mysql", true},
2906
3053
                addMachine{machineId: "2", job: state.JobHostUnits},
2907
 
                setAddresses{"2", network.NewAddresses("dummymodel-2.dns")},
 
3054
                setAddresses{"2", network.NewAddresses("admin-2.dns")},
2908
3055
                startAliveMachine{"2"},
2909
 
                setMachineStatus{"2", state.StatusStarted, ""},
 
3056
                setMachineStatus{"2", status.StatusStarted, ""},
2910
3057
                addAliveUnit{"mysql", "2"},
2911
 
                setAgentStatus{"mysql/0", state.StatusIdle, "", nil},
2912
 
                setUnitStatus{"mysql/0", state.StatusActive, "", nil},
 
3058
                setAgentStatus{"mysql/0", status.StatusIdle, "", nil},
 
3059
                setUnitStatus{"mysql/0", status.StatusActive, "", nil},
2913
3060
 
2914
3061
                addService{name: "logging", charm: "logging"},
2915
3062
                setServiceExposed{"logging", true},
2922
3069
                addSubordinate{"mysql/0", "logging"},
2923
3070
 
2924
3071
                setUnitsAlive{"logging"},
2925
 
                setAgentStatus{"logging/0", state.StatusIdle, "", nil},
2926
 
                setUnitStatus{"logging/0", state.StatusActive, "", nil},
2927
 
                setAgentStatus{"logging/1", state.StatusError, "somehow lost in all those logs", nil},
 
3072
                setAgentStatus{"logging/0", status.StatusIdle, "", nil},
 
3073
                setUnitStatus{"logging/0", status.StatusActive, "", nil},
 
3074
                setAgentStatus{"logging/1", status.StatusError, "somehow lost in all those logs", nil},
2928
3075
        }
2929
3076
 
2930
3077
        ctx.run(c, steps)
2931
3078
 
2932
3079
        const expected = `
2933
 
- mysql/0: dummymodel-2.dns (agent:idle, workload:active)
2934
 
  - logging/1: dummymodel-2.dns (agent:idle, workload:error)
2935
 
- wordpress/0: dummymodel-1.dns (agent:idle, workload:active)
2936
 
  - logging/0: dummymodel-1.dns (agent:idle, workload:active)
 
3080
- mysql/0: admin-2.dns (agent:idle, workload:active)
 
3081
  - logging/1: admin-2.dns (agent:idle, workload:error)
 
3082
- wordpress/0: admin-1.dns (agent:idle, workload:active)
 
3083
  - logging/0: admin-1.dns (agent:idle, workload:active)
2937
3084
`
2938
3085
        assertOneLineStatus(c, expected)
2939
3086
}
2962
3109
        steps := []stepper{
2963
3110
                setToolsUpgradeAvailable{},
2964
3111
                addMachine{machineId: "0", job: state.JobManageModel},
2965
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
3112
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
2966
3113
                startMachineWithHardware{"0", instance.MustParseHardware("availability-zone=us-east-1a")},
2967
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
3114
                setMachineStatus{"0", status.StatusStarted, ""},
2968
3115
                addCharm{"wordpress"},
2969
3116
                addCharm{"mysql"},
2970
3117
                addCharm{"logging"},
2971
3118
                addService{name: "wordpress", charm: "wordpress"},
2972
3119
                setServiceExposed{"wordpress", true},
2973
3120
                addMachine{machineId: "1", job: state.JobHostUnits},
2974
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
3121
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
2975
3122
                startAliveMachine{"1"},
2976
 
                setMachineStatus{"1", state.StatusStarted, ""},
 
3123
                setMachineStatus{"1", status.StatusStarted, ""},
2977
3124
                addAliveUnit{"wordpress", "1"},
2978
 
                setAgentStatus{"wordpress/0", state.StatusIdle, "", nil},
2979
 
                setUnitStatus{"wordpress/0", state.StatusActive, "", nil},
 
3125
                setAgentStatus{"wordpress/0", status.StatusIdle, "", nil},
 
3126
                setUnitStatus{"wordpress/0", status.StatusActive, "", nil},
2980
3127
                setUnitTools{"wordpress/0", version.MustParseBinary("1.2.3-trusty-ppc")},
2981
3128
                addService{name: "mysql", charm: "mysql"},
2982
3129
                setServiceExposed{"mysql", true},
2983
3130
                addMachine{machineId: "2", job: state.JobHostUnits},
2984
 
                setAddresses{"2", network.NewAddresses("dummymodel-2.dns")},
 
3131
                setAddresses{"2", network.NewAddresses("admin-2.dns")},
2985
3132
                startAliveMachine{"2"},
2986
 
                setMachineStatus{"2", state.StatusStarted, ""},
 
3133
                setMachineStatus{"2", status.StatusStarted, ""},
2987
3134
                addAliveUnit{"mysql", "2"},
2988
 
                setAgentStatus{"mysql/0", state.StatusIdle, "", nil},
 
3135
                setAgentStatus{"mysql/0", status.StatusIdle, "", nil},
2989
3136
                setUnitStatus{
2990
3137
                        "mysql/0",
2991
 
                        state.StatusMaintenance,
 
3138
                        status.StatusMaintenance,
2992
3139
                        "installing all the things", nil},
2993
3140
                setUnitTools{"mysql/0", version.MustParseBinary("1.2.3-trusty-ppc")},
2994
3141
                addService{name: "logging", charm: "logging"},
2999
3146
                addSubordinate{"wordpress/0", "logging"},
3000
3147
                addSubordinate{"mysql/0", "logging"},
3001
3148
                setUnitsAlive{"logging"},
3002
 
                setAgentStatus{"logging/0", state.StatusIdle, "", nil},
3003
 
                setUnitStatus{"logging/0", state.StatusActive, "", nil},
3004
 
                setAgentStatus{"logging/1", state.StatusError, "somehow lost in all those logs", nil},
 
3149
                setAgentStatus{"logging/0", status.StatusIdle, "", nil},
 
3150
                setUnitStatus{"logging/0", status.StatusActive, "", nil},
 
3151
                setAgentStatus{"logging/1", status.StatusError, "somehow lost in all those logs", nil},
3005
3152
        }
3006
3153
        for _, s := range steps {
3007
3154
                s.step(c, ctx)
3036
3183
logging     wordpress logging-dir       regular     
3037
3184
mysql       logging   info              subordinate 
3038
3185
mysql       wordpress db                regular     
3039
 
mysql       wordpress db                regular     
3040
3186
wordpress   logging   logging-directory subordinate 
3041
3187
 
3042
3188
[Units]     
3043
 
ID          WORKLOAD-STATE AGENT-STATE VERSION MACHINE PORTS PUBLIC-ADDRESS   MESSAGE                        
3044
 
mysql/0     maintenance    idle        1.2.3   2             dummymodel-2.dns installing all the things      
3045
 
  logging/1 error          idle                              dummymodel-2.dns somehow lost in all those logs 
3046
 
wordpress/0 active         idle        1.2.3   1             dummymodel-1.dns                                
3047
 
  logging/0 active         idle                              dummymodel-1.dns                                
 
3189
ID          WORKLOAD-STATUS JUJU-STATUS VERSION MACHINE PORTS PUBLIC-ADDRESS MESSAGE                        
 
3190
mysql/0     maintenance     idle        1.2.3   2             admin-2.dns    installing all the things      
 
3191
  logging/1 error           idle                              admin-2.dns    somehow lost in all those logs 
 
3192
wordpress/0 active          idle        1.2.3   1             admin-1.dns                                   
 
3193
  logging/0 active          idle                              admin-1.dns                                   
3048
3194
 
3049
3195
[Machines] 
3050
 
ID         STATE   DNS              INS-ID       SERIES  AZ         
3051
 
0          started dummymodel-0.dns dummymodel-0 quantal us-east-1a 
3052
 
1          started dummymodel-1.dns dummymodel-1 quantal            
3053
 
2          started dummymodel-2.dns dummymodel-2 quantal            
 
3196
ID         STATE   DNS         INS-ID  SERIES  AZ         
 
3197
0          started admin-0.dns admin-0 quantal us-east-1a 
 
3198
1          started admin-1.dns admin-1 quantal            
 
3199
2          started admin-2.dns admin-2 quantal            
3054
3200
 
3055
3201
`
3056
3202
        nextVersionStr := nextVersion().String()
3068
3214
                        "foo": serviceStatus{
3069
3215
                                Units: map[string]unitStatus{
3070
3216
                                        "foo/0": unitStatus{
3071
 
                                                AgentStatusInfo: statusInfoContents{
3072
 
                                                        Current: params.StatusExecuting,
 
3217
                                                JujuStatusInfo: statusInfoContents{
 
3218
                                                        Current: status.StatusExecuting,
3073
3219
                                                        Message: "running config-changed hook",
3074
3220
                                                },
3075
3221
                                                WorkloadStatusInfo: statusInfoContents{
3076
 
                                                        Current: params.StatusMaintenance,
 
3222
                                                        Current: status.StatusMaintenance,
3077
3223
                                                        Message: "doing some work",
3078
3224
                                                },
3079
3225
                                        },
3080
3226
                                        "foo/1": unitStatus{
3081
 
                                                AgentStatusInfo: statusInfoContents{
3082
 
                                                        Current: params.StatusExecuting,
 
3227
                                                JujuStatusInfo: statusInfoContents{
 
3228
                                                        Current: status.StatusExecuting,
3083
3229
                                                        Message: "running action backup database",
3084
3230
                                                },
3085
3231
                                                WorkloadStatusInfo: statusInfoContents{
3086
 
                                                        Current: params.StatusMaintenance,
 
3232
                                                        Current: status.StatusMaintenance,
3087
3233
                                                        Message: "doing some work",
3088
3234
                                                },
3089
3235
                                        },
3099
3245
foo               false         
3100
3246
 
3101
3247
[Units] 
3102
 
ID      WORKLOAD-STATE AGENT-STATE VERSION MACHINE PORTS PUBLIC-ADDRESS MESSAGE                           
3103
 
foo/0   maintenance    executing                                        (config-changed) doing some work  
3104
 
foo/1   maintenance    executing                                        (backup database) doing some work 
 
3248
ID      WORKLOAD-STATUS JUJU-STATUS VERSION MACHINE PORTS PUBLIC-ADDRESS MESSAGE                           
 
3249
foo/0   maintenance     executing                                        (config-changed) doing some work  
 
3250
foo/1   maintenance     executing                                        (backup database) doing some work 
3105
3251
 
3106
3252
[Machines] 
3107
3253
ID         STATE DNS INS-ID SERIES AZ 
3113
3259
        defer s.resetContext(c, ctx)
3114
3260
        steps := []stepper{
3115
3261
                addMachine{machineId: "0", job: state.JobManageModel},
3116
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
3262
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
3117
3263
                startAliveMachine{"0"},
3118
 
                setMachineStatus{"0", state.StatusStarted, ""},
 
3264
                setMachineStatus{"0", status.StatusStarted, ""},
3119
3265
        }
3120
3266
 
3121
3267
        for _, s := range steps {
3149
3295
                // And the machine's job is to manage the environment
3150
3296
                addMachine{machineId: "0", job: state.JobManageModel},
3151
3297
                startAliveMachine{"0"},
3152
 
                setMachineStatus{"0", state.StatusStarted, ""},
3153
 
                // And the machine's address is "dummymodel-0.dns"
3154
 
                setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
3298
                setMachineStatus{"0", status.StatusStarted, ""},
 
3299
                // And the machine's address is "admin-0.dns"
 
3300
                setAddresses{"0", network.NewAddresses("admin-0.dns")},
3155
3301
                // And a container is started
3156
3302
                // And the container's ID is "0/lxc/0"
3157
3303
                addContainer{"0", "0/lxc/0", state.JobHostUnits},
3170
3316
                // And the machine's job is to host units
3171
3317
                addMachine{machineId: "1", job: state.JobHostUnits},
3172
3318
                startAliveMachine{"1"},
3173
 
                setMachineStatus{"1", state.StatusStarted, ""},
3174
 
                // And the machine's address is "dummymodel-1.dns"
3175
 
                setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
 
3319
                setMachineStatus{"1", status.StatusStarted, ""},
 
3320
                // And the machine's address is "admin-1.dns"
 
3321
                setAddresses{"1", network.NewAddresses("admin-1.dns")},
3176
3322
                // And a unit of "wordpress" is deployed to machine "1"
3177
3323
                addAliveUnit{"wordpress", "1"},
3178
3324
                // And the unit is started
3179
 
                setAgentStatus{"wordpress/0", state.StatusIdle, "", nil},
3180
 
                setUnitStatus{"wordpress/0", state.StatusActive, "", nil},
 
3325
                setAgentStatus{"wordpress/0", status.StatusIdle, "", nil},
 
3326
                setUnitStatus{"wordpress/0", status.StatusActive, "", nil},
3181
3327
                // And a machine is started
3182
3328
 
3183
3329
                // And the machine's ID is "2"
3184
3330
                // And the machine's job is to host units
3185
3331
                addMachine{machineId: "2", job: state.JobHostUnits},
3186
3332
                startAliveMachine{"2"},
3187
 
                setMachineStatus{"2", state.StatusStarted, ""},
3188
 
                // And the machine's address is "dummymodel-2.dns"
3189
 
                setAddresses{"2", network.NewAddresses("dummymodel-2.dns")},
 
3333
                setMachineStatus{"2", status.StatusStarted, ""},
 
3334
                // And the machine's address is "admin-2.dns"
 
3335
                setAddresses{"2", network.NewAddresses("admin-2.dns")},
3190
3336
                // And a unit of "mysql" is deployed to machine "2"
3191
3337
                addAliveUnit{"mysql", "2"},
3192
3338
                // And the unit is started
3193
 
                setAgentStatus{"mysql/0", state.StatusIdle, "", nil},
3194
 
                setUnitStatus{"mysql/0", state.StatusActive, "", nil},
 
3339
                setAgentStatus{"mysql/0", status.StatusIdle, "", nil},
 
3340
                setUnitStatus{"mysql/0", status.StatusActive, "", nil},
3195
3341
                // And the "logging" service is added
3196
3342
                addService{name: "logging", charm: "logging"},
3197
3343
                // And the service is exposed
3204
3350
                relateServices{"mysql", "logging"},
3205
3351
                // And the "logging" service is a subordinate to unit 0 of the "wordpress" service
3206
3352
                addSubordinate{"wordpress/0", "logging"},
3207
 
                setAgentStatus{"logging/0", state.StatusIdle, "", nil},
3208
 
                setUnitStatus{"logging/0", state.StatusActive, "", nil},
 
3353
                setAgentStatus{"logging/0", status.StatusIdle, "", nil},
 
3354
                setUnitStatus{"logging/0", status.StatusActive, "", nil},
3209
3355
                // And the "logging" service is a subordinate to unit 0 of the "mysql" service
3210
3356
                addSubordinate{"mysql/0", "logging"},
3211
 
                setAgentStatus{"logging/1", state.StatusIdle, "", nil},
3212
 
                setUnitStatus{"logging/1", state.StatusActive, "", nil},
 
3357
                setAgentStatus{"logging/1", status.StatusIdle, "", nil},
 
3358
                setUnitStatus{"logging/1", status.StatusActive, "", nil},
3213
3359
                setUnitsAlive{"logging"},
3214
3360
        }
3215
3361
 
3217
3363
        return ctx
3218
3364
}
3219
3365
 
3220
 
// Scenario: One unit is in an errored state and user filters to started
3221
 
func (s *StatusSuite) TestFilterToStarted(c *gc.C) {
 
3366
// Scenario: One unit is in an errored state and user filters to active
 
3367
func (s *StatusSuite) TestFilterToActive(c *gc.C) {
3222
3368
        ctx := s.FilteringTestSetup(c)
3223
3369
        defer s.resetContext(c, ctx)
3224
3370
 
3225
3371
        // Given unit 1 of the "logging" service has an error
3226
 
        setAgentStatus{"logging/1", state.StatusError, "mock error", nil}.step(c, ctx)
 
3372
        setAgentStatus{"logging/1", status.StatusError, "mock error", nil}.step(c, ctx)
3227
3373
        // And unit 0 of the "mysql" service has an error
3228
 
        setAgentStatus{"mysql/0", state.StatusError, "mock error", nil}.step(c, ctx)
 
3374
        setAgentStatus{"mysql/0", status.StatusError, "mock error", nil}.step(c, ctx)
3229
3375
        // When I run juju status --format oneline started
3230
 
        _, stdout, stderr := runStatus(c, "--format", "oneline", "started")
 
3376
        _, stdout, stderr := runStatus(c, "--format", "oneline", "active")
3231
3377
        c.Assert(string(stderr), gc.Equals, "")
3232
3378
        // Then I should receive output prefixed with:
3233
3379
        const expected = `
3234
3380
 
3235
 
- wordpress/0: dummymodel-1.dns (agent:idle, workload:active)
3236
 
  - logging/0: dummymodel-1.dns (agent:idle, workload:active)
 
3381
- wordpress/0: admin-1.dns (agent:idle, workload:active)
 
3382
  - logging/0: admin-1.dns (agent:idle, workload:active)
3237
3383
`
3238
3384
        c.Assert(string(stdout), gc.Equals, expected[1:])
3239
3385
}
3249
3395
        // Then I should receive output prefixed with:
3250
3396
        const expected = `
3251
3397
 
3252
 
- wordpress/0: dummymodel-1.dns (agent:idle, workload:active)
3253
 
  - logging/0: dummymodel-1.dns (agent:idle, workload:active)
 
3398
- wordpress/0: admin-1.dns (agent:idle, workload:active)
 
3399
  - logging/0: admin-1.dns (agent:idle, workload:active)
3254
3400
`
3255
3401
        c.Assert(string(stdout), gc.Equals, expected[1:])
3256
3402
}
3276
3422
        // When I run juju status --format yaml 0/lxc/0
3277
3423
        _, stdout, stderr := runStatus(c, "--format", "yaml", "0/lxc/0")
3278
3424
        c.Assert(string(stderr), gc.Equals, "")
3279
 
        // Then I should receive output equal to:
3280
 
        const expected = `
3281
 
model: dummymodel
3282
 
machines:
3283
 
  "0":
3284
 
    agent-state: started
3285
 
    dns-name: dummymodel-0.dns
3286
 
    instance-id: dummymodel-0
3287
 
    series: quantal
3288
 
    containers:
3289
 
      0/lxc/0:
3290
 
        agent-state: pending
3291
 
        instance-id: pending
3292
 
        series: quantal
3293
 
    hardware: arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M
3294
 
    controller-member-status: adding-vote
3295
 
services: {}
3296
 
`
3297
 
        c.Assert(string(stdout), gc.Equals, expected[1:])
 
3425
        out := substituteFakeSinceTime(c, stdout, ctx.expectIsoTime)
 
3426
        const expected = "" +
 
3427
                "model: admin\n" +
 
3428
                "machines:\n" +
 
3429
                "  \"0\":\n" +
 
3430
                "    juju-status:\n" +
 
3431
                "      current: started\n" +
 
3432
                "      since: 01 Apr 15 01:23+10:00\n" +
 
3433
                "    dns-name: admin-0.dns\n" +
 
3434
                "    instance-id: admin-0\n" +
 
3435
                "    machine-status:\n" +
 
3436
                "      current: pending\n" +
 
3437
                "      since: 01 Apr 15 01:23+10:00\n" +
 
3438
                "    series: quantal\n" +
 
3439
                "    containers:\n" +
 
3440
                "      0/lxc/0:\n" +
 
3441
                "        juju-status:\n" +
 
3442
                "          current: pending\n" +
 
3443
                "          since: 01 Apr 15 01:23+10:00\n" +
 
3444
                "        instance-id: pending\n" +
 
3445
                "        machine-status:\n" +
 
3446
                "          current: pending\n" +
 
3447
                "          since: 01 Apr 15 01:23+10:00\n" +
 
3448
                "        series: quantal\n" +
 
3449
                "    hardware: arch=amd64 cpu-cores=1 mem=1024M root-disk=8192M\n" +
 
3450
                "    controller-member-status: adding-vote\n" +
 
3451
                "services: {}\n"
 
3452
 
 
3453
        c.Assert(string(out), gc.Equals, expected)
3298
3454
}
3299
3455
 
3300
3456
// Scenario: One unit is in an errored state and user filters to errored
3303
3459
        defer s.resetContext(c, ctx)
3304
3460
 
3305
3461
        // Given unit 1 of the "logging" service has an error
3306
 
        setAgentStatus{"logging/1", state.StatusError, "mock error", nil}.step(c, ctx)
 
3462
        setAgentStatus{"logging/1", status.StatusError, "mock error", nil}.step(c, ctx)
3307
3463
        // When I run juju status --format oneline error
3308
3464
        _, stdout, stderr := runStatus(c, "--format", "oneline", "error")
3309
3465
        c.Assert(stderr, gc.IsNil)
3310
3466
        // Then I should receive output prefixed with:
3311
3467
        const expected = `
3312
3468
 
3313
 
- mysql/0: dummymodel-2.dns (agent:idle, workload:active)
3314
 
  - logging/1: dummymodel-2.dns (agent:idle, workload:error)
 
3469
- mysql/0: admin-2.dns (agent:idle, workload:active)
 
3470
  - logging/1: admin-2.dns (agent:idle, workload:error)
3315
3471
`
3316
3472
        c.Assert(string(stdout), gc.Equals, expected[1:])
3317
3473
}
3327
3483
        // Then I should receive output prefixed with:
3328
3484
        const expected = `
3329
3485
 
3330
 
- mysql/0: dummymodel-2.dns (agent:idle, workload:active)
3331
 
  - logging/1: dummymodel-2.dns (agent:idle, workload:active)
 
3486
- mysql/0: admin-2.dns (agent:idle, workload:active)
 
3487
  - logging/1: admin-2.dns (agent:idle, workload:active)
3332
3488
`
3333
3489
 
3334
3490
        c.Assert(string(stdout), gc.Equals, expected[1:])
3351
3507
        // Then I should receive output prefixed with:
3352
3508
        const expected = `
3353
3509
 
3354
 
- mysql/0: dummymodel-2.dns (agent:idle, workload:active)
3355
 
  - logging/1: dummymodel-2.dns (agent:idle, workload:active)
 
3510
- mysql/0: admin-2.dns (agent:idle, workload:active)
 
3511
  - logging/1: admin-2.dns (agent:idle, workload:active)
3356
3512
`
3357
3513
        c.Assert(string(stdout), gc.Equals, expected[1:])
3358
3514
}
3369
3525
        // Then I should receive output prefixed with:
3370
3526
        const expected = `
3371
3527
 
3372
 
- wordpress/0: dummymodel-1.dns (agent:idle, workload:active)
3373
 
  - logging/0: dummymodel-1.dns (agent:idle, workload:active)
 
3528
- wordpress/0: admin-1.dns (agent:idle, workload:active)
 
3529
  - logging/0: admin-1.dns (agent:idle, workload:active)
3374
3530
`
3375
3531
        c.Assert(string(stdout), gc.Equals, expected[1:])
3376
3532
}
3429
3585
        // Then I should receive output prefixed with:
3430
3586
        const expected = `
3431
3587
 
3432
 
- mysql/0: dummymodel-2.dns (agent:idle, workload:active)
3433
 
  - logging/1: dummymodel-2.dns (agent:idle, workload:active)
3434
 
- wordpress/0: dummymodel-1.dns (agent:idle, workload:active)
3435
 
  - logging/0: dummymodel-1.dns (agent:idle, workload:active)
 
3588
- mysql/0: admin-2.dns (agent:idle, workload:active)
 
3589
  - logging/1: admin-2.dns (agent:idle, workload:active)
 
3590
- wordpress/0: admin-1.dns (agent:idle, workload:active)
 
3591
  - logging/0: admin-1.dns (agent:idle, workload:active)
3436
3592
`
3437
3593
        c.Assert(string(stdout), gc.Equals, expected[1:])
3438
3594
}
3450
3606
        // Then I should receive output prefixed with:
3451
3607
        const expected = `
3452
3608
 
3453
 
- mysql/0: dummymodel-2.dns (agent:idle, workload:active)
3454
 
  - logging/1: dummymodel-2.dns (agent:idle, workload:active)
 
3609
- mysql/0: admin-2.dns (agent:idle, workload:active)
 
3610
  - logging/1: admin-2.dns (agent:idle, workload:active)
3455
3611
`
3456
3612
        c.Assert(string(stdout), gc.Equals, expected[1:])
3457
3613
}
3465
3621
        // Then I should receive output prefixed with:
3466
3622
        const expected = `
3467
3623
 
3468
 
- mysql/0: dummymodel-2.dns (agent:idle, workload:active)
3469
 
  - logging/1: dummymodel-2.dns (agent:idle, workload:active)
3470
 
- wordpress/0: dummymodel-1.dns (agent:idle, workload:active)
3471
 
  - logging/0: dummymodel-1.dns (agent:idle, workload:active)
 
3624
- mysql/0: admin-2.dns (agent:idle, workload:active)
 
3625
  - logging/1: admin-2.dns (agent:idle, workload:active)
 
3626
- wordpress/0: admin-1.dns (agent:idle, workload:active)
 
3627
  - logging/0: admin-1.dns (agent:idle, workload:active)
3472
3628
`
3473
3629
        c.Assert(string(stdout), gc.Equals, expected[1:])
3474
3630
}
3477
3633
        ctx := s.FilteringTestSetup(c)
3478
3634
        defer s.resetContext(c, ctx)
3479
3635
 
3480
 
        _, stdout, stderr := runStatus(c, "--format", "oneline", "wordpress/0", "started")
 
3636
        _, stdout, stderr := runStatus(c, "--format", "oneline", "wordpress/0", "active")
3481
3637
        c.Assert(stderr, gc.IsNil)
3482
3638
        // Then I should receive output prefixed with:
3483
3639
        const expected = `
3484
3640
 
3485
 
- mysql/0: dummymodel-2.dns (agent:idle, workload:active)
3486
 
  - logging/1: dummymodel-2.dns (agent:idle, workload:active)
3487
 
- wordpress/0: dummymodel-1.dns (agent:idle, workload:active)
3488
 
  - logging/0: dummymodel-1.dns (agent:idle, workload:active)
 
3641
- mysql/0: admin-2.dns (agent:idle, workload:active)
 
3642
  - logging/1: admin-2.dns (agent:idle, workload:active)
 
3643
- wordpress/0: admin-1.dns (agent:idle, workload:active)
 
3644
  - logging/0: admin-1.dns (agent:idle, workload:active)
3489
3645
`
3490
3646
        c.Assert(string(stdout), gc.Equals, expected[1:])
3491
3647
}
3541
3697
var statusTimeTest = test(
3542
3698
        "status generates timestamps as UTC in ISO format",
3543
3699
        addMachine{machineId: "0", job: state.JobManageModel},
3544
 
        setAddresses{"0", network.NewAddresses("dummymodel-0.dns")},
 
3700
        setAddresses{"0", network.NewAddresses("admin-0.dns")},
3545
3701
        startAliveMachine{"0"},
3546
 
        setMachineStatus{"0", state.StatusStarted, ""},
 
3702
        setMachineStatus{"0", status.StatusStarted, ""},
3547
3703
        addCharm{"dummy"},
3548
3704
        addService{name: "dummy-service", charm: "dummy"},
3549
3705
 
3550
3706
        addMachine{machineId: "1", job: state.JobHostUnits},
3551
3707
        startAliveMachine{"1"},
3552
 
        setAddresses{"1", network.NewAddresses("dummymodel-1.dns")},
3553
 
        setMachineStatus{"1", state.StatusStarted, ""},
 
3708
        setAddresses{"1", network.NewAddresses("admin-1.dns")},
 
3709
        setMachineStatus{"1", status.StatusStarted, ""},
3554
3710
 
3555
3711
        addAliveUnit{"dummy-service", "1"},
3556
3712
        expect{
3557
3713
                "add two units, one alive (in error state), one started",
3558
3714
                M{
3559
 
                        "model": "dummymodel",
 
3715
                        "model": "admin",
3560
3716
                        "machines": M{
3561
3717
                                "0": machine0,
3562
3718
                                "1": machine1,
3578
3734
                                                                "message": "Waiting for agent initialization to finish",
3579
3735
                                                                "since":   "01 Apr 15 01:23+10:00",
3580
3736
                                                        },
3581
 
                                                        "agent-status": M{
 
3737
                                                        "juju-status": M{
3582
3738
                                                                "current": "allocating",
3583
3739
                                                                "since":   "01 Apr 15 01:23+10:00",
3584
3740
                                                        },
3585
 
                                                        "public-address": "dummymodel-1.dns",
 
3741
                                                        "public-address": "admin-1.dns",
3586
3742
                                                },
3587
3743
                                        },
3588
3744
                                },
3605
3761
        status := &params.FullStatus{
3606
3762
                Machines: map[string]params.MachineStatus{
3607
3763
                        "1": params.MachineStatus{
3608
 
                                Agent: params.AgentStatus{
 
3764
                                AgentStatus: params.DetailedStatus{
3609
3765
                                        Status: "error",
3610
3766
                                        Info:   "<error while provisioning>",
3611
3767
                                },
3612
 
                                InstanceId:    "pending",
3613
 
                                InstanceState: "",
3614
 
                                Series:        "trusty",
3615
 
                                Id:            "1",
3616
 
                                Jobs:          []multiwatcher.MachineJob{"JobHostUnits"},
 
3768
                                InstanceId:     "pending",
 
3769
                                InstanceStatus: params.DetailedStatus{},
 
3770
                                Series:         "trusty",
 
3771
                                Id:             "1",
 
3772
                                Jobs:           []multiwatcher.MachineJob{"JobHostUnits"},
3617
3773
                        },
3618
3774
                },
3619
3775
        }
3623
3779
        c.Check(formatted, jc.DeepEquals, formattedStatus{
3624
3780
                Machines: map[string]machineStatus{
3625
3781
                        "1": machineStatus{
3626
 
                                AgentState:     "error",
3627
 
                                AgentStateInfo: "<error while provisioning>",
3628
 
                                InstanceId:     "pending",
3629
 
                                Series:         "trusty",
3630
 
                                Id:             "1",
3631
 
                                Containers:     map[string]machineStatus{},
 
3782
                                JujuStatus: statusInfoContents{Current: "error", Message: "<error while provisioning>"},
 
3783
                                InstanceId: "pending",
 
3784
                                Series:     "trusty",
 
3785
                                Id:         "1",
 
3786
                                Containers: map[string]machineStatus{},
3632
3787
                        },
3633
3788
                },
3634
3789
                Services: map[string]serviceStatus{},