fix(router-tests): fix connectrpc tests and add to CI#2542
Conversation
WalkthroughAdds connectrpc to CI integration tests, updates an HTTP 404 mapping test to expect CodeUnimplemented, and switches test service directory references from samples to testdata across connectrpc tests. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Router-nonroot image scan passed✅ No security vulnerabilities found in image: |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
router-tests/connectrpc/connectrpc_client_test.go (1)
28-28: Redundantdefer ts.Close().
NewTestConnectRPCServeralready registerst.Cleanup(func() { ts.Close() }), andClose()has an idempotency guard (cleanupDone), so the explicitdefer ts.Close()on line 28 is harmless but unnecessary. The other error-handling tests in this same file omit it consistently.🔧 Suggested cleanup
ts := NewTestConnectRPCServer(t, ConnectRPCServerOptions{ GraphQLHandler: EmployeeGraphQLHandler(), }) - defer ts.Close() - - err := ts.Start() + err := ts.Start()🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@router-tests/connectrpc/connectrpc_client_test.go` at line 28, Remove the redundant explicit defer call to ts.Close() in the test after calling NewTestConnectRPCServer; NewTestConnectRPCServer already schedules t.Cleanup(func() { ts.Close() }) and Close() is idempotent via cleanupDone, so simply delete the line containing defer ts.Close() to keep tests consistent with the other error-handling tests that rely on t.Cleanup..github/workflows/router-ci.yaml (1)
199-204: LGTM — consider a dedicated lighter job for./connectrpclater.The matrix addition is correct. However, the
connectrpctests (reviewed below) rely only on a mock HTTP server and an in-process ConnectRPC server — they have no dependency on nats, redis cluster, or kafka. Every PR will now start an extraubuntu-latest-lrunner, initialize a 3-node Redis cluster (up to ~60 s wait), and boot nats + kafka, all unused.This is fine for now given the simplicity of a single shared job, but worth revisiting if CI times become a concern: a minimal job without the service stack would suffice for
./connectrpc.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/router-ci.yaml around lines 199 - 204, Current change adds './connectrpc' to the heavy test matrix which unnecessarily starts services; remove './connectrpc' from the existing matrix and add a new lightweight CI job (e.g., "connectrpc-tests") that runs only the './connectrpc' path, uses an ubuntu-latest runner, skips starting Redis/NATS/Kafka services, and runs the same test commands used in the main job (ensure the step that executes the tests targets the ./connectrpc directory); update the workflow matrix/paths to exclude './connectrpc' from the heavy job and create the new job with minimal service setup to keep CI times down.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/router-ci.yaml:
- Around line 199-204: Current change adds './connectrpc' to the heavy test
matrix which unnecessarily starts services; remove './connectrpc' from the
existing matrix and add a new lightweight CI job (e.g., "connectrpc-tests") that
runs only the './connectrpc' path, uses an ubuntu-latest runner, skips starting
Redis/NATS/Kafka services, and runs the same test commands used in the main job
(ensure the step that executes the tests targets the ./connectrpc directory);
update the workflow matrix/paths to exclude './connectrpc' from the heavy job
and create the new job with minimal service setup to keep CI times down.
In `@router-tests/connectrpc/connectrpc_client_test.go`:
- Line 28: Remove the redundant explicit defer call to ts.Close() in the test
after calling NewTestConnectRPCServer; NewTestConnectRPCServer already schedules
t.Cleanup(func() { ts.Close() }) and Close() is idempotent via cleanupDone, so
simply delete the line containing defer ts.Close() to keep tests consistent with
the other error-handling tests that rely on t.Cleanup.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2542 +/- ##
===========================================
- Coverage 61.69% 44.96% -16.73%
===========================================
Files 239 239
Lines 25423 25423
===========================================
- Hits 15685 11432 -4253
- Misses 8418 12812 +4394
+ Partials 1320 1179 -141 🚀 New features to boost your workflow:
|
a01c832 to
ef2959d
Compare
Update test service directory paths from samples/services to testdata/services, fix HTTP 404 mapping assertion to match Connect RPC spec (CodeUnimplemented), and add connectrpc package to CI test matrix.
ef2959d to
78c8d1c
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/router-ci.yaml (1)
192-204: Operational note: connectrpc matrix leg spins up services it doesn't use.Every
integration_testmatrix entry — including./connectrpc— waits for a Redis Cluster to form, configures cluster ACLs, and starts NATS and Kafka. Connect RPC tests are pure HTTP/gRPC protocol tests and almost certainly require none of those services. This adds roughly 2–3 minutes of service-bootstrap overhead to every connectrpc run on an expensive large runner.Consider either:
- Grouping
./connectrpcalongside another lightweight target in a single matrix entry (e.g.,'./telemetry ./connectrpc'), or- Splitting it into a separate, slimmer job without the Redis Cluster / NATS / Kafka service block — similar to how
build_test_forkis kept lightweight.Neither change is blocking, but the waste compounds on every PR touching router-tests.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/router-ci.yaml around lines 192 - 204, The integration_test matrix currently runs a heavy service bootstrap for every test_target including './connectrpc', causing unnecessary Redis/NATS/Kafka startup overhead; update the CI by either grouping './connectrpc' with a lightweight target (e.g., change the matrix entry to include './telemetry ./connectrpc' so it shares a single lightweight matrix leg) or create a separate job (copy of integration_test named e.g., integration_test_connectrpc) that omits the Redis Cluster / ACL / NATS / Kafka service block (mirror how build_test_fork is kept lightweight) so the connectrpc runs without the expensive service bootstrap.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/router-ci.yaml:
- Around line 192-204: The integration_test matrix currently runs a heavy
service bootstrap for every test_target including './connectrpc', causing
unnecessary Redis/NATS/Kafka startup overhead; update the CI by either grouping
'./connectrpc' with a lightweight target (e.g., change the matrix entry to
include './telemetry ./connectrpc' so it shares a single lightweight matrix leg)
or create a separate job (copy of integration_test named e.g.,
integration_test_connectrpc) that omits the Redis Cluster / ACL / NATS / Kafka
service block (mirror how build_test_fork is kept lightweight) so the connectrpc
runs without the expensive service bootstrap.
Summary
samples/services→testdata/services(directory was renamed)CodeUnimplementednotCodeNotFoundper Connect RPC spec./connectrpcto the CI integration test matrix so these tests run on every PRFixes ENG-8984
Test plan
./connectrpcmatrix entry successfullySummary by CodeRabbit