interop-testing: Add integration test for RetriableStream

This commit is contained in:
Eric Anderson 2020-07-09 09:09:51 -07:00 committed by Eric Anderson
parent 825c34f606
commit cb5ceaaaa0
11 changed files with 44 additions and 29 deletions

View File

@ -19,6 +19,7 @@ package io.grpc.android.integrationtest;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.util.Log; import android.util.Log;
import io.grpc.ManagedChannel; import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.testing.integration.AbstractInteropTest; import io.grpc.testing.integration.AbstractInteropTest;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
@ -156,6 +157,11 @@ final class InteropTask extends AsyncTask<Void, Void, String> {
return channel; return channel;
} }
@Override
protected ManagedChannelBuilder<?> createChannelBuilder() {
throw new UnsupportedOperationException();
}
@Override @Override
protected boolean metricsExpected() { protected boolean metricsExpected() {
return false; return false;

View File

@ -19,7 +19,6 @@ package io.grpc.testing.integration;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder; import io.grpc.ManagedChannelBuilder;
import io.grpc.netty.NettyChannelBuilder; import io.grpc.netty.NettyChannelBuilder;
import java.io.IOException; import java.io.IOException;
@ -126,7 +125,7 @@ public final class NettyClientInteropServlet extends HttpServlet {
public static final class Tester extends AbstractInteropTest { public static final class Tester extends AbstractInteropTest {
@Override @Override
protected ManagedChannel createChannel() { protected ManagedChannelBuilder<?> createChannelBuilder() {
assertEquals( assertEquals(
"jdk8 required", "jdk8 required",
"1.8", "1.8",
@ -136,7 +135,7 @@ public final class NettyClientInteropServlet extends HttpServlet {
.maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE); .maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE);
assertTrue(builder instanceof NettyChannelBuilder); assertTrue(builder instanceof NettyChannelBuilder);
((NettyChannelBuilder) builder).flowControlWindow(65 * 1024); ((NettyChannelBuilder) builder).flowControlWindow(65 * 1024);
return builder.build(); return builder;
} }
@Override @Override

View File

@ -49,6 +49,7 @@ import io.grpc.ClientStreamTracer;
import io.grpc.Context; import io.grpc.Context;
import io.grpc.Grpc; import io.grpc.Grpc;
import io.grpc.ManagedChannel; import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.Server; import io.grpc.Server;
@ -337,7 +338,11 @@ public abstract class AbstractInteropTest {
stopServer(); stopServer();
} }
protected abstract ManagedChannel createChannel(); protected ManagedChannel createChannel() {
return createChannelBuilder().build();
}
protected abstract ManagedChannelBuilder<?> createChannelBuilder();
@Nullable @Nullable
protected ClientInterceptor[] getAdditionalInterceptors() { protected ClientInterceptor[] getAdditionalInterceptors() {
@ -374,6 +379,13 @@ public abstract class AbstractInteropTest {
assertEquals(EMPTY, blockingStub.emptyCall(EMPTY)); assertEquals(EMPTY, blockingStub.emptyCall(EMPTY));
} }
@Test
public void emptyUnaryWithRetriableStream() throws Exception {
channel.shutdown();
channel = createChannelBuilder().enableRetry().build();
assertEquals(EMPTY, TestServiceGrpc.newBlockingStub(channel).emptyCall(EMPTY));
}
/** Sends a cacheable unary rpc using GET. Requires that the server is behind a caching proxy. */ /** Sends a cacheable unary rpc using GET. Requires that the server is behind a caching proxy. */
public void cacheableUnary() { public void cacheableUnary() {
// THIS TEST IS BROKEN. Enabling safe just on the MethodDescriptor does nothing by itself. This // THIS TEST IS BROKEN. Enabling safe just on the MethodDescriptor does nothing by itself. This

View File

@ -33,6 +33,7 @@ import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.MoreExecutors;
import io.grpc.ManagedChannel; import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.Server; import io.grpc.Server;
import io.grpc.ServerBuilder; import io.grpc.ServerBuilder;
import io.grpc.Status; import io.grpc.Status;
@ -515,6 +516,11 @@ public class StressTestClient {
return Worker.this.channel; return Worker.this.channel;
} }
@Override
protected ManagedChannelBuilder<?> createChannelBuilder() {
throw new UnsupportedOperationException();
}
@Override @Override
protected int operationTimeoutMillis() { protected int operationTimeoutMillis() {
// Don't enforce a timeout when using the interop tests for the stress test client. // Don't enforce a timeout when using the interop tests for the stress test client.

View File

@ -19,6 +19,7 @@ package io.grpc.testing.integration;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.io.Files; import com.google.common.io.Files;
import io.grpc.ManagedChannel; import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.alts.AltsChannelBuilder; import io.grpc.alts.AltsChannelBuilder;
import io.grpc.alts.ComputeEngineChannelBuilder; import io.grpc.alts.ComputeEngineChannelBuilder;
import io.grpc.alts.GoogleDefaultChannelBuilder; import io.grpc.alts.GoogleDefaultChannelBuilder;
@ -389,17 +390,17 @@ public class TestServiceClient {
private class Tester extends AbstractInteropTest { private class Tester extends AbstractInteropTest {
@Override @Override
protected ManagedChannel createChannel() { protected ManagedChannelBuilder<?> createChannelBuilder() {
if (customCredentialsType != null if (customCredentialsType != null
&& customCredentialsType.equals("google_default_credentials")) { && customCredentialsType.equals("google_default_credentials")) {
return GoogleDefaultChannelBuilder.forAddress(serverHost, serverPort).build(); return GoogleDefaultChannelBuilder.forAddress(serverHost, serverPort);
} }
if (customCredentialsType != null if (customCredentialsType != null
&& customCredentialsType.equals("compute_engine_channel_creds")) { && customCredentialsType.equals("compute_engine_channel_creds")) {
return ComputeEngineChannelBuilder.forAddress(serverHost, serverPort).build(); return ComputeEngineChannelBuilder.forAddress(serverHost, serverPort);
} }
if (useAlts) { if (useAlts) {
return AltsChannelBuilder.forAddress(serverHost, serverPort).build(); return AltsChannelBuilder.forAddress(serverHost, serverPort);
} }
AbstractManagedChannelImplBuilder<?> builder; AbstractManagedChannelImplBuilder<?> builder;
if (!useOkHttp) { if (!useOkHttp) {
@ -452,7 +453,7 @@ public class TestServiceClient {
} }
// Disable the default census stats interceptor, use testing interceptor instead. // Disable the default census stats interceptor, use testing interceptor instead.
io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false); io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor()).build(); return builder.intercept(createCensusStatsClientInterceptor());
} }
@Override @Override

View File

@ -16,7 +16,6 @@
package io.grpc.testing.integration; package io.grpc.testing.integration;
import io.grpc.ManagedChannel;
import io.grpc.internal.AbstractServerImplBuilder; import io.grpc.internal.AbstractServerImplBuilder;
import io.grpc.netty.NegotiationType; import io.grpc.netty.NegotiationType;
import io.grpc.netty.NettyChannelBuilder; import io.grpc.netty.NettyChannelBuilder;
@ -34,13 +33,13 @@ public class AutoWindowSizingOnTest extends AbstractInteropTest {
} }
@Override @Override
protected ManagedChannel createChannel() { protected NettyChannelBuilder createChannelBuilder() {
NettyChannelBuilder builder = NettyChannelBuilder.forAddress(getListenAddress()) NettyChannelBuilder builder = NettyChannelBuilder.forAddress(getListenAddress())
.negotiationType(NegotiationType.PLAINTEXT) .negotiationType(NegotiationType.PLAINTEXT)
.maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE) .maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE)
.initialFlowControlWindow(NettyChannelBuilder.DEFAULT_FLOW_CONTROL_WINDOW); .initialFlowControlWindow(NettyChannelBuilder.DEFAULT_FLOW_CONTROL_WINDOW);
// Disable the default census stats interceptor, use testing interceptor instead. // Disable the default census stats interceptor, use testing interceptor instead.
io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false); io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor()).build(); return builder.intercept(createCensusStatsClientInterceptor());
} }
} }

View File

@ -16,7 +16,6 @@
package io.grpc.testing.integration; package io.grpc.testing.integration;
import io.grpc.ManagedChannel;
import io.grpc.internal.AbstractServerImplBuilder; import io.grpc.internal.AbstractServerImplBuilder;
import io.grpc.netty.NegotiationType; import io.grpc.netty.NegotiationType;
import io.grpc.netty.NettyChannelBuilder; import io.grpc.netty.NettyChannelBuilder;
@ -49,7 +48,7 @@ public class Http2NettyLocalChannelTest extends AbstractInteropTest {
} }
@Override @Override
protected ManagedChannel createChannel() { protected NettyChannelBuilder createChannelBuilder() {
NettyChannelBuilder builder = NettyChannelBuilder NettyChannelBuilder builder = NettyChannelBuilder
.forAddress(new LocalAddress("in-process-1")) .forAddress(new LocalAddress("in-process-1"))
.negotiationType(NegotiationType.PLAINTEXT) .negotiationType(NegotiationType.PLAINTEXT)
@ -59,7 +58,7 @@ public class Http2NettyLocalChannelTest extends AbstractInteropTest {
.maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE); .maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE);
// Disable the default census stats interceptor, use testing interceptor instead. // Disable the default census stats interceptor, use testing interceptor instead.
io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false); io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor()).build(); return builder.intercept(createCensusStatsClientInterceptor());
} }
@Override @Override

