From 53fbba79257d71ca9481ebd2604108094a299d88 Mon Sep 17 00:00:00 2001 From: BenWhitehead Date: Fri, 23 Aug 2024 12:40:25 -0400 Subject: [PATCH] test: disable grpc client side metrics for tests (#2683) Our test suite creates thousands of instances of storage clients, the vast majority against test bench and non-directpath. Explicitly disable grpc client metrics to avoid the bootstrapping overhead and permission failures that happen. --- .../src/test/java/com/google/cloud/storage/FakeServer.java | 1 + .../com/google/cloud/storage/ITStorageLifecycleTest.java | 1 + .../cloud/storage/conformance/retry/RetryTestFixture.java | 5 ++++- .../google/cloud/storage/it/ITGrpcIdempotencyTokenTest.java | 1 + .../com/google/cloud/storage/it/ITStorageOptionsTest.java | 6 +++++- .../cloud/storage/it/runner/registry/BackendResources.java | 1 + 6 files changed, 13 insertions(+), 2 deletions(-) diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/FakeServer.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/FakeServer.java index 578f6c7dc8..331856c4d0 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/FakeServer.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/FakeServer.java @@ -60,6 +60,7 @@ static FakeServer of(StorageGrpc.StorageImplBase service) throws IOException { .setProjectId("test-proj") .setCredentials(NoCredentials.getInstance()) .setGrpcInterceptorProvider(GrpcPlainRequestLoggingInterceptor.getInterceptorProvider()) + .setEnableGrpcClientMetrics(false) .build(); return new FakeServer(server, grpcStorageOptions); } diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/ITStorageLifecycleTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/ITStorageLifecycleTest.java index 0c8fc12b39..1c404ec973 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/ITStorageLifecycleTest.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/ITStorageLifecycleTest.java @@ -50,6 +50,7 @@ public void grpc() throws Exception { .setHost(testBench.getGRPCBaseUri()) .setCredentials(NoCredentials.getInstance()) .setProjectId("test-project-id") + .setEnableGrpcClientMetrics(false) .build(); Storage service1 = options.getService(); diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RetryTestFixture.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RetryTestFixture.java index eec2b847b2..3076b171be 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RetryTestFixture.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RetryTestFixture.java @@ -157,7 +157,10 @@ private Storage newStorage(boolean forTest) { builder = StorageOptions.http().setHost(testBench.getBaseUri()); break; case GRPC: - builder = StorageOptions.grpc().setHost(testBench.getGRPCBaseUri()); + builder = + StorageOptions.grpc() + .setHost(testBench.getGRPCBaseUri()) + .setEnableGrpcClientMetrics(false); break; default: throw new IllegalStateException( diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITGrpcIdempotencyTokenTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITGrpcIdempotencyTokenTest.java index ec5d54252b..0aca897aff 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITGrpcIdempotencyTokenTest.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITGrpcIdempotencyTokenTest.java @@ -68,6 +68,7 @@ public void setUp() throws Exception { storage = StorageOptions.grpc() .setGrpcInterceptorProvider(() -> ImmutableList.of(requestAuditing)) + .setEnableGrpcClientMetrics(false) .build() .getService(); } diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageOptionsTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageOptionsTest.java index 85ee5f642c..86bf0a4b82 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageOptionsTest.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageOptionsTest.java @@ -64,7 +64,11 @@ public void clientShouldConstructCleanly_http() throws Exception { @Test public void clientShouldConstructCleanly_grpc() throws Exception { StorageOptions options = - StorageOptions.grpc().setCredentials(credentials).setAttemptDirectPath(false).build(); + StorageOptions.grpc() + .setCredentials(credentials) + .setAttemptDirectPath(false) + .setEnableGrpcClientMetrics(false) + .build(); doTest(options); } diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/BackendResources.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/BackendResources.java index 4ed6887fe5..9739abcc3f 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/BackendResources.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/BackendResources.java @@ -117,6 +117,7 @@ static BackendResources of(Backend backend) { optionsBuilder .setGrpcInterceptorProvider( GrpcPlainRequestLoggingInterceptor.getInterceptorProvider()) + .setEnableGrpcClientMetrics(false) .build(); return new StorageInstance(built, protectedBucketNames); });