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

Side by Side Diff: worker/provisioner/kvm-broker_test.go

Issue 97400043: Change StopInstances to take []instance.Id
Patch Set: Change StopInstances to take []instance.Id Created 9 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « worker/provisioner/kvm-broker.go ('k') | worker/provisioner/lxc-broker.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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
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
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 }
OLDNEW
« no previous file with comments | « worker/provisioner/kvm-broker.go ('k') | worker/provisioner/lxc-broker.go » ('j') | no next file with comments »

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