View File

@ -19,7 +19,6 @@ package io.grpc.testing.integration;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
import io.grpc.ManagedChannel;
import io.grpc.internal.AbstractServerImplBuilder; import io.grpc.internal.AbstractServerImplBuilder;
import io.grpc.internal.testing.TestUtils; import io.grpc.internal.testing.TestUtils;
import io.grpc.netty.GrpcSslContexts; import io.grpc.netty.GrpcSslContexts;
@ -59,7 +58,7 @@ public class Http2NettyTest extends AbstractInteropTest {
} }
@Override @Override
protected ManagedChannel createChannel() { protected NettyChannelBuilder createChannelBuilder() {
try { try {
NettyChannelBuilder builder = NettyChannelBuilder NettyChannelBuilder builder = NettyChannelBuilder
.forAddress(TestUtils.testServerAddress((InetSocketAddress) getListenAddress())) .forAddress(TestUtils.testServerAddress((InetSocketAddress) getListenAddress()))
@ -73,7 +72,7 @@ public class Http2NettyTest extends AbstractInteropTest {
.build()); .build());
// Disable the default census stats interceptor, use testing interceptor instead. // Disable the default census stats interceptor, use testing interceptor instead.
io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false); io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor()).build(); return builder.intercept(createCensusStatsClientInterceptor());
} catch (Exception ex) { } catch (Exception ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }

