Repository navigation
test(metrics): optimize gRPC metrics test fixture and OTel test helpers - #5265
alleaditya wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the gRPC metrics tests and verification utilities. In internal/fs/grpc_metrics_test.go, the fake storage server is updated to use a centralized protobuf descriptor set and dynamic protobuf messages, and a new BidiWriteObject streaming handler is implemented. In metrics/metrics_test_utils.go, the metric verification helper functions are enhanced with new configuration options (such as scope, unit, and resource metrics reuse) and more robust attribute matching. Additionally, a new test file metrics/metrics_test_utils_test.go is introduced to thoroughly test these verification utilities. Feedback suggests validating that the bucket index is non-negative in VerifyHistogramFull to prevent potential runtime panics.
618d145 to
abc536f
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5265 +/- ##
==========================================
+ Coverage 85.19% 85.23% +0.03%
==========================================
Files 181 181
Lines 19957 19974 +17
==========================================
+ Hits 17003 17024 +21
+ Misses 2953 2949 -4
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
abc536f to
3da0c9e
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the gRPC metrics tests and verification utilities to improve performance, reliability, and maintainability. Key changes include implementing a cached protobuf descriptor set, adding a BidiWriteObject implementation to the fake storage server, introducing a test fixture to streamline setup, and replacing fragile sleep-based synchronization with require.EventuallyWithT. Additionally, the metrics verification helpers were updated to support a broader TestingT interface and allow reusing collected metrics snapshots. The review feedback suggests increasing the polling interval in EventuallyWithT from 1ms to 10ms to avoid busy-waiting and potential flakiness in CI environments.
|
Hi @kislaykishore, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you! |
|
Hi @kislaykishore, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you! |
2 similar comments
|
Hi @kislaykishore, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you! |
|
Hi @kislaykishore, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you! |
Improve the existing gRPC transport metrics test suite and OpenTelemetry metric verification helpers: - Speed up TestGrpcMetrics_* by ~18x (~1.85s -> ~0.10s) in internal/fs/grpc_metrics_test.go by setting GOOGLE_CLOUD_DISABLE_DIRECT_PATH=true and serving GCE metadata endpoints via t.Setenv, replacing sacrificial 100ms shortCtx workarounds and 1.5s+ sleeps with require.EventuallyWithT on ReadObject's asynchronous stream OnFinish callback. - Implement BidiWriteObject on reflectFakeServer with dynamicpb.Message.Reset() reuse (so TestGrpcMetrics_CreateFile asserts SyncFile success), cache google.storage.v2.* descriptors via sync.OnceValue, fix FileSystem/MetricHandle/MeterProvider cleanup leaks, and remove dead fakeStorageControlServer, unary WriteObject, and file-cache scaffolding. - Refactor metrics/metrics_test_utils.go to accept a TestingT interface (supporting *testing.T and *assert.CollectT), add single-pass CollectResourceMetrics / WithResourceMetrics snapshots, replace deprecated string-allocating attribute.Set.Emit() with zero-allocation typed attribute.Value matching, and validate negative histogram bucket indices.
Avoid 1ms retry polling if contended on resource-constrained CI runners while keeping the immediate 0ms initial check in TestGrpcMetrics_ReadFile.
3b81ce4 to
bcba7c7
Compare
|
Hi @kislaykishore, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you! |
|
Hi @kislaykishore, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you! |
Description
Optimize
internal/fs/grpc_metrics_test.goand clean upmetrics/metrics_test_utils.go:TestGrpcMetrics_*by ~18x (~1.85s->~0.10s) & fixBidiWriteObject/ resource leaks: SetGOOGLE_CLOUD_DISABLE_DIRECT_PATH=trueand serve GCE metadata endpoints viat.Setenv, eliminating all three sacrificial100msshortCtxDirectPath workarounds and1.5s+sleeps (usingrequire.EventuallyWithTforReadObject's async streamOnFinishcallback); implementBidiWriteObjectwithdynamicpb.Message.Reset()reuse soTestGrpcMetrics_CreateFileassertsSyncFilesuccess rather than ignoringUnimplemented; cachegoogle.storage.v2.*descriptors viasync.OnceValue; add LIFOt.Cleanupteardown (server.Destroy,mh.Close,provider.Shutdown); and remove deadfakeStorageControlServer, unaryWriteObject, and file-cache scaffolding.metrics/metrics_test_utils.gofor existing callers: WidenttoTestingT(supporting*testing.T,testing.TB, and*assert.CollectTinrequire.EventuallyWithT), add single-passCollectResourceMetrics+WithResourceMetricssnapshots used byTestGrpcMetrics_*, replace deprecated string-allocatingattribute.Set.Emit()with zero-allocation typedattribute.Valuecomparison, and guard against negative bucket indices inVerifyHistogramFull.Link to the issue in case of a bug fix.
Fixes b/586721886
Testing details
make build(go generate,goimports,go mod tidy,gofmt -s,go vet ./...,golangci-lint,go build ./...).go test -race -shuffle=on -count=5 ./internal/fs -run "^TestGrpcMetrics"and fullinternal/fs/*_metrics_test.gosuite.StorageHandle-> in-processgoogle.storage.v2.Storagefake server ininternal/fs.execute-integration-tests): Kokoro build #18627execute-integration-tests-on-zb): Kokoro build #18628execute-perf-test) - Kokoro build #18628Any backward incompatible change? If so, please explain.
N/A (widened
*testing.Tparameter toTestingTand added backward-compatibleWithResourceMetricsin test-only helper packagemetrics).