Package io.grpc.testing.integration
Class AbstractInteropTest
- java.lang.Object
-
- io.grpc.testing.integration.AbstractInteropTest
-
public abstract class AbstractInteropTest extends java.lang.ObjectAbstract base class for all GRPC transport tests.New tests should avoid using Mockito to support running on AppEngine.
-
-
Field Summary
Fields Modifier and Type Field Description protected TestServiceGrpc.TestServiceStubasyncStubprotected TestServiceGrpc.TestServiceBlockingStubblockingStubprotected io.grpc.ManagedChannelchannelprotected static EmptyProtos.EmptyEMPTYorg.junit.rules.TestRuleglobalTimeoutstatic intMAX_MESSAGE_SIZEMust be at leastunaryPayloadLength(), plus some to account for encoding overhead.static intTEST_FLOW_CONTROL_WINDOWUse a small flow control to help detect flow control bugs.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractInteropTest()Constructor for tests.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static voidassertSuccess(io.grpc.internal.testing.StreamRecorder<?> recorder)protected voidassertX500SubjectDn(java.lang.String tlsInfo)Helper for asserting TLS info in SSLSessionServerCall.getAttributes().protected static voidassumeEnoughMemory()Some tests run on memory constrained environments.voidcacheableUnary()Sends a cacheable unary rpc using GET.voidcancelAfterBegin()voidcancelAfterFirstResponse()voidcensusContextsPropagated()voidclientCompressedStreaming(boolean probe)Tests client per-message compression for streaming calls.voidclientCompressedUnary(boolean probe)Tests client per-message compression for unary calls.voidclientStreaming()voidcomputeEngineChannelCredentials(java.lang.String defaultServiceAccount, TestServiceGrpc.TestServiceBlockingStub computeEngineStub)Sends an unary rpc with ComputeEngineChannelBuilder.voidcomputeEngineCreds(java.lang.String serviceAccount, java.lang.String oauthScope)Sends a large unary rpc with compute engine credentials.protected io.grpc.ClientInterceptorcreateCensusStatsClientInterceptor()protected io.grpc.ManagedChannelcreateChannel()protected abstract io.grpc.ManagedChannelBuilder<?>createChannelBuilder()protected io.grpc.ServerStreamTracer.FactorycreateCustomCensusTracerFactory()protected booleancustomCensusModulePresent()Override this when custom census module presence is different frommetricsExpected().voidcustomMetadata()voiddeadlineExceeded()voiddeadlineExceededServerStreaming()voiddeadlineInPast()voiddeadlineNotExceeded()voidemptyStream()voidemptyUnary()voidemptyUnaryWithRetriableStream()voidexchangeMetadataStreamingCall()voidexchangeMetadataUnaryCall()voidfullDuplexCallShouldSucceed()protected io.grpc.ClientInterceptor[]getAdditionalInterceptors()protected io.grpc.ServerBuilder<?>getHandshakerServerBuilder()voidgetServerAddressAndLocalAddressFromClient()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.voidgoogleDefaultCredentials(java.lang.String defaultServiceAccount, TestServiceGrpc.TestServiceBlockingStub googleDefaultStub)Sends an unary rpc with "google default credentials".voidgracefulShutdown()voidhalfDuplexCallShouldSucceed()voidjwtTokenCreds(java.io.InputStream serviceAccountJson)Test JWT-based auth.voidlargeUnary()voidmaxInboundSize_exact()voidmaxInboundSize_tooBig()voidmaxOutboundSize_exact()voidmaxOutboundSize_tooBig()protected booleanmetricsExpected()Return true if exact metric values should be checked.voidoauth2AuthToken(java.lang.String jsonKey, java.io.InputStream credentialsStream, java.lang.String authScope)Sends a unary rpc with raw oauth2 access token credentials.protected java.net.SocketAddressobtainLocalClientAddr()Helper for getting local address fromClientCall.getAttributes().protected java.net.SocketAddressobtainLocalServerAddr()Helper for getting local address fromServerCall.getAttributes().protected java.net.SocketAddressobtainRemoteClientAddr()Helper for getting remote address fromServerCall.getAttributes().protected java.net.SocketAddressobtainRemoteServerAddr()Helper for getting remote address fromClientCall.getAttributes().protected intoperationTimeoutMillis()voidperformSoakTest(java.lang.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.voidperRpcCreds(java.lang.String jsonKey, java.io.InputStream credentialsStream, java.lang.String oauthScope)Sends a unary rpc with "per rpc" raw oauth2 access token credentials.voidpickFirstUnary()Assuming "pick_first" policy is used, tests that all requests are sent to the same server.voidpingPong()voidsendsTimeoutHeader()voidserverCompressedStreaming()Tests server per-message compression in a streaming response.voidserverCompressedUnary()Tests if the server can send a compressed unary response.voidserverStreaming()voidserverStreamingShouldBeFlowControlled()voidserviceAccountCreds(java.lang.String jsonKey, java.io.InputStream credentialsStream, java.lang.String authScope)Sends a large unary rpc with service account credentials.voidsetUp()Must be called by the subclass setup method if overridden.voidspecialStatusMessage()protected voidstartServer(io.grpc.ServerBuilder<?> builder)voidstatusCodeAndMessage()voidtearDown()Clean up.voidtestOrcaOob()Test backend metrics OOB reporting: expect the test client LB policy to receive load reports.voidtestOrcaPerRpc()Test backend metrics per query reporting: expect the test client LB policy to receive load reports.voidtimeoutOnSleepingServer()Start a fullDuplexCall which the server will not respond, and verify the deadline expires.protected intunaryPayloadLength()voidunimplementedMethod()Sends an rpc to an unimplemented method within TestService.voidunimplementedService()Sends an rpc to an unimplemented service on the server.voidveryLargeRequest()voidveryLargeResponse()
-
-
-
Field Detail
-
globalTimeout
public final org.junit.rules.TestRule globalTimeout
-
MAX_MESSAGE_SIZE
public static final int MAX_MESSAGE_SIZE
Must be at leastunaryPayloadLength(), plus some to account for encoding overhead.- See Also:
- Constant Field Values
-
TEST_FLOW_CONTROL_WINDOW
public static final int TEST_FLOW_CONTROL_WINDOW
Use a small flow control to help detect flow control bugs. Don't use 64KiB to test SETTINGS/WINDOW_UPDATE exchange.- See Also:
- Constant Field Values
-
EMPTY
protected static final EmptyProtos.Empty EMPTY
-
channel
protected io.grpc.ManagedChannel channel
-
blockingStub
protected TestServiceGrpc.TestServiceBlockingStub blockingStub
-
asyncStub
protected TestServiceGrpc.TestServiceStub asyncStub
-
-
Method Detail
-
startServer
protected void startServer(@Nullable io.grpc.ServerBuilder<?> builder)
-
setUp
public void setUp()
Must be called by the subclass setup method if overridden.
-
tearDown
public void tearDown()
Clean up.
-
createChannel
protected io.grpc.ManagedChannel createChannel()
-
createChannelBuilder
protected abstract io.grpc.ManagedChannelBuilder<?> createChannelBuilder()
-
getAdditionalInterceptors
@Nullable protected io.grpc.ClientInterceptor[] getAdditionalInterceptors()
-
getServerBuilder
@Nullable protected io.grpc.ServerBuilder<?> getServerBuilder()
Returns the server builder used to create server for each test run. Returnnullif it shouldn't start a server in the same process.
-
getHandshakerServerBuilder
@Nullable protected io.grpc.ServerBuilder<?> getHandshakerServerBuilder()
-
createCensusStatsClientInterceptor
protected final io.grpc.ClientInterceptor createCensusStatsClientInterceptor()
-
createCustomCensusTracerFactory
protected final io.grpc.ServerStreamTracer.Factory createCustomCensusTracerFactory()
-
customCensusModulePresent
protected boolean customCensusModulePresent()
Override this when custom census module presence is different frommetricsExpected().
-
metricsExpected
protected boolean metricsExpected()
Return true if exact metric values should be checked.
-
emptyUnary
public void emptyUnary() throws java.lang.Exception- Throws:
java.lang.Exception
-
emptyUnaryWithRetriableStream
public void emptyUnaryWithRetriableStream() throws java.lang.Exception- Throws:
java.lang.Exception
-
cacheableUnary
public void cacheableUnary()
Sends a cacheable unary rpc using GET. Requires that the server is behind a caching proxy.
-
largeUnary
public void largeUnary() throws java.lang.Exception- Throws:
java.lang.Exception
-
clientCompressedUnary
public void clientCompressedUnary(boolean probe) throws java.lang.ExceptionTests client per-message compression for unary calls. The Java API does not support inspecting a message's compression level, so this is primarily intended to run against a gRPC C++ server.- Throws:
java.lang.Exception
-
serverCompressedUnary
public void serverCompressedUnary() throws java.lang.ExceptionTests if the server can send a compressed unary response. Ideally we would assert that the responses have the requested compression, but this is not supported by the API. Given a compliant server, this test will exercise the code path for receiving a compressed response but cannot itself verify that the response was compressed.- Throws:
java.lang.Exception
-
pickFirstUnary
public void pickFirstUnary() throws java.lang.ExceptionAssuming "pick_first" policy is used, tests that all requests are sent to the same server.- Throws:
java.lang.Exception
-
serverStreaming
public void serverStreaming() throws java.lang.Exception- Throws:
java.lang.Exception
-
clientStreaming
public void clientStreaming() throws java.lang.Exception- Throws:
java.lang.Exception
-
clientCompressedStreaming
public void clientCompressedStreaming(boolean probe) throws java.lang.ExceptionTests client per-message compression for streaming calls. The Java API does not support inspecting a message's compression level, so this is primarily intended to run against a gRPC C++ server.- Throws:
java.lang.Exception
-
serverCompressedStreaming
public void serverCompressedStreaming() throws java.lang.ExceptionTests server per-message compression in a streaming response. Ideally we would assert that the responses have the requested compression, but this is not supported by the API. Given a compliant server, this test will exercise the code path for receiving a compressed response but cannot itself verify that the response was compressed.- Throws:
java.lang.Exception
-
pingPong
public void pingPong() throws java.lang.Exception- Throws:
java.lang.Exception
-
emptyStream
public void emptyStream() throws java.lang.Exception- Throws:
java.lang.Exception
-
cancelAfterBegin
public void cancelAfterBegin() throws java.lang.Exception- Throws:
java.lang.Exception
-
cancelAfterFirstResponse
public void cancelAfterFirstResponse() throws java.lang.Exception- Throws:
java.lang.Exception
-
fullDuplexCallShouldSucceed
public void fullDuplexCallShouldSucceed() throws java.lang.Exception- Throws:
java.lang.Exception
-
halfDuplexCallShouldSucceed
public void halfDuplexCallShouldSucceed() throws java.lang.Exception- Throws:
java.lang.Exception
-
serverStreamingShouldBeFlowControlled
public void serverStreamingShouldBeFlowControlled() throws java.lang.Exception- Throws:
java.lang.Exception
-
veryLargeRequest
public void veryLargeRequest() throws java.lang.Exception- Throws:
java.lang.Exception
-
veryLargeResponse
public void veryLargeResponse() throws java.lang.Exception- Throws:
java.lang.Exception
-
exchangeMetadataUnaryCall
public void exchangeMetadataUnaryCall() throws java.lang.Exception- Throws:
java.lang.Exception
-
exchangeMetadataStreamingCall
public void exchangeMetadataStreamingCall() throws java.lang.Exception- Throws:
java.lang.Exception
-
sendsTimeoutHeader
public void sendsTimeoutHeader()
-
deadlineNotExceeded
public void deadlineNotExceeded()
-
deadlineExceeded
public void deadlineExceeded() throws java.lang.Exception- Throws:
java.lang.Exception
-
deadlineExceededServerStreaming
public void deadlineExceededServerStreaming() throws java.lang.Exception- Throws:
java.lang.Exception
-
deadlineInPast
public void deadlineInPast() throws java.lang.Exception- Throws:
java.lang.Exception
-
maxInboundSize_exact
public void maxInboundSize_exact()
-
maxInboundSize_tooBig
public void maxInboundSize_tooBig()
-
maxOutboundSize_exact
public void maxOutboundSize_exact()
-
maxOutboundSize_tooBig
public void maxOutboundSize_tooBig()
-
unaryPayloadLength
protected int unaryPayloadLength()
-
gracefulShutdown
public void gracefulShutdown() throws java.lang.Exception- Throws:
java.lang.Exception
-
customMetadata
public void customMetadata() throws java.lang.Exception- Throws:
java.lang.Exception
-
censusContextsPropagated
public void censusContextsPropagated()
-
statusCodeAndMessage
public void statusCodeAndMessage() throws java.lang.Exception- Throws:
java.lang.Exception
-
specialStatusMessage
public void specialStatusMessage() throws java.lang.Exception- Throws:
java.lang.Exception
-
unimplementedMethod
public void unimplementedMethod()
Sends an rpc to an unimplemented method within TestService.
-
unimplementedService
public void unimplementedService()
Sends an rpc to an unimplemented service on the server.
-
timeoutOnSleepingServer
public void timeoutOnSleepingServer() throws java.lang.ExceptionStart a fullDuplexCall which the server will not respond, and verify the deadline expires.- Throws:
java.lang.Exception
-
getServerAddressAndLocalAddressFromClient
public void getServerAddressAndLocalAddressFromClient()
Verifies remote server address and local client address are available from ClientCall Attributes via ClientInterceptor.
-
testOrcaPerRpc
public void testOrcaPerRpc() throws java.lang.ExceptionTest backend metrics per query reporting: expect the test client LB policy to receive load reports.- Throws:
java.lang.Exception
-
testOrcaOob
public void testOrcaOob() throws java.lang.ExceptionTest backend metrics OOB reporting: expect the test client LB policy to receive load reports.- Throws:
java.lang.Exception
-
serviceAccountCreds
public void serviceAccountCreds(java.lang.String jsonKey, java.io.InputStream credentialsStream, java.lang.String authScope) throws java.lang.ExceptionSends a large unary rpc with service account credentials.- Throws:
java.lang.Exception
-
computeEngineCreds
public void computeEngineCreds(java.lang.String serviceAccount, java.lang.String oauthScope) throws java.lang.ExceptionSends a large unary rpc with compute engine credentials.- Throws:
java.lang.Exception
-
computeEngineChannelCredentials
public void computeEngineChannelCredentials(java.lang.String defaultServiceAccount, TestServiceGrpc.TestServiceBlockingStub computeEngineStub) throws java.lang.ExceptionSends an unary rpc with ComputeEngineChannelBuilder.- Throws:
java.lang.Exception
-
jwtTokenCreds
public void jwtTokenCreds(java.io.InputStream serviceAccountJson) throws java.lang.ExceptionTest JWT-based auth.- Throws:
java.lang.Exception
-
oauth2AuthToken
public void oauth2AuthToken(java.lang.String jsonKey, java.io.InputStream credentialsStream, java.lang.String authScope) throws java.lang.ExceptionSends a unary rpc with raw oauth2 access token credentials.- Throws:
java.lang.Exception
-
perRpcCreds
public void perRpcCreds(java.lang.String jsonKey, java.io.InputStream credentialsStream, java.lang.String oauthScope) throws java.lang.ExceptionSends a unary rpc with "per rpc" raw oauth2 access token credentials.- Throws:
java.lang.Exception
-
googleDefaultCredentials
public void googleDefaultCredentials(java.lang.String defaultServiceAccount, TestServiceGrpc.TestServiceBlockingStub googleDefaultStub) throws java.lang.ExceptionSends an unary rpc with "google default credentials".- Throws:
java.lang.Exception
-
performSoakTest
public void performSoakTest(java.lang.String serverUri, boolean resetChannelPerIteration, int soakIterations, int maxFailures, int maxAcceptablePerIterationLatencyMs, int minTimeMsBetweenRpcs, int overallTimeoutSeconds) throws java.lang.ExceptionRuns large unary RPCs in a loop with configurable failure thresholds and channel creation behavior.- Throws:
java.lang.Exception
-
assertSuccess
protected static void assertSuccess(io.grpc.internal.testing.StreamRecorder<?> recorder)
-
obtainRemoteClientAddr
protected java.net.SocketAddress obtainRemoteClientAddr()
Helper for getting remote address fromServerCall.getAttributes().
-
obtainRemoteServerAddr
protected java.net.SocketAddress obtainRemoteServerAddr()
Helper for getting remote address fromClientCall.getAttributes().
-
obtainLocalServerAddr
protected java.net.SocketAddress obtainLocalServerAddr()
Helper for getting local address fromServerCall.getAttributes().
-
obtainLocalClientAddr
protected java.net.SocketAddress obtainLocalClientAddr()
Helper for getting local address fromClientCall.getAttributes().
-
assertX500SubjectDn
protected void assertX500SubjectDn(java.lang.String tlsInfo)
Helper for asserting TLS info in SSLSessionServerCall.getAttributes().
-
operationTimeoutMillis
protected int operationTimeoutMillis()
-
assumeEnoughMemory
protected static void assumeEnoughMemory()
Some tests run on memory constrained environments. Rather than OOM, just give up. 64 is chosen as a maximum amount of memory a large test would need.
-
-