test(sync/grpc): verify config affects grpc client (MaxMsgSize, dial override)#1983
test(sync/grpc): verify config affects grpc client (MaxMsgSize, dial override)#1983anxkhn wants to merge 1 commit into
Conversation
…override) The existing grpc_sync tests assert side effects (a log line, a non-nil client) but never assert that Sync configuration actually changes the resulting gRPC client behavior, which is the gap called out in open-feature#1562. Add table-driven tests to grpc_sync_test.go that prove configuration affects the gRPC calls, using the existing deterministic seams: - MaxMsgSize is enforced: a real loopback listener returns a response larger than a small configured MaxMsgSize, and ReSync fails with codes.ResourceExhausted; the same payload succeeds when MaxMsgSize is unset. This exercises the production (non-override) dial path verbatim, so grpc.MaxCallRecvMsgSize is the only variable. - The GrpcDialOptionsOverride branch is taken: providing dial options bypasses CredentialBuilder (the mock builder has no expected calls) and yields a usable client. - ProviderID and Selector config propagate into the outgoing FetchAllFlagsRequest, captured server-side. Test-only change; grpc_sync.go is untouched. Closes open-feature#1562 Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
✅ Deploy Preview for polite-licorice-3db33c canceled.
|
📝 WalkthroughWalkthroughThree new test functions and a ChangesgRPC Sync Client Wiring Tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
core/pkg/sync/grpc/grpc_sync_test.go (1)
253-258: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSwitch this test to
grpc.NewClientwith apassthrough:///target.grpc.Dialis deprecated, andgrpc.NewClientwill otherwise try DNS resolution forlocalBufCon; this test already uses the same pattern above.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@core/pkg/sync/grpc/grpc_sync_test.go` around lines 253 - 258, Update the test setup in grpc_sync_test.go to use grpc.NewClient instead of grpc.Dial for the localBufCon connection; grpc.Dial is deprecated and grpc.NewClient will otherwise attempt DNS resolution on the target. Keep the existing context dialer and insecure credentials, but switch the target to the same passthrough:/// pattern used elsewhere in the test so the client connects directly through bufCon.Dial without name resolution.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@core/pkg/sync/grpc/grpc_sync_test.go`:
- Around line 253-258: Update the test setup in grpc_sync_test.go to use
grpc.NewClient instead of grpc.Dial for the localBufCon connection; grpc.Dial is
deprecated and grpc.NewClient will otherwise attempt DNS resolution on the
target. Keep the existing context dialer and insecure credentials, but switch
the target to the same passthrough:/// pattern used elsewhere in the test so the
client connects directly through bufCon.Dial without name resolution.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4763e7eb-9262-421c-8fd8-7251ede2b977
📒 Files selected for processing (1)
core/pkg/sync/grpc/grpc_sync_test.go



This PR
Closes #1562.
grpc_sync.goconfigures the gRPC client differently depending on theSyncsettings (
MaxMsgSize,GrpcDialOptionsOverride,ProviderID,Selector),but the existing tests only assert side effects: a log line, or that the client
is non-nil. They never assert that the configuration actually changes the
resulting gRPC behavior. That is the gap #1562 calls out ("test whether that
configuration affects the calls to grpc").
This is a test-only change.
grpc_sync.gois untouched.What's added
Three table-driven / focused tests in
core/pkg/sync/grpc/grpc_sync_test.go, built on the deterministic seams alreadyused in this file (
bufconn, the generated mocks,GrpcDialOptionsOverride):Test_InitMaxMsgSizeAffectsClient- provesMaxMsgSizeis wired as acall option, not just logged. A real loopback listener returns a response
larger than the configured limit; with
MaxMsgSize: 100theReSyncfailswith
codes.ResourceExhausted, and withMaxMsgSize: 0the same payloadsucceeds. It runs the production (non-override) dial path verbatim, so
grpc.MaxCallRecvMsgSizeis the only variable between the two cases.Test_InitDialOptionsOverrideBypassesCredentialBuilder- proves theGrpcDialOptionsOverridebranch is taken and skipsCredentialBuilderentirely. The mock builder is created with no expected calls, so any call to
Buildfails the test; the resulting client is then exercised end to end.Test_ReSyncSendsConfiguredProviderIDAndSelector- provesProviderIDand
Selectorpropagate into the outgoingFetchAllFlagsRequest, capturedserver-side.
A small
requestCapturingServerhelper is added, mirroring the existingheaderCapturingServer.Testing
All green under
-race(non-flaky over repeated runs). Package coverage forcore/pkg/sync/grpcgoes from ~87.3% to ~89.9%.golangci-lint(repo-pinnedv2.7.2) reports 0 issues on the package.