Skip to content

Commit

Permalink
fixed changes to existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ldetmer committed Oct 1, 2024
1 parent d3492b3 commit 1330841
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit 1330841

Please sign in to comment.