-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Feature/grpc healthcheck #4853
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
Feature/grpc healthcheck #4853
Conversation
Hello 👋 I would like some feedback on the changes related to issue #3428. Cheers ! |
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.
Hey @tbourrely,
this is a great start! The general architecture seems fine to me. I've spotted a few details in comments. However, the unique major missing point is a unit test for the JavaScript API. You can find them here https://github.com/grafana/k6/blob/master/internal/js/modules/k6/grpc/client_test.go
examples/grpc_healthcheck.js
Outdated
export default () => { | ||
client.connect(GRPC_ADDR, { plaintext: true }); | ||
|
||
const response = client.healthcheck("") |
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.
const response = client.healthcheck("") | |
const response = client.healthcheck() |
I would prefer if we support null
instead of empty string for the default case.
examples/grpc_healthcheck.js
Outdated
export default () => { | ||
client.connect(GRPC_ADDR, { plaintext: true }); | ||
|
||
const response = client.healthcheck("") |
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.
const response = client.healthcheck("") | |
const response = client.healthCheck("") |
I see you've originally proposed this name, that resonates with me because it matches the namespace of the API. Did you encounter any obstacle with it?
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.
none at all :)
@@ -278,6 +278,11 @@ func (c *Client) Connect(addr string, params sobek.Value) (bool, error) { | |||
return true, err | |||
} | |||
|
|||
// Healthcheck runs healtcheck |
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.
// Healthcheck runs healtcheck | |
// Healthcheck checks if the server side is up and ready to serve responses. |
internal/js/modules/k6/grpc/grpc.go
Outdated
@@ -86,6 +91,11 @@ func (mi *ModuleInstance) defineConstants() { | |||
mustAddCode("StatusUnavailable", codes.Unavailable) | |||
mustAddCode("StatusDataLoss", codes.DataLoss) | |||
mustAddCode("StatusUnauthenticated", codes.Unauthenticated) | |||
|
|||
mustAddServingStatus("HealthcheckUnknown", healthpb.HealthCheckResponse_UNKNOWN) |
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.
mustAddServingStatus("HealthcheckUnknown", healthpb.HealthCheckResponse_UNKNOWN) | |
mustAddServingStatus("HealthCheckUnknown", healthpb.HealthCheckResponse_UNKNOWN) |
It seems consistent with the current API. What is the case used on JavaScript-grpc library?
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.
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.
HealthCheck
is more consistent with the current method.
panic("not implemented") | ||
} | ||
|
||
func TestHealthcheck(t *testing.T) { |
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.
func TestHealthcheck(t *testing.T) { | |
func TestHealthCheckServing(t *testing.T) { |
We are missing a not serving case.
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.
ive also added the unknown case
05f2d36
to
225969a
Compare
Thanks for the review @codebien 👍 |
I've added the JS client tests. |
vendor/modules.txt
Outdated
google.golang.org/genproto/googleapis/rpc/errdetails | ||
google.golang.org/genproto/googleapis/rpc/status | ||
# google.golang.org/grpc v1.72.1 | ||
## explicit; go 1.23 | ||
# google.golang.org/grpc v1.73.0 |
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.
It shouldn't happen here, can you rollback it, please? If this is a requirement, then we need a dedicated pull request for it.
internal/js/modules/k6/grpc/grpc.go
Outdated
@@ -86,6 +91,11 @@ func (mi *ModuleInstance) defineConstants() { | |||
mustAddCode("StatusUnavailable", codes.Unavailable) | |||
mustAddCode("StatusDataLoss", codes.DataLoss) | |||
mustAddCode("StatusUnauthenticated", codes.Unauthenticated) | |||
|
|||
mustAddServingStatus("HealthcheckUnknown", healthpb.HealthCheckResponse_UNKNOWN) |
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.
HealthCheck
is more consistent with the current method.
return nil | ||
} | ||
c := Conn{raw: healthcheckmock(healthReply)} | ||
res, err := c.HealthCheck(context.Background(), "") |
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.
res, err := c.HealthCheck(context.Background(), "") | |
res, err := c.HealthCheck(context.Background(), "HERE-SERVICE") |
We're missing a case where we test a specific service
@tbourrely can you rebase and resolve the conflicts, please? |
886dc73
to
ca96658
Compare
ca96658
to
0e3fb95
Compare
68ec422
to
b054618
Compare
b054618
to
129be31
Compare
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.
LGTM 🚀
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.
LGTM 🎉 @tbourrely thanks for the contribution 🙇
As soon as we have resolved the linter issue, we're working internally on it, we will merge this pull request.
What?
Add a healthcheck method to gRPC JS client.
Why?
Remove invoke boilerplate as specified in #3428
Checklist
make check
) and all pass.Related PR(s)/Issue(s)
Closes #3428