Class AbstractInteropTest


  • public abstract class AbstractInteropTest
    extends java.lang.Object
    Abstract base class for all GRPC transport tests.

    New tests should avoid using Mockito to support running on AppEngine.

    • Constructor Detail

      • AbstractInteropTest

        protected AbstractInteropTest()
        Constructor for tests.
    • 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. Return null if 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 from metricsExpected().
      • 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.Exception
        Tests 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.Exception
        Tests 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.Exception
        Assuming "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.Exception
        Tests 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.Exception
        Tests 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.Exception
        Start 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.Exception
        Test 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.Exception
        Test 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.Exception
        Sends 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.Exception
        Sends 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.Exception
        Sends an unary rpc with ComputeEngineChannelBuilder.
        Throws:
        java.lang.Exception
      • jwtTokenCreds

        public void jwtTokenCreds​(java.io.InputStream serviceAccountJson)
                           throws java.lang.Exception
        Test 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.Exception
        Sends 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.Exception
        Sends 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.Exception
        Sends 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.Exception
        Runs 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 from ServerCall.getAttributes().
      • obtainRemoteServerAddr

        protected java.net.SocketAddress obtainRemoteServerAddr()
        Helper for getting remote address from ClientCall.getAttributes().
      • obtainLocalServerAddr

        protected java.net.SocketAddress obtainLocalServerAddr()
        Helper for getting local address from ServerCall.getAttributes().
      • obtainLocalClientAddr

        protected java.net.SocketAddress obtainLocalClientAddr()
        Helper for getting local address from ClientCall.getAttributes().
      • assertX500SubjectDn

        protected void assertX500SubjectDn​(java.lang.String tlsInfo)
        Helper for asserting TLS info in SSLSession ServerCall.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.