Index: cmd/jujud/machine_test.go |
=== modified file 'cmd/jujud/machine_test.go' |
--- cmd/jujud/machine_test.go 2013-05-25 13:11:46 +0000 |
+++ cmd/jujud/machine_test.go 2013-05-25 13:24:39 +0000 |
@@ -46,7 +46,7 @@ |
c.Assert(err, IsNil) |
err = m.SetMongoPassword("machine-password") |
c.Assert(err, IsNil) |
- err = m.SetPassword("machine-api-password") |
+ err = m.SetPassword("machine-password") |
c.Assert(err, IsNil) |
conf, tools := s.agentSuite.primeAgent(c, state.MachineTag(m.Id()), "machine-password") |
conf.MachineNonce = state.BootstrapNonce |
@@ -124,8 +124,11 @@ |
} |
func (s *MachineSuite) TestDyingMachine(c *C) { |
+ c.Logf("x1") |
m, _, _ := s.primeAgent(c, state.JobHostUnits) |
+ c.Logf("x2") |
a := s.newAgent(c, m) |
+ c.Logf("x3") |
done := make(chan error) |
go func() { |
done <- a.Run(nil) |
@@ -134,7 +137,9 @@ |
c.Check(a.Stop(), IsNil) |
}() |
time.Sleep(1 * time.Second) |
+ c.Logf("x4") |
err := m.Destroy() |
+ c.Logf("x5") |
c.Assert(err, IsNil) |
select { |
case err := <-done: |
@@ -254,21 +259,17 @@ |
s.testUpgrade(c, a, currentTools) |
} |
+// addAPIInfo adds information to the agent's configuration |
+// for serving the API. |
func addAPIInfo(conf *agent.Conf, m *state.Machine) { |
port := testing.FindTCPPort() |
- conf.APIInfo = &api.Info{ |
- Addrs: []string{fmt.Sprintf("localhost:%d", port)}, |
- CACert: []byte(testing.CACert), |
- Tag: m.Tag(), |
- Password: "machine-api-password", |
- } |
+ conf.APIInfo.Addrs = []string{fmt.Sprintf("localhost:%d", port)} |
+ conf.APIInfo.CACert = []byte(testing.CACert) |
conf.StateServerCert = []byte(testing.ServerCert) |
conf.StateServerKey = []byte(testing.ServerKey) |
conf.APIPort = port |
} |
-var fastDialOpts = api.DialOpts{} |
- |
func (s *MachineSuite) TestServeAPI(c *C) { |
stm, conf, _ := s.primeAgent(c, state.JobServeAPI) |
addAPIInfo(conf, stm) |
@@ -280,7 +281,10 @@ |
done <- a.Run(nil) |
}() |
- st, err := api.Open(conf.APIInfo, fastDialOpts) |
+ st, err := api.Open(conf.APIInfo, api.DialOpts{ |
+ Timeout: 3 * time.Second, |
+ RetryDelay: 5 * time.Millisecond, |
+ }) |
c.Assert(err, IsNil) |
defer st.Close() |
@@ -292,7 +296,15 @@ |
c.Assert(instId, Equals, "ardbeg-0") |
err = a.Stop() |
- c.Assert(err, IsNil) |
+ // When shutting down, the API server can be shut down before |
+ // the other workers that connect to it, so they get an error so |
+ // they then die, causing Stop to return an error. It's not |
+ // easy to control the actual error that's received in this |
+ // circumstance so we just log it rather than asserting that it |
+ // is not nil. |
+ if err != nil { |
+ c.Logf("error shutting down: %v", err) |
+ } |
select { |
case err := <-done: |
@@ -317,7 +329,7 @@ |
"configuration does not have state server cert/key", |
}} |
-func (s *MachineSuite) TestServeAPIWithBadConf(c *C) { |
+func (s *MachineSuite) TestBadConfServeAPI(c *C) { |
m, conf, _ := s.primeAgent(c, state.JobServeAPI) |
addAPIInfo(conf, m) |
for i, t := range serveAPIWithBadConfTests { |