8000 Feature/grpc healthcheck by tbourrely · Pull Request #4853 · grafana/k6 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

tbourrely
Copy link
Contributor
@tbourrely tbourrely commented Jun 15, 2025

What?

Add a healthcheck method to gRPC JS client.

Why?

Remove invoke boilerplate as specified in #3428

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Related PR(s)/Issue(s)

Closes #3428

@tbourrely tbourrely requested a review from a team as a code owner June 15, 2025 23:05
@tbourrely tbourrely requested review from ankur22 and codebien and removed request for a team June 15, 2025 23:05
@tbourrely
Copy link
Contributor Author

Hello 👋

I would like some feedback on the changes related to issue #3428.
Please let me know if I'm going in the wrong direction.

Cheers !

@joanlopez joanlopez added this to the v1.2.0 milestone Jun 16, 2025
Copy link
Contributor
@codebien codebien left a 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

export default () => {
client.connect(GRPC_ADDR, { plaintext: true });

const response = client.healthcheck("")
Copy link
Contributor
@codebien codebien Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const response = client.healthcheck("")
const response = client.healthcheck()

I would prefer if we support null instead of empty string for the default case.

export default () => {
client.connect(GRPC_ADDR, { plaintext: true });

const response = client.healthcheck("")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Healthcheck runs healtcheck
// Healthcheck checks if the server side is up and ready to serve responses.

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

panic("not implemented")
}

func TestHealthcheck(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func TestHealthcheck(t *testing.T) {
func TestHealthCheckServing(t *testing.T) {

We are missing a not serving case.

Copy link
Contributor Author

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

@tbourrely tbourrely force-pushed the feature/grpc-healthcheck branch from 05f2d36 to 225969a Compare June 20, 2025 15:34
@tbourrely
Copy link
Contributor Author

Thanks for the review @codebien 👍
I'll address the js test concerns asap !

@tbourrely
Copy link
Contributor Author

I've added the JS client tests.
I was unsure whether i should put the healthcheck server on the HTTPMultiBin struct or not 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gRPC HealthV1 support without .proto files
3 participants
0