Fix connection leak and panic at close operation #171
1 changed files with 38 additions and 0 deletions
|
@ -523,6 +523,44 @@ func TestStatusMonitor(t *testing.T) {
|
|||
|
||||
require.Equal(t, uint64(count), monitor.overallErrorRate())
|
||||
require.Equal(t, uint32(1), monitor.currentErrorRate())
|
||||
|
||||
t.Run("healthy status", func(t *testing.T) {
|
||||
cases := []struct {
|
||||
action func(*clientStatusMonitor)
|
||||
status uint32
|
||||
isDialed bool
|
||||
isHealthy bool
|
||||
description string
|
||||
}{
|
||||
{
|
||||
action: func(m *clientStatusMonitor) { m.setUnhealthyOnDial() },
|
||||
status: statusUnhealthyOnDial,
|
||||
isDialed: false,
|
||||
isHealthy: false,
|
||||
description: "set unhealthy on dial",
|
||||
},
|
||||
{
|
||||
action: func(m *clientStatusMonitor) { m.setUnhealthy() },
|
||||
status: statusUnhealthyOnRequest,
|
||||
isDialed: true,
|
||||
isHealthy: false,
|
||||
description: "set unhealthy on request",
|
||||
},
|
||||
{
|
||||
action: func(m *clientStatusMonitor) { m.setHealthy() },
|
||||
status: statusHealthy,
|
||||
isDialed: true,
|
||||
isHealthy: true,
|
||||
description: "set healthy",
|
||||
},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
tc.action(&monitor)
|
||||
require.Equal(t, tc.status, monitor.healthy.Load())
|
||||
require.Equal(t, tc.isDialed, monitor.isDialed())
|
||||
require.Equal(t, tc.isHealthy, monitor.isHealthy())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestHandleError(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue