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

View File

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

View File

@ -49,6 +49,7 @@ import io.grpc.ClientStreamTracer;
import io.grpc.Context;
import io.grpc.Grpc;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;
import io.grpc.Server;
@ -337,7 +338,11 @@ public abstract class AbstractInteropTest {
stopServer();
}
protected abstract ManagedChannel createChannel();
protected ManagedChannel createChannel() {
return createChannelBuilder().build();
}
protected abstract ManagedChannelBuilder<?> createChannelBuilder();
@Nullable
protected ClientInterceptor[] getAdditionalInterceptors() {
@ -374,6 +379,13 @@ public abstract class AbstractInteropTest {
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. */
public void cacheableUnary() {
// 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.MoreExecutors;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.Server;
import io.grpc.ServerBuilder;
import io.grpc.Status;
@ -515,6 +516,11 @@ public class StressTestClient {
return Worker.this.channel;
}
@Override
protected ManagedChannelBuilder<?> createChannelBuilder() {
throw new UnsupportedOperationException();
}
@Override
protected int operationTimeoutMillis() {
// 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.io.Files;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.alts.AltsChannelBuilder;
import io.grpc.alts.ComputeEngineChannelBuilder;
import io.grpc.alts.GoogleDefaultChannelBuilder;
@ -389,17 +390,17 @@ public class TestServiceClient {
private class Tester extends AbstractInteropTest {
@Override
protected ManagedChannel createChannel() {
protected ManagedChannelBuilder<?> createChannelBuilder() {
if (customCredentialsType != null
&& customCredentialsType.equals("google_default_credentials")) {
return GoogleDefaultChannelBuilder.forAddress(serverHost, serverPort).build();
return GoogleDefaultChannelBuilder.forAddress(serverHost, serverPort);
}
if (customCredentialsType != null
&& customCredentialsType.equals("compute_engine_channel_creds")) {
return ComputeEngineChannelBuilder.forAddress(serverHost, serverPort).build();
return ComputeEngineChannelBuilder.forAddress(serverHost, serverPort);
}
if (useAlts) {
return AltsChannelBuilder.forAddress(serverHost, serverPort).build();
return AltsChannelBuilder.forAddress(serverHost, serverPort);
}
AbstractManagedChannelImplBuilder<?> builder;
if (!useOkHttp) {
@ -452,7 +453,7 @@ public class TestServiceClient {
}
// Disable the default census stats interceptor, use testing interceptor instead.
io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor()).build();
return builder.intercept(createCensusStatsClientInterceptor());
}
@Override

View File

@ -16,7 +16,6 @@
package io.grpc.testing.integration;
import io.grpc.ManagedChannel;
import io.grpc.internal.AbstractServerImplBuilder;
import io.grpc.netty.NegotiationType;
import io.grpc.netty.NettyChannelBuilder;
@ -34,13 +33,13 @@ public class AutoWindowSizingOnTest extends AbstractInteropTest {
}
@Override
protected ManagedChannel createChannel() {
protected NettyChannelBuilder createChannelBuilder() {
NettyChannelBuilder builder = NettyChannelBuilder.forAddress(getListenAddress())
.negotiationType(NegotiationType.PLAINTEXT)
.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);
return builder.intercept(createCensusStatsClientInterceptor()).build();
return builder.intercept(createCensusStatsClientInterceptor());
}
}

View File

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

View File

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

View File

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

View File

@ -16,7 +16,6 @@
package io.grpc.testing.integration;
import io.grpc.ManagedChannel;
import io.grpc.inprocess.InProcessChannelBuilder;
import io.grpc.inprocess.InProcessServerBuilder;
import io.grpc.internal.AbstractServerImplBuilder;
@ -36,11 +35,11 @@ public class InProcessTest extends AbstractInteropTest {
}
@Override
protected ManagedChannel createChannel() {
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);
return builder.intercept(createCensusStatsClientInterceptor()).build();
return builder.intercept(createCensusStatsClientInterceptor());
}
@Override

View File

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