OLD | NEW |
1 package state | 1 package state |
2 | 2 |
3 import ( | 3 import ( |
4 "errors" | 4 "errors" |
5 "fmt" | 5 "fmt" |
6 "labix.org/v2/mgo" | 6 "labix.org/v2/mgo" |
7 . "launchpad.net/gocheck" | 7 . "launchpad.net/gocheck" |
8 "launchpad.net/juju-core/charm" | 8 "launchpad.net/juju-core/charm" |
9 "launchpad.net/juju-core/state/api/params" | 9 "launchpad.net/juju-core/state/api/params" |
10 "launchpad.net/juju-core/state/multiwatcher" | 10 "launchpad.net/juju-core/state/multiwatcher" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // setUpScenario adds some entities to the state so that | 53 // setUpScenario adds some entities to the state so that |
54 // we can check that they all get pulled in by | 54 // we can check that they all get pulled in by |
55 // allWatcherStateBacking.getAll. | 55 // allWatcherStateBacking.getAll. |
56 func (s *storeManagerStateSuite) setUpScenario(c *C) (entities entityInfoSlice)
{ | 56 func (s *storeManagerStateSuite) setUpScenario(c *C) (entities entityInfoSlice)
{ |
57 add := func(e params.EntityInfo) { | 57 add := func(e params.EntityInfo) { |
58 entities = append(entities, e) | 58 entities = append(entities, e) |
59 } | 59 } |
60 m, err := s.State.AddMachine("series", JobManageEnviron) | 60 m, err := s.State.AddMachine("series", JobManageEnviron) |
61 c.Assert(err, IsNil) | 61 c.Assert(err, IsNil) |
62 c.Assert(m.Tag(), Equals, "machine-0") | 62 c.Assert(m.Tag(), Equals, "machine-0") |
63 » err = m.SetInstanceId(InstanceId("i-" + m.Tag())) | 63 » err = m.SetProvisioned(InstanceId("i-"+m.Tag()), "fake_nonce") |
64 c.Assert(err, IsNil) | 64 c.Assert(err, IsNil) |
65 add(¶ms.MachineInfo{ | 65 add(¶ms.MachineInfo{ |
66 Id: "0", | 66 Id: "0", |
67 InstanceId: "i-machine-0", | 67 InstanceId: "i-machine-0", |
68 Status: params.MachinePending, | 68 Status: params.MachinePending, |
69 }) | 69 }) |
70 | 70 |
71 wordpress, err := s.State.AddService("wordpress", AddTestingCharm(c, s.S
tate, "wordpress")) | 71 wordpress, err := s.State.AddService("wordpress", AddTestingCharm(c, s.S
tate, "wordpress")) |
72 c.Assert(err, IsNil) | 72 c.Assert(err, IsNil) |
73 err = wordpress.SetExposed() | 73 err = wordpress.SetExposed() |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 Status: params.UnitPending, | 121 Status: params.UnitPending, |
122 }) | 122 }) |
123 pairs := map[string]string{"name": fmt.Sprintf("bar %d", i)} | 123 pairs := map[string]string{"name": fmt.Sprintf("bar %d", i)} |
124 err = wu.SetAnnotations(pairs) | 124 err = wu.SetAnnotations(pairs) |
125 c.Assert(err, IsNil) | 125 c.Assert(err, IsNil) |
126 add(¶ms.AnnotationInfo{ | 126 add(¶ms.AnnotationInfo{ |
127 Tag: fmt.Sprintf("unit-wordpress-%d", i), | 127 Tag: fmt.Sprintf("unit-wordpress-%d", i), |
128 Annotations: pairs, | 128 Annotations: pairs, |
129 }) | 129 }) |
130 | 130 |
131 » » err = m.SetInstanceId(InstanceId("i-" + m.Tag())) | 131 » » err = m.SetProvisioned(InstanceId("i-"+m.Tag()), "fake_nonce") |
132 c.Assert(err, IsNil) | 132 c.Assert(err, IsNil) |
133 err = m.SetStatus(params.MachineError, m.Tag()) | 133 err = m.SetStatus(params.MachineError, m.Tag()) |
134 c.Assert(err, IsNil) | 134 c.Assert(err, IsNil) |
135 add(¶ms.MachineInfo{ | 135 add(¶ms.MachineInfo{ |
136 Id: fmt.Sprint(i + 1), | 136 Id: fmt.Sprint(i + 1), |
137 InstanceId: "i-" + m.Tag(), | 137 InstanceId: "i-" + m.Tag(), |
138 Status: params.MachineError, | 138 Status: params.MachineError, |
139 StatusInfo: m.Tag(), | 139 StatusInfo: m.Tag(), |
140 }) | 140 }) |
141 err = wu.AssignToMachine(m) | 141 err = wu.AssignToMachine(m) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 add: []params.EntityInfo{ | 256 add: []params.EntityInfo{ |
257 ¶ms.MachineInfo{ | 257 ¶ms.MachineInfo{ |
258 Id: "0", | 258 Id: "0", |
259 Status: params.MachineError, | 259 Status: params.MachineError, |
260 StatusInfo: "another failure", | 260 StatusInfo: "another failure", |
261 }, | 261 }, |
262 }, | 262 }, |
263 setUp: func(c *C, st *State) { | 263 setUp: func(c *C, st *State) { |
264 m, err := st.AddMachine("series", JobManageEnviron) | 264 m, err := st.AddMachine("series", JobManageEnviron) |
265 c.Assert(err, IsNil) | 265 c.Assert(err, IsNil) |
266 » » » err = m.SetInstanceId("i-0") | 266 » » » err = m.SetProvisioned("i-0", "bootstrap_nonce") |
267 c.Assert(err, IsNil) | 267 c.Assert(err, IsNil) |
268 }, | 268 }, |
269 change: watcher.Change{ | 269 change: watcher.Change{ |
270 C: "machines", | 270 C: "machines", |
271 Id: "0", | 271 Id: "0", |
272 }, | 272 }, |
273 expectContents: []params.EntityInfo{ | 273 expectContents: []params.EntityInfo{ |
274 ¶ms.MachineInfo{ | 274 ¶ms.MachineInfo{ |
275 Id: "0", | 275 Id: "0", |
276 InstanceId: "i-0", | 276 InstanceId: "i-0", |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 Status: params.MachinePending, | 688 Status: params.MachinePending, |
689 }, | 689 }, |
690 }, { | 690 }, { |
691 Entity: ¶ms.MachineInfo{ | 691 Entity: ¶ms.MachineInfo{ |
692 Id: "1", | 692 Id: "1", |
693 Status: params.MachinePending, | 693 Status: params.MachinePending, |
694 }, | 694 }, |
695 }}, "") | 695 }}, "") |
696 | 696 |
697 // Make some changes to the state. | 697 // Make some changes to the state. |
698 » err = m0.SetInstanceId("i-0") | 698 » err = m0.SetProvisioned("i-0", "bootstrap_nonce") |
699 c.Assert(err, IsNil) | 699 c.Assert(err, IsNil) |
700 err = m1.Destroy() | 700 err = m1.Destroy() |
701 c.Assert(err, IsNil) | 701 c.Assert(err, IsNil) |
702 err = m1.EnsureDead() | 702 err = m1.EnsureDead() |
703 c.Assert(err, IsNil) | 703 c.Assert(err, IsNil) |
704 err = m1.Remove() | 704 err = m1.Remove() |
705 c.Assert(err, IsNil) | 705 c.Assert(err, IsNil) |
706 m2, err := s.State.AddMachine("series", JobManageEnviron) | 706 m2, err := s.State.AddMachine("series", JobManageEnviron) |
707 c.Assert(err, IsNil) | 707 c.Assert(err, IsNil) |
708 c.Assert(m2.Id(), Equals, "2") | 708 c.Assert(m2.Id(), Equals, "2") |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 panic(fmt.Errorf("%v mentioned twice in delta set", id)) | 803 panic(fmt.Errorf("%v mentioned twice in delta set", id)) |
804 } | 804 } |
805 if d.Removed { | 805 if d.Removed { |
806 m[id] = nil | 806 m[id] = nil |
807 } else { | 807 } else { |
808 m[id] = d.Entity | 808 m[id] = d.Entity |
809 } | 809 } |
810 } | 810 } |
811 return m | 811 return m |
812 } | 812 } |
OLD | NEW |