-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Feature/3552 grpc tests separate process #5121
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
base: master
Are you sure you want to change the base?
Feature/3552 grpc tests separate process #5121
Conversation
This commit addresses issue grafana#3552 by adding comprehensive testing for gRPC proto definition loading when k6 and gRPC server run in separate processes. Key changes: - Add TestGRPCSeparateProcess test that validates runtime proto loading - Move gRPC service from internal/lib/testutils to public testutils/grpcservice - Consolidate gRPC services to eliminate duplication (addresses @mstoykov feedback) - Update all import paths and proto file references throughout codebase - Fix context leak linting error in lib/executor/helpers.go - Update examples and tests to use new service location The refactor follows the MR feedback to reuse existing gRPC service infrastructure instead of creating duplicate implementations, making the codebase cleaner and more maintainable while enabling the separate process testing capability. Technical details: - Moved comprehensive gRPC service (FeatureExplorer + RouteGuide) to public package - Updated go_package option in proto files to reflect new location - Fixed all linting issues: errcheck, forbidigo, gofmt, gosec - Maintained backward compatibility for all existing functionality - Test validates core requirement: proto definitions loaded at runtime work correctly across process boundaries Closes grafana#3552
907cab2
to
fb45ee4
Compare
@@ -35,7 +35,7 @@ import ( | |||
"google.golang.org/grpc/reflection" | |||
"google.golang.org/grpc/testdata" | |||
|
|||
"go.k6.io/k6/internal/lib/testutils/grpcservice" |
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.
I checked and this works locally, so I am not certain why you are moving it, but I really would prefer not to have testutils
be a public package
ts := getSingleFileTestState(t, script, []string{"-v", "--log-output=stdout", "--no-usage-report"}, 0) | ||
|
||
// Read the actual proto file from testutils (same as working gRPC test) | ||
protoContent, err := os.ReadFile("../../../testutils/grpcservice/route_guide.proto") //nolint:forbidigo |
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.
Just changign this to be the correct internal path makes this pass, without any of the other changes.
// TestGRPCSeparateProcess tests that the gRPC client can properly load proto definitions | ||
// at runtime, which is the core functionality needed for separate process scenarios. | ||
// This validates the issue #3552 requirement without actually launching separate processes. | ||
func TestGRPCSeparateProcess(t *testing.T) { | ||
t.Parallel() |
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.
I do not see how you can test this without separate process and actually be certain it is working.
The whole point is that as long as the process are the same, there is no gurauntee that we are correctly loading them, or if it just piggyback on the fact the server has already loaded the same protobufs.
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.
Hi @paulnegz, thank you for the PR 🙇
Unfortunately there are a couple of problesm with it:
- it does move an internal package to be not internal, and I am pretty sure this is not needed as I commented
- The issue specifically wants to run in separate processes so we are not dependant on knowing how the current implementaiton works. As shown recently this does have problems and we have hit an issue that a test with separate process would've caught, but we didn't have such one.
This test verifies that k6 can properly load proto definitions at runtime when the server and client are in separate processes. This ensures that we're not relying on the global registry being populated by the server process.
Fixes #3552
What?
This PR adds a new test (
TestGRPCSeparateProcess
) that:Why?
Previously, gRPC tests ran both the server and client in the same process, which could mask issues with proto type registration due to Go's global registry. This test ensures that k6's gRPC client can independently load and use proto definitions at runtime, matching real-world usage and preventing false positives in tests.
Checklist
make check
) and all pass.Checklist: Documentation (only for k6 maintainers and if relevant)
Please do not merge this PR until the following items are filled out.
Related PR(s)/Issue(s)