[#171] pool: Add test for healthy status monitor
Signed-off-by: Alex Vanin <a.vanin@yadro.com>
This commit is contained in:
parent
8a04638749
commit
60463871db
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, uint64(count), monitor.overallErrorRate())
|
||||||
require.Equal(t, uint32(1), monitor.currentErrorRate())
|
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) {
|
func TestHandleError(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue