Skip to content

Conversation

paulnegz
Copy link

@paulnegz paulnegz commented Sep 2, 2025

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:

  • Starts a gRPC server in a separate process.
  • Runs a k6 script in another process, which loads the proto file at runtime and connects to the server.
  • Verifies that the client can successfully invoke a gRPC method using only the proto definition, ensuring that type registration is not leaking between processes.

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

  • 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.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

@paulnegz paulnegz requested a review from a team as a code owner September 2, 2025 04:21
@paulnegz paulnegz requested review from mstoykov and inancgumus and removed request for a team September 2, 2025 04:21
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
@paulnegz paulnegz force-pushed the feature/3552-grpc-tests-separate-process branch from 907cab2 to fb45ee4 Compare September 2, 2025 08:57
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.

Run tests in separate process so that we actually test loading proto definitions at runtime
1 participant