Allow short healthcheck interval with long timeout
This commit is contained in:
parent
d6457e6cbb
commit
55e00be36e
3 changed files with 51 additions and 6 deletions
|
@ -18,6 +18,57 @@ import (
|
|||
healthpb "google.golang.org/grpc/health/grpc_health_v1"
|
||||
)
|
||||
|
||||
func TestNewServiceHealthChecker_durations(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
config *dynamic.ServerHealthCheck
|
||||
expInterval time.Duration
|
||||
expTimeout time.Duration
|
||||
}{
|
||||
{
|
||||
desc: "default values",
|
||||
config: &dynamic.ServerHealthCheck{},
|
||||
expInterval: time.Duration(dynamic.DefaultHealthCheckInterval),
|
||||
expTimeout: time.Duration(dynamic.DefaultHealthCheckTimeout),
|
||||
},
|
||||
{
|
||||
desc: "out of range values",
|
||||
config: &dynamic.ServerHealthCheck{
|
||||
Interval: ptypes.Duration(-time.Second),
|
||||
Timeout: ptypes.Duration(-time.Second),
|
||||
},
|
||||
expInterval: time.Duration(dynamic.DefaultHealthCheckInterval),
|
||||
expTimeout: time.Duration(dynamic.DefaultHealthCheckTimeout),
|
||||
},
|
||||
{
|
||||
desc: "custom durations",
|
||||
config: &dynamic.ServerHealthCheck{
|
||||
Interval: ptypes.Duration(time.Second * 10),
|
||||
Timeout: ptypes.Duration(time.Second * 5),
|
||||
},
|
||||
expInterval: time.Second * 10,
|
||||
expTimeout: time.Second * 5,
|
||||
},
|
||||
{
|
||||
desc: "interval shorter than timeout",
|
||||
config: &dynamic.ServerHealthCheck{
|
||||
Interval: ptypes.Duration(time.Second),
|
||||
Timeout: ptypes.Duration(time.Second * 5),
|
||||
},
|
||||
expInterval: time.Second,
|
||||
expTimeout: time.Second * 5,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
healthChecker := NewServiceHealthChecker(context.Background(), nil, test.config, nil, nil, http.DefaultTransport, nil)
|
||||
assert.Equal(t, test.expInterval, healthChecker.interval)
|
||||
assert.Equal(t, test.expTimeout, healthChecker.timeout)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceHealthChecker_newRequest(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue