LEFT | RIGHT |
1 package api_test | 1 package api_test |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | 4 "fmt" |
| 5 "io" |
5 . "launchpad.net/gocheck" | 6 . "launchpad.net/gocheck" |
6 "launchpad.net/juju-core/juju/testing" | 7 "launchpad.net/juju-core/juju/testing" |
7 "launchpad.net/juju-core/rpc" | 8 "launchpad.net/juju-core/rpc" |
8 "launchpad.net/juju-core/state" | 9 "launchpad.net/juju-core/state" |
9 "launchpad.net/juju-core/state/api" | 10 "launchpad.net/juju-core/state/api" |
10 coretesting "launchpad.net/juju-core/testing" | 11 coretesting "launchpad.net/juju-core/testing" |
11 "net" | 12 "net" |
12 stdtesting "testing" | 13 stdtesting "testing" |
13 ) | 14 ) |
14 | 15 |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 548 |
548 m, err := st.Machine(stm.Id()) | 549 m, err := st.Machine(stm.Id()) |
549 c.Assert(err, IsNil) | 550 c.Assert(err, IsNil) |
550 c.Assert(m.Id(), Equals, stm.Id()) | 551 c.Assert(m.Id(), Equals, stm.Id()) |
551 | 552 |
552 err = srv.Stop() | 553 err = srv.Stop() |
553 c.Assert(err, IsNil) | 554 c.Assert(err, IsNil) |
554 c.Logf("srv stopped") | 555 c.Logf("srv stopped") |
555 | 556 |
556 _, err = st.Machine(stm.Id()) | 557 _, err = st.Machine(stm.Id()) |
557 » c.Assert(err, Equals, rpc.ErrShutdown) | 558 » // The client has not necessarily seen the server |
| 559 » // shutdown yet, so there are two possible |
| 560 » // errors. |
| 561 » if err != rpc.ErrShutdown && err != io.ErrUnexpectedEOF { |
| 562 » » c.Fatalf("unexpected error from request: %v", err) |
| 563 » } |
558 | 564 |
559 // Check it can be stopped twice. | 565 // Check it can be stopped twice. |
560 err = srv.Stop() | 566 err = srv.Stop() |
561 c.Assert(err, IsNil) | 567 c.Assert(err, IsNil) |
562 } | 568 } |
563 | 569 |
564 // openAs connects to the API state as the given entity | 570 // openAs connects to the API state as the given entity |
565 // with the default password for that entity. | 571 // with the default password for that entity. |
566 func (s *suite) openAs(c *C, entityName string) *api.State { | 572 func (s *suite) openAs(c *C, entityName string) *api.State { |
567 _, info, err := s.APIConn.Environ.StateInfo() | 573 _, info, err := s.APIConn.Environ.StateInfo() |
568 c.Assert(err, IsNil) | 574 c.Assert(err, IsNil) |
569 info.EntityName = entityName | 575 info.EntityName = entityName |
570 info.Password = fmt.Sprintf("%s password", entityName) | 576 info.Password = fmt.Sprintf("%s password", entityName) |
571 c.Logf("opening state; entity %q; password %q", info.EntityName, info.Pa
ssword) | 577 c.Logf("opening state; entity %q; password %q", info.EntityName, info.Pa
ssword) |
572 st, err := api.Open(info) | 578 st, err := api.Open(info) |
573 c.Assert(err, IsNil) | 579 c.Assert(err, IsNil) |
574 c.Assert(st, NotNil) | 580 c.Assert(st, NotNil) |
575 return st | 581 return st |
576 } | 582 } |
LEFT | RIGHT |