View File

@ -86,11 +86,7 @@ public class Http2OkHttpTest extends AbstractInteropTest {
} }
@Override @Override
protected ManagedChannel createChannel() { protected OkHttpChannelBuilder createChannelBuilder() {
return createChannelBuilder().build();
}
private OkHttpChannelBuilder createChannelBuilder() {
int port = ((InetSocketAddress) getListenAddress()).getPort(); int port = ((InetSocketAddress) getListenAddress()).getPort();
OkHttpChannelBuilder builder = OkHttpChannelBuilder.forAddress("localhost", port) OkHttpChannelBuilder builder = OkHttpChannelBuilder.forAddress("localhost", port)
.maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE) .maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE)

View File

@ -16,7 +16,6 @@
package io.grpc.testing.integration; package io.grpc.testing.integration;
import io.grpc.ManagedChannel;
import io.grpc.inprocess.InProcessChannelBuilder; import io.grpc.inprocess.InProcessChannelBuilder;
import io.grpc.inprocess.InProcessServerBuilder; import io.grpc.inprocess.InProcessServerBuilder;
import io.grpc.internal.AbstractServerImplBuilder; import io.grpc.internal.AbstractServerImplBuilder;
@ -36,11 +35,11 @@ public class InProcessTest extends AbstractInteropTest {
} }
@Override @Override
protected ManagedChannel createChannel() { protected InProcessChannelBuilder createChannelBuilder() {
InProcessChannelBuilder builder = InProcessChannelBuilder.forName(SERVER_NAME); InProcessChannelBuilder builder = InProcessChannelBuilder.forName(SERVER_NAME);
// Disable the default census stats interceptor, use testing interceptor instead. // Disable the default census stats interceptor, use testing interceptor instead.
io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false); io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor()).build(); return builder.intercept(createCensusStatsClientInterceptor());
} }
@Override @Override

View File

@ -29,7 +29,6 @@ import io.grpc.CompressorRegistry;
import io.grpc.DecompressorRegistry; import io.grpc.DecompressorRegistry;
import io.grpc.ForwardingClientCall; import io.grpc.ForwardingClientCall;
import io.grpc.ForwardingClientCallListener; import io.grpc.ForwardingClientCallListener;
import io.grpc.ManagedChannel;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.ServerCall; import io.grpc.ServerCall;
@ -122,7 +121,7 @@ public class TransportCompressionTest extends AbstractInteropTest {
} }
@Override @Override
protected ManagedChannel createChannel() { protected NettyChannelBuilder createChannelBuilder() {
NettyChannelBuilder builder = NettyChannelBuilder.forAddress(getListenAddress()) NettyChannelBuilder builder = NettyChannelBuilder.forAddress(getListenAddress())
.maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE) .maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE)
.decompressorRegistry(decompressors) .decompressorRegistry(decompressors)
@ -167,7 +166,7 @@ public class TransportCompressionTest extends AbstractInteropTest {
.usePlaintext(); .usePlaintext();
// Disable the default census stats interceptor, use testing interceptor instead. // Disable the default census stats interceptor, use testing interceptor instead.
io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false); io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor()).build(); return builder.intercept(createCensusStatsClientInterceptor());
} }
/** /**