OLD | NEW |
1 // Copyright 2013 Canonical Ltd. | 1 // Copyright 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package provisioner_test | 4 package provisioner_test |
5 | 5 |
6 import ( | 6 import ( |
7 "fmt" | 7 "fmt" |
8 "path/filepath" | 8 "path/filepath" |
9 "time" | 9 "time" |
10 | 10 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 }) | 95 }) |
96 c.Assert(err, gc.IsNil) | 96 c.Assert(err, gc.IsNil) |
97 return kvm | 97 return kvm |
98 } | 98 } |
99 | 99 |
100 func (s *kvmBrokerSuite) TestStopInstance(c *gc.C) { | 100 func (s *kvmBrokerSuite) TestStopInstance(c *gc.C) { |
101 kvm0 := s.startInstance(c, "1/kvm/0") | 101 kvm0 := s.startInstance(c, "1/kvm/0") |
102 kvm1 := s.startInstance(c, "1/kvm/1") | 102 kvm1 := s.startInstance(c, "1/kvm/1") |
103 kvm2 := s.startInstance(c, "1/kvm/2") | 103 kvm2 := s.startInstance(c, "1/kvm/2") |
104 | 104 |
105 » err := s.broker.StopInstances([]instance.Instance{kvm0}) | 105 » err := s.broker.StopInstances(kvm0.Id()) |
106 c.Assert(err, gc.IsNil) | 106 c.Assert(err, gc.IsNil) |
107 s.assertInstances(c, kvm1, kvm2) | 107 s.assertInstances(c, kvm1, kvm2) |
108 c.Assert(s.kvmContainerDir(kvm0), jc.DoesNotExist) | 108 c.Assert(s.kvmContainerDir(kvm0), jc.DoesNotExist) |
109 c.Assert(s.kvmRemovedContainerDir(kvm0), jc.IsDirectory) | 109 c.Assert(s.kvmRemovedContainerDir(kvm0), jc.IsDirectory) |
110 | 110 |
111 » err = s.broker.StopInstances([]instance.Instance{kvm1, kvm2}) | 111 » err = s.broker.StopInstances(kvm1.Id(), kvm2.Id()) |
112 c.Assert(err, gc.IsNil) | 112 c.Assert(err, gc.IsNil) |
113 s.assertInstances(c) | 113 s.assertInstances(c) |
114 } | 114 } |
115 | 115 |
116 func (s *kvmBrokerSuite) TestAllInstances(c *gc.C) { | 116 func (s *kvmBrokerSuite) TestAllInstances(c *gc.C) { |
117 kvm0 := s.startInstance(c, "1/kvm/0") | 117 kvm0 := s.startInstance(c, "1/kvm/0") |
118 kvm1 := s.startInstance(c, "1/kvm/1") | 118 kvm1 := s.startInstance(c, "1/kvm/1") |
119 s.assertInstances(c, kvm0, kvm1) | 119 s.assertInstances(c, kvm0, kvm1) |
120 | 120 |
121 » err := s.broker.StopInstances([]instance.Instance{kvm1}) | 121 » err := s.broker.StopInstances(kvm1.Id()) |
122 c.Assert(err, gc.IsNil) | 122 c.Assert(err, gc.IsNil) |
123 kvm2 := s.startInstance(c, "1/kvm/2") | 123 kvm2 := s.startInstance(c, "1/kvm/2") |
124 s.assertInstances(c, kvm0, kvm2) | 124 s.assertInstances(c, kvm0, kvm2) |
125 } | 125 } |
126 | 126 |
127 func (s *kvmBrokerSuite) assertInstances(c *gc.C, inst ...instance.Instance) { | 127 func (s *kvmBrokerSuite) assertInstances(c *gc.C, inst ...instance.Instance) { |
128 results, err := s.broker.AllInstances() | 128 results, err := s.broker.AllInstances() |
129 c.Assert(err, gc.IsNil) | 129 c.Assert(err, gc.IsNil) |
130 instancetest.MatchInstances(c, results, inst...) | 130 instancetest.MatchInstances(c, results, inst...) |
131 } | 131 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 268 |
269 container := s.addContainer(c) | 269 container := s.addContainer(c) |
270 | 270 |
271 instId := s.expectStarted(c, container) | 271 instId := s.expectStarted(c, container) |
272 | 272 |
273 // ...and removed, along with the machine, when the machine is Dead. | 273 // ...and removed, along with the machine, when the machine is Dead. |
274 c.Assert(container.EnsureDead(), gc.IsNil) | 274 c.Assert(container.EnsureDead(), gc.IsNil) |
275 s.expectStopped(c, instId) | 275 s.expectStopped(c, instId) |
276 s.waitRemoved(c, container) | 276 s.waitRemoved(c, container) |
277 } | 277 } |
OLD | NEW |