-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add timeout for /health endpoint checks #145
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 6 files at r1.
Reviewable status: 0 of 1 approvals obtained (waiting on @cristinaleonr)
cmd/heartbeat/health/checker_test.go
line 28 at r1 (raw file):
}, &EndpointClient{ Client: http.Client{},
nit: the Client value is a literal (not a pointer) and the zero value for http.Client
is what's being declared here. Is it sufficient to simply declare &EndpointClient{}
here?
cmd/heartbeat/health/checker_test.go
line 151 at r1 (raw file):
}, &EndpointClient{ Client: http.Client{},
Do any of these cases induce a timeout event for the health endpoint client? Which one if so? Please add one if not. This is the functionality being added. One test verifying that behavior would be welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 approvals obtained (waiting on @stephen-soltesz)
cmd/heartbeat/health/checker_test.go
line 28 at r1 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
nit: the Client value is a literal (not a pointer) and the zero value for
http.Client
is what's being declared here. Is it sufficient to simply declare&EndpointClient{}
here?
Changed.
cmd/heartbeat/health/checker_test.go
line 151 at r1 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
Do any of these cases induce a timeout event for the health endpoint client? Which one if so? Please add one if not. This is the functionality being added. One test verifying that behavior would be welcome.
I have added a test in the test file for the class where the behavior was implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 approvals obtained (waiting on @cristinaleonr)
cmd/heartbeat/health/endpoint-check_test.go
line 55 at r2 (raw file):
} hc := NewEndpointClient(time.Second)
Where is tt.timeout
used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 approvals obtained (waiting on @stephen-soltesz)
cmd/heartbeat/health/endpoint-check_test.go
line 55 at r2 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
Where is
tt.timeout
used?
Whoops, sorry! The test was passing for a different reason, which I have now fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 approvals obtained (waiting on @stephen-soltesz)
cmd/heartbeat/health/endpoint-check_test.go
line 55 at r2 (raw file):
Previously, cristinaleonr (Cristina Leon) wrote…
Whoops, sorry! The test was passing for a different reason, which I have now fixed.
Nvm, wait.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 approvals obtained (waiting on @cristinaleonr)
cmd/heartbeat/health/endpoint-check_test.go
line 31 at r3 (raw file):
name: "timeout", code: http.StatusOK, timeout: 0,
This error case is labeled "timeout" -- but iiuc, an http.Client
behavior with timeout = 0 is no timeout. What is this case testing?
cmd/heartbeat/health/endpoint-check_test.go
line 45 at r3 (raw file):
}, { name: "error",
What is the error case? Please use a slightly more descriptive name.
cmd/heartbeat/health/endpoint-check_test.go
line 53 at r3 (raw file):
for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if !tt.wantErr {
Where is tt.startSrv
used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the multiple revisions! I double checked it now 😅.
Reviewable status: 0 of 1 approvals obtained (waiting on @stephen-soltesz)
cmd/heartbeat/health/endpoint-check_test.go
line 31 at r3 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
This error case is labeled "timeout" -- but iiuc, an
http.Client
behavior with timeout = 0 is no timeout. What is this case testing?
I separated this into a new test with a 1 second timeout.
cmd/heartbeat/health/endpoint-check_test.go
line 45 at r3 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
What is the error case? Please use a slightly more descriptive name.
The server is not running. Done.
cmd/heartbeat/health/endpoint-check_test.go
line 53 at r3 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
Where is
tt.startSrv
used?
Sorry, I removed it and just moved the test case to its own function.
I realized that and that's why I added the "Nvm, wait" comment 👼.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggested refinement if possible.
Reviewed 3 of 6 files at r1, 1 of 2 files at r2, 1 of 2 files at r4.
Reviewable status:complete! 1 of 1 approvals obtained (waiting on @cristinaleonr)
cmd/heartbeat/health/endpoint-check_test.go
line 66 at r4 (raw file):
got, err := hc.checkHealthEndpoint() if err == nil { t.Errorf("checkHealthEndpoint() error = %v, wantErr %s", err, "context deadline error")
Is it possible to add an affirmative errors.Is
check for context deadline error
? I see context.DeadlineExceeded
-- this would be nice if possible. Not blocking if not.
cmd/heartbeat/health/healthtest/healthtest.go
line 18 at r4 (raw file):
} func TestTimeoutServer(timeout time.Duration) *httptest.Server {
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 1 of 1 approvals obtained (waiting on @stephen-soltesz)
cmd/heartbeat/health/endpoint-check_test.go
line 66 at r4 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
Is it possible to add an affirmative
errors.Is
check forcontext deadline error
? I seecontext.DeadlineExceeded
-- this would be nice if possible. Not blocking if not.
Even though the error message is of the form Get "http://127.0.0.1:44235/health": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
, it must not specifically wrap that error since the errors.Is
check returns false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 1 of 1 approvals obtained (waiting on @stephen-soltesz)
cmd/heartbeat/health/endpoint-check_test.go
line 66 at r4 (raw file):
Previously, cristinaleonr (Cristina Leon) wrote…
Even though the error message is of the form
Get "http://127.0.0.1:44235/health": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
, it must not specifically wrap that error since theerrors.Is
check returns false.
Agh, hold on again, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 1 of 1 approvals obtained (waiting on @stephen-soltesz)
cmd/heartbeat/health/endpoint-check_test.go
line 66 at r4 (raw file):
Previously, cristinaleonr (Cristina Leon) wrote…
Agh, hold on again, please.
Yep, my original statement above is right (I was double checking 👼).
Related to #149. |
This change is