From 9d8f77c96c9d555839d310adb6f1106c58e7b621 Mon Sep 17 00:00:00 2001 From: Sergii Tkachenko Date: Tue, 25 Aug 2020 16:13:22 -0400 Subject: [PATCH] interop-testing, testing: setup channels with internal channel builders --- .../io/grpc/testing/integration/TestServiceClient.java | 10 ++++++---- .../testing/integration/AutoWindowSizingOnTest.java | 3 ++- .../integration/Http2NettyLocalChannelTest.java | 3 ++- .../io/grpc/testing/integration/Http2NettyTest.java | 3 ++- .../io/grpc/testing/integration/Http2OkHttpTest.java | 3 ++- .../io/grpc/testing/integration/InProcessTest.java | 3 ++- .../testing/integration/TransportCompressionTest.java | 3 ++- .../main/java/io/grpc/internal/TestingAccessor.java | 7 ------- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java b/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java index fa7010d19a88..5823435ae94f 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java @@ -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; @@ -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) { @@ -425,6 +426,7 @@ protected ManagedChannelBuilder createChannelBuilder() { if (fullStreamDecompression) { nettyBuilder.enableFullStreamDecompression(); } + InternalNettyChannelBuilder.setStatsEnabled(nettyBuilder, false); builder = nettyBuilder; } else { OkHttpChannelBuilder okBuilder = OkHttpChannelBuilder.forAddress(serverHost, serverPort); @@ -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()); } diff --git a/interop-testing/src/test/java/io/grpc/testing/integration/AutoWindowSizingOnTest.java b/interop-testing/src/test/java/io/grpc/testing/integration/AutoWindowSizingOnTest.java index a68181be8315..a2036ecea91e 100644 --- a/interop-testing/src/test/java/io/grpc/testing/integration/AutoWindowSizingOnTest.java +++ b/interop-testing/src/test/java/io/grpc/testing/integration/AutoWindowSizingOnTest.java @@ -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; @@ -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()); } } diff --git a/interop-testing/src/test/java/io/grpc/testing/integration/Http2NettyLocalChannelTest.java b/interop-testing/src/test/java/io/grpc/testing/integration/Http2NettyLocalChannelTest.java index 5592801755b0..8ed7dc769004 100644 --- a/interop-testing/src/test/java/io/grpc/testing/integration/Http2NettyLocalChannelTest.java +++ b/interop-testing/src/test/java/io/grpc/testing/integration/Http2NettyLocalChannelTest.java @@ -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; @@ -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()); } diff --git a/interop-testing/src/test/java/io/grpc/testing/integration/Http2NettyTest.java b/interop-testing/src/test/java/io/grpc/testing/integration/Http2NettyTest.java index 1819b9f3008c..353180cbafb5 100644 --- a/interop-testing/src/test/java/io/grpc/testing/integration/Http2NettyTest.java +++ b/interop-testing/src/test/java/io/grpc/testing/integration/Http2NettyTest.java @@ -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; @@ -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); diff --git a/interop-testing/src/test/java/io/grpc/testing/integration/Http2OkHttpTest.java b/interop-testing/src/test/java/io/grpc/testing/integration/Http2OkHttpTest.java index 041c7cafaa69..fc6e600789d7 100644 --- a/interop-testing/src/test/java/io/grpc/testing/integration/Http2OkHttpTest.java +++ b/interop-testing/src/test/java/io/grpc/testing/integration/Http2OkHttpTest.java @@ -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; @@ -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()); } diff --git a/interop-testing/src/test/java/io/grpc/testing/integration/InProcessTest.java b/interop-testing/src/test/java/io/grpc/testing/integration/InProcessTest.java index fd403affcf54..66894834b953 100644 --- a/interop-testing/src/test/java/io/grpc/testing/integration/InProcessTest.java +++ b/interop-testing/src/test/java/io/grpc/testing/integration/InProcessTest.java @@ -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; @@ -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()); } diff --git a/interop-testing/src/test/java/io/grpc/testing/integration/TransportCompressionTest.java b/interop-testing/src/test/java/io/grpc/testing/integration/TransportCompressionTest.java index 8bc0494b79d1..1144c75073cb 100644 --- a/interop-testing/src/test/java/io/grpc/testing/integration/TransportCompressionTest.java +++ b/interop-testing/src/test/java/io/grpc/testing/integration/TransportCompressionTest.java @@ -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; @@ -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()); } diff --git a/testing/src/main/java/io/grpc/internal/TestingAccessor.java b/testing/src/main/java/io/grpc/internal/TestingAccessor.java index d5b00e025fc0..92dc114d9c60 100644 --- a/testing/src/main/java/io/grpc/internal/TestingAccessor.java +++ b/testing/src/main/java/io/grpc/internal/TestingAccessor.java @@ -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.