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

Side by Side Diff: worker/firewaller/firewaller_test.go

Issue 6499071: state: unit: AssignedMachine returns a machine
Patch Set: Created 12 years, 7 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
OLDNEW
1 package firewaller_test 1 package firewaller_test
2 2
3 import ( 3 import (
4 . "launchpad.net/gocheck" 4 . "launchpad.net/gocheck"
5 "launchpad.net/juju-core/environs" 5 "launchpad.net/juju-core/environs"
6 "launchpad.net/juju-core/environs/dummy" 6 "launchpad.net/juju-core/environs/dummy"
7 "launchpad.net/juju-core/juju/testing" 7 "launchpad.net/juju-core/juju/testing"
8 "launchpad.net/juju-core/state" 8 "launchpad.net/juju-core/state"
9 coretesting "launchpad.net/juju-core/testing" 9 coretesting "launchpad.net/juju-core/testing"
10 "launchpad.net/juju-core/worker/firewaller" 10 "launchpad.net/juju-core/worker/firewaller"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 func (s *FirewallerSuite) TestStartStop(c *C) { 58 func (s *FirewallerSuite) TestStartStop(c *C) {
59 fw := firewaller.NewFirewaller(s.State) 59 fw := firewaller.NewFirewaller(s.State)
60 c.Assert(fw.Stop(), IsNil) 60 c.Assert(fw.Stop(), IsNil)
61 } 61 }
62 62
63 func (s *FirewallerSuite) addUnit(c *C, svc *state.Service) (*state.Unit, *state .Machine) { 63 func (s *FirewallerSuite) addUnit(c *C, svc *state.Service) (*state.Unit, *state .Machine) {
64 units, err := s.Conn.AddUnits(svc, 1) 64 units, err := s.Conn.AddUnits(svc, 1)
65 c.Assert(err, IsNil) 65 c.Assert(err, IsNil)
66 u := units[0] 66 u := units[0]
67 » id, err := u.AssignedMachineId() 67 » m, err := u.AssignedMachine()
68 » c.Assert(err, IsNil)
69 » m, err := s.State.Machine(id)
70 c.Assert(err, IsNil) 68 c.Assert(err, IsNil)
71 return u, m 69 return u, m
72 } 70 }
73 71
74 // startInstance starts a new instance for the given machine. 72 // startInstance starts a new instance for the given machine.
75 func (s *FirewallerSuite) startInstance(c *C, m *state.Machine) environs.Instanc e { 73 func (s *FirewallerSuite) startInstance(c *C, m *state.Machine) environs.Instanc e {
76 inst, err := s.Conn.Environ.StartInstance(m.Id(), s.StateInfo(c), nil) 74 inst, err := s.Conn.Environ.StartInstance(m.Id(), s.StateInfo(c), nil)
77 c.Assert(err, IsNil) 75 c.Assert(err, IsNil)
78 err = m.SetInstanceId(inst.Id()) 76 err = m.SetInstanceId(inst.Id())
79 c.Assert(err, IsNil) 77 c.Assert(err, IsNil)
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 268 }
271 269
272 func (s *FirewallerSuite) TestFirewallerStopOnStateClose(c *C) { 270 func (s *FirewallerSuite) TestFirewallerStopOnStateClose(c *C) {
273 st, err := state.Open(s.StateInfo(c)) 271 st, err := state.Open(s.StateInfo(c))
274 c.Assert(err, IsNil) 272 c.Assert(err, IsNil)
275 fw := firewaller.NewFirewaller(st) 273 fw := firewaller.NewFirewaller(st)
276 st.Close() 274 st.Close()
277 c.Check(fw.Wait(), ErrorMatches, ".* zookeeper is closing") 275 c.Check(fw.Wait(), ErrorMatches, ".* zookeeper is closing")
278 c.Assert(fw.Stop(), ErrorMatches, ".* zookeeper is closing") 276 c.Assert(fw.Stop(), ErrorMatches, ".* zookeeper is closing")
279 } 277 }
OLDNEW
« worker/firewaller/firewaller.go ('K') | « worker/firewaller/firewaller.go ('k') | no next file » | no next file with comments »

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