public abstract class AbstractInteropTest extends Object
New tests should avoid using Mockito to support running on AppEngine.
| Modifier and Type | Field and Description |
|---|---|
protected TestServiceGrpc.TestServiceStub |
asyncStub |
protected TestServiceGrpc.TestServiceBlockingStub |
blockingStub |
protected io.grpc.ManagedChannel |
channel |
protected static EmptyProtos.Empty |
EMPTY |
org.junit.rules.TestRule |
globalTimeout |
static int |
MAX_MESSAGE_SIZE
Must be at least
unaryPayloadLength(), plus some to account for encoding overhead. |
static int |
TEST_FLOW_CONTROL_WINDOW
Use a small flow control to help detect flow control bugs.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractInteropTest()
Constructor for tests.
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
assertSuccess(io.grpc.internal.testing.StreamRecorder<?> recorder) |
protected void |
assertX500SubjectDn(String tlsInfo)
Helper for asserting TLS info in SSLSession
ServerCall.getAttributes(). |
protected static void |
assumeEnoughMemory()
Some tests run on memory constrained environments.
|
void |
cacheableUnary()
Sends a cacheable unary rpc using GET.
|
void |
cancelAfterBegin() |
void |
cancelAfterFirstResponse() |
void |
censusContextsPropagated() |
void |
clientCompressedStreaming(boolean probe)
Tests client per-message compression for streaming calls.
|
void |
clientCompressedUnary(boolean probe)
Tests client per-message compression for unary calls.
|
void |
clientStreaming() |
void |
computeEngineChannelCredentials(String defaultServiceAccount,
TestServiceGrpc.TestServiceBlockingStub computeEngineStub)
Sends an unary rpc with ComputeEngineChannelBuilder.
|
void |
computeEngineCreds(String serviceAccount,
String oauthScope)
Sends a large unary rpc with compute engine credentials.
|
protected io.grpc.ClientInterceptor |
createCensusStatsClientInterceptor() |
protected io.grpc.ManagedChannel |
createChannel() |
protected abstract io.grpc.ManagedChannelBuilder<?> |
createChannelBuilder() |
protected io.grpc.ServerStreamTracer.Factory |
createCustomCensusTracerFactory() |
protected boolean |
customCensusModulePresent()
Override this when custom census module presence is different from
metricsExpected(). |
void |
customMetadata() |
void |
deadlineExceeded() |
void |
deadlineExceededServerStreaming() |
void |
deadlineInPast() |
void |
deadlineNotExceeded() |
void |
emptyStream() |
void |
emptyUnary() |
void |
emptyUnaryWithRetriableStream() |
void |
exchangeMetadataStreamingCall() |
void |
exchangeMetadataUnaryCall() |
void |
fullDuplexCallShouldSucceed() |
protected io.grpc.ClientInterceptor[] |
getAdditionalInterceptors() |
protected io.grpc.ServerBuilder<?> |
getHandshakerServerBuilder() |
void |
getServerAddressAndLocalAddressFromClient()
Verifies remote server address and local client address are available from ClientCall
Attributes via ClientInterceptor.
|
protected io.grpc.ServerBuilder<?> |
getServerBuilder()
Returns the server builder used to create server for each test run.
|
void |
googleDefaultCredentials(String defaultServiceAccount,
TestServiceGrpc.TestServiceBlockingStub googleDefaultStub)
Sends an unary rpc with "google default credentials".
|
void |
gracefulShutdown() |
void |
halfDuplexCallShouldSucceed() |
void |
jwtTokenCreds(InputStream serviceAccountJson)
Test JWT-based auth.
|
void |
largeUnary() |
void |
maxInboundSize_exact() |
void |
maxInboundSize_tooBig() |
void |
maxOutboundSize_exact() |
void |
maxOutboundSize_tooBig() |
protected boolean |
metricsExpected()
Return true if exact metric values should be checked.
|
void |
oauth2AuthToken(String jsonKey,
InputStream credentialsStream,
String authScope)
Sends a unary rpc with raw oauth2 access token credentials.
|
protected SocketAddress |
obtainLocalClientAddr()
Helper for getting local address from
ClientCall.getAttributes(). |
protected SocketAddress |
obtainLocalServerAddr()
Helper for getting local address from
ServerCall.getAttributes(). |
protected SocketAddress |
obtainRemoteClientAddr()
Helper for getting remote address from
ServerCall.getAttributes(). |
protected SocketAddress |
obtainRemoteServerAddr()
Helper for getting remote address from
ClientCall.getAttributes(). |
protected int |
operationTimeoutMillis() |
void |
performSoakTest(String serverUri,
boolean resetChannelPerIteration,
int soakIterations,
int maxFailures,
int maxAcceptablePerIterationLatencyMs,
int minTimeMsBetweenRpcs,
int overallTimeoutSeconds)
Runs large unary RPCs in a loop with configurable failure thresholds
and channel creation behavior.
|
void |
perRpcCreds(String jsonKey,
InputStream credentialsStream,
String oauthScope)
Sends a unary rpc with "per rpc" raw oauth2 access token credentials.
|
void |
pickFirstUnary()
Assuming "pick_first" policy is used, tests that all requests are sent to the same server.
|
void |
pingPong() |
void |
sendsTimeoutHeader() |
void |
serverCompressedStreaming()
Tests server per-message compression in a streaming response.
|
void |
serverCompressedUnary()
Tests if the server can send a compressed unary response.
|
void |
serverStreaming() |
void |
serverStreamingShouldBeFlowControlled() |
void |
serviceAccountCreds(String jsonKey,
InputStream credentialsStream,
String authScope)
Sends a large unary rpc with service account credentials.
|
void |
setUp()
Must be called by the subclass setup method if overridden.
|
void |
specialStatusMessage() |
protected void |
startServer(io.grpc.ServerBuilder<?> builder) |
void |
statusCodeAndMessage() |
void |
tearDown()
Clean up.
|
void |
testOrcaOob()
Test backend metrics OOB reporting: expect the test client LB policy to receive load reports.
|
void |
testOrcaPerRpc()
Test backend metrics per query reporting: expect the test client LB policy to receive load
reports.
|
void |
timeoutOnSleepingServer()
Start a fullDuplexCall which the server will not respond, and verify the deadline expires.
|
protected int |
unaryPayloadLength() |
void |
unimplementedMethod()
Sends an rpc to an unimplemented method within TestService.
|
void |
unimplementedService()
Sends an rpc to an unimplemented service on the server.
|
void |
veryLargeRequest() |
void |
veryLargeResponse() |
public final org.junit.rules.TestRule globalTimeout
public static final int MAX_MESSAGE_SIZE
unaryPayloadLength(), plus some to account for encoding overhead.public static final int TEST_FLOW_CONTROL_WINDOW
protected static final EmptyProtos.Empty EMPTY
protected io.grpc.ManagedChannel channel
protected TestServiceGrpc.TestServiceBlockingStub blockingStub
protected TestServiceGrpc.TestServiceStub asyncStub
protected void startServer(@Nullable io.grpc.ServerBuilder<?> builder)
public void setUp()
public void tearDown()
protected io.grpc.ManagedChannel createChannel()
protected abstract io.grpc.ManagedChannelBuilder<?> createChannelBuilder()
@Nullable protected io.grpc.ClientInterceptor[] getAdditionalInterceptors()
@Nullable protected io.grpc.ServerBuilder<?> getServerBuilder()
null if
it shouldn't start a server in the same process.@Nullable protected io.grpc.ServerBuilder<?> getHandshakerServerBuilder()
protected final io.grpc.ClientInterceptor createCensusStatsClientInterceptor()
protected final io.grpc.ServerStreamTracer.Factory createCustomCensusTracerFactory()
protected boolean customCensusModulePresent()
metricsExpected().protected boolean metricsExpected()
public void emptyUnaryWithRetriableStream()
throws Exception
Exceptionpublic void cacheableUnary()
public void clientCompressedUnary(boolean probe)
throws Exception
Exceptionpublic void serverCompressedUnary()
throws Exception
Exceptionpublic void pickFirstUnary()
throws Exception
Exceptionpublic void clientCompressedStreaming(boolean probe)
throws Exception
Exceptionpublic void serverCompressedStreaming()
throws Exception
Exceptionpublic void fullDuplexCallShouldSucceed()
throws Exception
Exceptionpublic void halfDuplexCallShouldSucceed()
throws Exception
Exceptionpublic void serverStreamingShouldBeFlowControlled()
throws Exception
Exceptionpublic void exchangeMetadataUnaryCall()
throws Exception
Exceptionpublic void exchangeMetadataStreamingCall()
throws Exception
Exceptionpublic void sendsTimeoutHeader()
public void deadlineNotExceeded()
public void deadlineExceededServerStreaming()
throws Exception
Exceptionpublic void maxInboundSize_exact()
public void maxInboundSize_tooBig()
public void maxOutboundSize_exact()
public void maxOutboundSize_tooBig()
protected int unaryPayloadLength()
public void censusContextsPropagated()
public void unimplementedMethod()
public void unimplementedService()
public void timeoutOnSleepingServer()
throws Exception
Exceptionpublic void getServerAddressAndLocalAddressFromClient()
public void testOrcaPerRpc()
throws Exception
Exceptionpublic void testOrcaOob()
throws Exception
Exceptionpublic void serviceAccountCreds(String jsonKey, InputStream credentialsStream, String authScope) throws Exception
Exceptionpublic void computeEngineCreds(String serviceAccount, String oauthScope) throws Exception
Exceptionpublic void computeEngineChannelCredentials(String defaultServiceAccount, TestServiceGrpc.TestServiceBlockingStub computeEngineStub) throws Exception
Exceptionpublic void jwtTokenCreds(InputStream serviceAccountJson) throws Exception
Exceptionpublic void oauth2AuthToken(String jsonKey, InputStream credentialsStream, String authScope) throws Exception
Exceptionpublic void perRpcCreds(String jsonKey, InputStream credentialsStream, String oauthScope) throws Exception
Exceptionpublic void googleDefaultCredentials(String defaultServiceAccount, TestServiceGrpc.TestServiceBlockingStub googleDefaultStub) throws Exception
Exceptionpublic void performSoakTest(String serverUri, boolean resetChannelPerIteration, int soakIterations, int maxFailures, int maxAcceptablePerIterationLatencyMs, int minTimeMsBetweenRpcs, int overallTimeoutSeconds) throws Exception
Exceptionprotected static void assertSuccess(io.grpc.internal.testing.StreamRecorder<?> recorder)
protected SocketAddress obtainRemoteClientAddr()
ServerCall.getAttributes().protected SocketAddress obtainRemoteServerAddr()
ClientCall.getAttributes().protected SocketAddress obtainLocalServerAddr()
ServerCall.getAttributes().protected SocketAddress obtainLocalClientAddr()
ClientCall.getAttributes().protected void assertX500SubjectDn(String tlsInfo)
ServerCall.getAttributes().protected int operationTimeoutMillis()
protected static void assumeEnoughMemory()