Add a status option to the service health check
This commit is contained in:
parent
61325d7b91
commit
46c266661c
17 changed files with 97 additions and 2 deletions
|
@ -249,6 +249,7 @@ func TestServiceHealthChecker_Launch(t *testing.T) {
|
|||
testCases := []struct {
|
||||
desc string
|
||||
mode string
|
||||
status int
|
||||
server StartTestServer
|
||||
expNumRemovedServers int
|
||||
expNumUpsertedServers int
|
||||
|
@ -263,6 +264,15 @@ func TestServiceHealthChecker_Launch(t *testing.T) {
|
|||
expGaugeValue: 1,
|
||||
targetStatus: runtime.StatusUp,
|
||||
},
|
||||
{
|
||||
desc: "healthy server staying healthy, with custom code status check",
|
||||
server: newHTTPServer(http.StatusNotFound),
|
||||
status: http.StatusNotFound,
|
||||
expNumRemovedServers: 0,
|
||||
expNumUpsertedServers: 1,
|
||||
expGaugeValue: 1,
|
||||
targetStatus: runtime.StatusUp,
|
||||
},
|
||||
{
|
||||
desc: "healthy server staying healthy (StatusNoContent)",
|
||||
server: newHTTPServer(http.StatusNoContent),
|
||||
|
@ -287,6 +297,15 @@ func TestServiceHealthChecker_Launch(t *testing.T) {
|
|||
expGaugeValue: 0,
|
||||
targetStatus: runtime.StatusDown,
|
||||
},
|
||||
{
|
||||
desc: "healthy server becoming sick, with custom code status check",
|
||||
server: newHTTPServer(http.StatusOK),
|
||||
status: http.StatusServiceUnavailable,
|
||||
expNumRemovedServers: 1,
|
||||
expNumUpsertedServers: 0,
|
||||
expGaugeValue: 0,
|
||||
targetStatus: runtime.StatusDown,
|
||||
},
|
||||
{
|
||||
desc: "healthy server toggling to sick and back to healthy",
|
||||
server: newHTTPServer(http.StatusServiceUnavailable, http.StatusOK),
|
||||
|
@ -348,6 +367,7 @@ func TestServiceHealthChecker_Launch(t *testing.T) {
|
|||
|
||||
config := &dynamic.ServerHealthCheck{
|
||||
Mode: test.mode,
|
||||
Status: test.status,
|
||||
Path: "/path",
|
||||
Interval: ptypes.Duration(500 * time.Millisecond),
|
||||
Timeout: ptypes.Duration(499 * time.Millisecond),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue