interop-testing: Avoid alts incompatibility with netty

alts requires netty-shaded, not netty.
This commit is contained in:
Eric Anderson 2020-10-08 10:38:29 -07:00 committed by Eric Anderson
parent 5c59fd2b1a
commit 0203256171
1 changed files with 11 additions and 2 deletions

View File

@ -396,9 +396,10 @@ public class TestServiceClient {
private class Tester extends AbstractInteropTest { private class Tester extends AbstractInteropTest {
@Override @Override
protected ManagedChannelBuilder<?> createChannelBuilder() { protected ManagedChannelBuilder<?> createChannelBuilder() {
boolean useGeneric = false;
ChannelCredentials channelCredentials; ChannelCredentials channelCredentials;
if (customCredentialsType != null) { if (customCredentialsType != null) {
useOkHttp = false; // Retain old behavior; avoids erroring if incompatible useGeneric = true; // Retain old behavior; avoids erroring if incompatible
if (customCredentialsType.equals("google_default_credentials")) { if (customCredentialsType.equals("google_default_credentials")) {
channelCredentials = GoogleDefaultChannelCredentials.create(); channelCredentials = GoogleDefaultChannelCredentials.create();
} else if (customCredentialsType.equals("compute_engine_channel_creds")) { } else if (customCredentialsType.equals("compute_engine_channel_creds")) {
@ -409,7 +410,7 @@ public class TestServiceClient {
} }
} else if (useAlts) { } else if (useAlts) {
useOkHttp = false; // Retain old behavior; avoids erroring if incompatible useGeneric = true; // Retain old behavior; avoids erroring if incompatible
channelCredentials = AltsChannelCredentials.create(); channelCredentials = AltsChannelCredentials.create();
} else if (useTls) { } else if (useTls) {
@ -442,6 +443,14 @@ public class TestServiceClient {
channelCredentials = InsecureChannelCredentials.create(); channelCredentials = InsecureChannelCredentials.create();
} }
} }
if (useGeneric) {
ManagedChannelBuilder<?> channelBuilder =
Grpc.newChannelBuilderForAddress(serverHost, serverPort, channelCredentials);
if (serverHostOverride != null) {
channelBuilder.overrideAuthority(serverHostOverride);
}
return channelBuilder;
}
if (!useOkHttp) { if (!useOkHttp) {
NettyChannelBuilder nettyBuilder = NettyChannelBuilder nettyBuilder =
NettyChannelBuilder.forAddress(serverHost, serverPort, channelCredentials) NettyChannelBuilder.forAddress(serverHost, serverPort, channelCredentials)