From 1330841a876f7616cb50a4f9842f909983fe5c1c Mon Sep 17 00:00:00 2001 From: detmerl Date: Tue, 1 Oct 2024 14:20:38 -0400 Subject: [PATCH] fixed changes to existing tests --- .../InstantiatingGrpcChannelProviderTest.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java index c634aa0f11..75ed58f729 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java @@ -712,7 +712,7 @@ void testLogDirectPathMisconfigNotOnGCE() throws Exception { } @Test - public void canUseDirectPath_happyPath() { + public void canUseDirectPath_happyPath() throws IOException { System.setProperty("os.name", "Linux"); EnvironmentProvider envProvider = Mockito.mock(EnvironmentProvider.class); Mockito.when( @@ -724,14 +724,20 @@ public void canUseDirectPath_happyPath() { .setAttemptDirectPath(true) .setCredentials(computeEngineCredentials) .setEndpoint(DEFAULT_ENDPOINT) - .setEnvProvider(envProvider); + .setEnvProvider(envProvider) + .setHeaderProvider(Mockito.mock(HeaderProvider.class)); InstantiatingGrpcChannelProvider provider = new InstantiatingGrpcChannelProvider(builder, GCE_PRODUCTION_NAME_AFTER_2016); Truth.assertThat(provider.canUseDirectPath()).isTrue(); + + // verify this info is passed correctly to transport channel + TransportChannel transportChannel = provider.getTransportChannel(); + Truth.assertThat(((GrpcTransportChannel) transportChannel).isDirectPath()).isTrue(); + transportChannel.shutdownNow(); } @Test - public void canUseDirectPath_directPathEnvVarDisabled() { + public void canUseDirectPath_directPathEnvVarDisabled() throws IOException { System.setProperty("os.name", "Linux"); EnvironmentProvider envProvider = Mockito.mock(EnvironmentProvider.class); Mockito.when( @@ -743,10 +749,16 @@ public void canUseDirectPath_directPathEnvVarDisabled() { .setAttemptDirectPath(true) .setCredentials(computeEngineCredentials) .setEndpoint(DEFAULT_ENDPOINT) - .setEnvProvider(envProvider); + .setEnvProvider(envProvider) + .setHeaderProvider(Mockito.mock(HeaderProvider.class)); InstantiatingGrpcChannelProvider provider = new InstantiatingGrpcChannelProvider(builder, GCE_PRODUCTION_NAME_AFTER_2016); Truth.assertThat(provider.canUseDirectPath()).isFalse(); + + // verify this info is passed correctly to transport channel + TransportChannel transportChannel = provider.getTransportChannel(); + Truth.assertThat(((GrpcTransportChannel) transportChannel).isDirectPath()).isFalse(); + transportChannel.shutdownNow(); } @Test