~rogpeppe/juju-core/themue-058-debug-log-api

« back to all changes in this revision

Viewing changes to state/apiserver/pinger_test.go

  • Committer: Frank Mueller
  • Date: 2014-01-21 08:46:24 UTC
  • mfrom: (2152.1.76 juju-core)
  • Revision ID: frank.mueller@canonical.com-20140121084624-rv32dv6ufzul9h1b
debugger: merged trunk and added access to debugger API facade

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
        "launchpad.net/juju-core/juju/testing"
13
13
        "launchpad.net/juju-core/rpc"
14
14
        "launchpad.net/juju-core/state/api"
 
15
        "launchpad.net/juju-core/state/apiserver"
 
16
        coretesting "launchpad.net/juju-core/testing"
15
17
)
16
18
 
17
19
type stateSuite struct {
23
25
var testPingPeriod = 100 * time.Millisecond
24
26
 
25
27
func (s *stateSuite) TestConnectionBrokenDetection(c *gc.C) {
26
 
        origPingPeriod := api.PingPeriod
27
 
        api.PingPeriod = testPingPeriod
28
 
        defer func() {
29
 
                api.PingPeriod = origPingPeriod
30
 
        }()
 
28
        s.PatchValue(&api.PingPeriod, testPingPeriod)
31
29
 
32
30
        st, _ := s.OpenAPIAsNewMachine(c)
33
31
 
69
67
                c.Check(m.Message, gc.Not(gc.Matches), ".*Ping.*")
70
68
        }
71
69
}
 
70
 
 
71
func (s *stateSuite) TestClientNoNeedToPing(c *gc.C) {
 
72
        s.PatchValue(apiserver.MaxPingInterval, time.Duration(0))
 
73
        st, err := api.Open(s.APIInfo(c), api.DefaultDialOpts())
 
74
        c.Assert(err, gc.IsNil)
 
75
        time.Sleep(coretesting.ShortWait)
 
76
        err = st.Ping()
 
77
        c.Assert(err, gc.IsNil)
 
78
}
 
79
 
 
80
func (s *stateSuite) TestAgentConnectionShutsDownWithNoPing(c *gc.C) {
 
81
        s.PatchValue(apiserver.MaxPingInterval, time.Duration(0))
 
82
        st, _ := s.OpenAPIAsNewMachine(c)
 
83
        time.Sleep(coretesting.ShortWait)
 
84
        err := st.Ping()
 
85
        c.Assert(err, gc.ErrorMatches, "connection is shut down")
 
86
}