Skip to content

Commit

Permalink
interop-testing, testing: setup channels with internal channel builders
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiitk committed Aug 25, 2020
1 parent 877e6fd commit 9d8f77c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
import io.grpc.alts.AltsChannelBuilder;
import io.grpc.alts.ComputeEngineChannelBuilder;
import io.grpc.alts.GoogleDefaultChannelBuilder;
import io.grpc.internal.AbstractManagedChannelImplBuilder;
import io.grpc.internal.GrpcUtil;
import io.grpc.internal.testing.TestUtils;
import io.grpc.netty.GrpcSslContexts;
import io.grpc.netty.InternalNettyChannelBuilder;
import io.grpc.netty.NegotiationType;
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.okhttp.InternalOkHttpChannelBuilder;
import io.grpc.okhttp.OkHttpChannelBuilder;
import io.grpc.okhttp.internal.Platform;
import io.netty.handler.ssl.SslContext;
Expand Down Expand Up @@ -402,7 +403,7 @@ protected ManagedChannelBuilder<?> createChannelBuilder() {
if (useAlts) {
return AltsChannelBuilder.forAddress(serverHost, serverPort);
}
AbstractManagedChannelImplBuilder<?> builder;
ManagedChannelBuilder<?> builder;
if (!useOkHttp) {
SslContext sslContext = null;
if (useTestCa) {
Expand All @@ -425,6 +426,7 @@ protected ManagedChannelBuilder<?> createChannelBuilder() {
if (fullStreamDecompression) {
nettyBuilder.enableFullStreamDecompression();
}
InternalNettyChannelBuilder.setStatsEnabled(nettyBuilder, false);
builder = nettyBuilder;
} else {
OkHttpChannelBuilder okBuilder = OkHttpChannelBuilder.forAddress(serverHost, serverPort);
Expand All @@ -449,10 +451,10 @@ protected ManagedChannelBuilder<?> createChannelBuilder() {
if (fullStreamDecompression) {
okBuilder.enableFullStreamDecompression();
}
InternalOkHttpChannelBuilder.setStatsEnabled(okBuilder, false);
builder = okBuilder;
}
// Disable the default census stats interceptor, use testing interceptor instead.
io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
// Use testing interceptor instead.
return builder.intercept(createCensusStatsClientInterceptor());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package io.grpc.testing.integration;

import io.grpc.internal.AbstractServerImplBuilder;
import io.grpc.netty.InternalNettyChannelBuilder;
import io.grpc.netty.NegotiationType;
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.NettyServerBuilder;
Expand All @@ -39,7 +40,7 @@ protected NettyChannelBuilder createChannelBuilder() {
.maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE)
.initialFlowControlWindow(NettyChannelBuilder.DEFAULT_FLOW_CONTROL_WINDOW);
// Disable the default census stats interceptor, use testing interceptor instead.
io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
InternalNettyChannelBuilder.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package io.grpc.testing.integration;

import io.grpc.internal.AbstractServerImplBuilder;
import io.grpc.netty.InternalNettyChannelBuilder;
import io.grpc.netty.NegotiationType;
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.NettyServerBuilder;
Expand Down Expand Up @@ -57,7 +58,7 @@ protected NettyChannelBuilder createChannelBuilder() {
.flowControlWindow(65 * 1024)
.maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE);
// Disable the default census stats interceptor, use testing interceptor instead.
io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
InternalNettyChannelBuilder.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.grpc.internal.AbstractServerImplBuilder;
import io.grpc.internal.testing.TestUtils;
import io.grpc.netty.GrpcSslContexts;
import io.grpc.netty.InternalNettyChannelBuilder;
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.NettyServerBuilder;
import io.netty.handler.ssl.ClientAuth;
Expand Down Expand Up @@ -71,7 +72,7 @@ protected NettyChannelBuilder createChannelBuilder() {
.ciphers(TestUtils.preferredTestCiphers(), SupportedCipherSuiteFilter.INSTANCE)
.build());
// Disable the default census stats interceptor, use testing interceptor instead.
io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
InternalNettyChannelBuilder.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor());
} catch (Exception ex) {
throw new RuntimeException(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.grpc.internal.testing.TestUtils;
import io.grpc.netty.GrpcSslContexts;
import io.grpc.netty.NettyServerBuilder;
import io.grpc.okhttp.InternalOkHttpChannelBuilder;
import io.grpc.okhttp.OkHttpChannelBuilder;
import io.grpc.okhttp.internal.Platform;
import io.grpc.stub.StreamObserver;
Expand Down Expand Up @@ -102,7 +103,7 @@ protected OkHttpChannelBuilder createChannelBuilder() {
throw new RuntimeException(e);
}
// Disable the default census stats interceptor, use testing interceptor instead.
io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
InternalOkHttpChannelBuilder.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.grpc.inprocess.InProcessChannelBuilder;
import io.grpc.inprocess.InProcessServerBuilder;
import io.grpc.inprocess.InternalInProcessChannelBuilder;
import io.grpc.internal.AbstractServerImplBuilder;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand All @@ -38,7 +39,7 @@ protected AbstractServerImplBuilder<?> getServerBuilder() {
protected InProcessChannelBuilder createChannelBuilder() {
InProcessChannelBuilder builder = InProcessChannelBuilder.forName(SERVER_NAME);
// Disable the default census stats interceptor, use testing interceptor instead.
io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
InternalInProcessChannelBuilder.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import io.grpc.ServerInterceptor;
import io.grpc.internal.AbstractServerImplBuilder;
import io.grpc.internal.GrpcUtil;
import io.grpc.netty.InternalNettyChannelBuilder;
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.NettyServerBuilder;
import io.grpc.testing.integration.Messages.BoolValue;
Expand Down Expand Up @@ -165,7 +166,7 @@ public void onHeaders(Metadata headers) {
})
.usePlaintext();
// Disable the default census stats interceptor, use testing interceptor instead.
io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
InternalNettyChannelBuilder.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor());
}

Expand Down
7 changes: 0 additions & 7 deletions testing/src/main/java/io/grpc/internal/TestingAccessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
* Test helper that allows accessing package-private stuff.
*/
public final class TestingAccessor {
/**
* Disable or enable client side census stats features.
*/
public static void setStatsEnabled(
AbstractManagedChannelImplBuilder<?> builder, boolean statsEnabled) {
builder.setStatsEnabled(statsEnabled);
}

/**
* Disable or enable server side census stats features.
Expand Down

0 comments on commit 9d8f77c

Please sign in to comment.