refactor: share in-memory gRPC bufconn helpers across fake-RPC tests - #1021
Conversation
Centralize listener, server, dialer, and cleanup for in-memory Spanner and DatabaseAdmin fakes. Fake-server behavior stays in each test file. Serve errors are reported inside Cleanup after Stop returns, and the dialer keeps listener.Dial because no migrated test covers cancelled dials.
Code Metrics Report📊 View detailed coverage report (available for 7 days)
Details | | main (f86e0d2) | #1021 (becd62d) | +/- |
|---------------------|----------------|-----------------|------|
| Coverage | 87.4% | 87.4% | 0.0% |
| Files | 132 | 132 | 0 |
| Lines | 13294 | 13294 | 0 |
| Covered | 11629 | 11629 | 0 |
- | Code to Test Ratio | 1:2.5 | 1:2.5 | -0.1 |
| Code | 28902 | 28902 | 0 |
- | Test | 73163 | 72726 | -437 |
+ | Test Execution Time | 2m50s | 2m40s | -10s |Reported by octocov |
|
Reviewed HEAD Reviewed all migrated fixtures and the shared transport cleanup order, Serve completion, service registration, and per-client options. The existing dial behavior and separate TCP/TLS fixtures are preserved. Current hosted CI checks pass. This is a source-review conclusion for this HEAD; the PR remains draft pending integration. |
Additive base update after #1023 so current main is an ancestor of this branch. No rebase.
|
Reviewed updated HEAD The tree exactly matches the clean automatic merge of the previously reviewed change with main |
Summary
Shared in-memory gRPC transport helpers for fake Spanner and DatabaseAdmin servers. Each test keeps its own fake-server behavior;
heartbeatRPCServeris not turned into a universal fake. Real TCP/TLS fixtures intls_transport_test.goandspanner_metrics_test.goare unchanged.Lifecycle review of the U1 prototype:
listener.Dial()rather thanDialContext. No migrated test covers cancelled-dial behavior, and RecreateClient / USE / DETACH still dial the shared listener aftert.Context()is cancelled during cleanup.Serveerrors are reported insidet.CleanupafterStopreturns, so a Serve goroutine cannot log after cleanup completes.#1018 was still open and unmerged at publication, so this branch is based on current
origin/mainwithout thatexecute_sql_test.gochange. Mergemainadditively if #1018 lands first.Base / HEAD
cbc1663366464409aba93f0d82cff9f4e9daa87b(origin/main)d716daca8d53d61e3e809c5d5135f32965e6ef19Numstat
internal/mycli/bufconn_test.go)Per-file:
Eliminated RPC setup is the repeated
bufconn.Listen/Serve/grpc.NewClient/ client-construction blocks. Retained real integration: TCP listeners intls_transport_test.go,spanner_metrics_test.go, and the partition TCP fixture instatements_run_partition_test.go.Scenario mapping
No named
Test*functions were added or removed. Every previously named case survives under the same name. Collapsed transport setup maps as follows:newQueryCacheRPCSessionbufconn bootstrapTestQueryCachePublication*vianewBufconnQuerySessionnewEmptySQLRPCSessionbufconn bootstrapTestExecuteSQLBufferedAndStreamingEmptyResultsvianewBufconnQuerySessionTestTablePreviewProcessorStreamingPreservesValue,TestExecuteSQLStreamingTablePreservesValue,TestCLIStringQuoteModeStreaming*,TestShowQueryProfile*vianewBufconnQuerySessionnewDDLAdminSession/newScriptedDDLSession/attachDDLAdminTestExecuteDdlStatementsRPC,TestSequenceKindRepairRPC,TestDDLInTransaction*vianewBufconnAdminSession/newBufconnAdminClientsync_proto_bundleadmin attachTestSyncProtoBundle*vianewBufconnAdminClientnewShowOperationTestSession(Operations only; baresystemVariables)TestShowOperation*viadialBufconnnewFuzzyAdminSession/newFuzzySchemaSession(p/i/dbidentity kept)TestFetchAdminCandidates,TestFetchSchemaObjectCandidates, otherTestFuzzy*/TestFetch*/TestResolveCandidates*startDirectedReadWire/startDirectedReadDial/ run-partition dial optionsTestDirectedRead*,TestRunPartition*,TestPartitionExportsCompleteEnvelopevianewBufconnSpannerClient/bufconnClientOptionsstartPartitionFanInTestRunPartitioned*,TestStreamPartitioned*,TestBufferPartitioned*vianewBufconnSpannerClientnewHeartbeatHarnesslistener/server (customclientOptskept)TestHeartbeat*viadialBufconn;heartbeatRPCServerunchangedGates
Captured under
.worktrees/test-bufconn-helper/.tmp/quality-wave-20260917/at HEADd716daca8d53d61e3e809c5d5135f32965e6ef19:go test -short -count=1 ./internal/mycliwith the 109 surviving names): exit 0GOTOOLCHAIN=go1.26.8 make checkwith golangci-lint 2.13.2: exit 0GOTOOLCHAIN=go1.26.8 make check-race: exit 0Environment:
GOTOOLCHAIN=go1.26.8, Homebrew golangci-lint 2.13.2,DOCKER_HOST=unix:///Users/apstndb/.colima/default/docker.sock,TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock.