Search in sources :

Example 26 with CompatClient

use of io.servicetalk.grpc.netty.CompatProto.Compat.CompatClient in project servicetalk by apple.

the class ProtocolCompatibilityTest method serviceTalkToServiceTalkCompressionError.

@ParameterizedTest
@MethodSource("sslAndStreamingParams")
void serviceTalkToServiceTalkCompressionError(final boolean ssl, final boolean streaming) throws Exception {
    final String clientCompression = "gzip";
    final TestServerContext server = serviceTalkServer(ErrorMode.NONE, ssl, null, null);
    final CompatClient client = serviceTalkClient(server.listenAddress(), ssl, clientCompression, null);
    testGrpcError(client, server, false, streaming, clientCompression, GrpcStatusCode.UNIMPLEMENTED, null);
}
Also used : BlockingCompatClient(io.servicetalk.grpc.netty.CompatProto.Compat.BlockingCompatClient) CompatClient(io.servicetalk.grpc.netty.CompatProto.Compat.CompatClient) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 27 with CompatClient

use of io.servicetalk.grpc.netty.CompatProto.Compat.CompatClient in project servicetalk by apple.

the class ProtocolCompatibilityTest method serviceTalkToServiceTalkErrorViaServerFilter.

@ParameterizedTest
@MethodSource("sslStreamingAndCompressionParams")
void serviceTalkToServiceTalkErrorViaServerFilter(final boolean ssl, final boolean streaming, final String compression) throws Exception {
    final TestServerContext server = serviceTalkServer(ErrorMode.SIMPLE_IN_SERVER_FILTER, ssl, compression, null);
    final CompatClient client = serviceTalkClient(server.listenAddress(), ssl, compression, null);
    testGrpcError(client, server, false, streaming, compression);
}
Also used : BlockingCompatClient(io.servicetalk.grpc.netty.CompatProto.Compat.BlockingCompatClient) CompatClient(io.servicetalk.grpc.netty.CompatProto.Compat.CompatClient) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 28 with CompatClient

use of io.servicetalk.grpc.netty.CompatProto.Compat.CompatClient in project servicetalk by apple.

the class ProtocolCompatibilityTest method timeoutMidRequest.

@ParameterizedTest
@CsvSource({ "false,false,false", "false,false,true", "false,true,false", "false,true,true", "true,false,false", "true,false,true", "true,true,false", "true,true,true" })
void timeoutMidRequest(boolean stClient, boolean stServer, boolean clientInitiatedTimeout) throws Exception {
    Duration clientTimeout = clientInitiatedTimeout ? DEFAULT_DEADLINE : null;
    Duration serverTimeout = clientInitiatedTimeout ? null : DEFAULT_DEADLINE;
    BlockingQueue<Throwable> serverErrorQueue = new ArrayBlockingQueue<>(16);
    final TestServerContext server = stServer ? serviceTalkServer(ErrorMode.NONE, false, offloadNever(), null, null, serverErrorQueue) : grpcJavaServer(ErrorMode.NONE, false, null);
    try (ServerContext proxyCtx = buildTimeoutProxy(server.listenAddress(), serverTimeout, false)) {
        final CompatClient client = stClient ? serviceTalkClient(proxyCtx.listenAddress(), false, null, clientTimeout) : grpcJavaClient(proxyCtx.listenAddress(), null, false, clientTimeout);
        try {
            PublisherSource.Processor<CompatRequest, CompatRequest> reqPub = newPublisherProcessor();
            reqPub.onNext(CompatRequest.newBuilder().setId(3).build());
            validateGrpcErrorInResponse(client.bidirectionalStreamingCall(fromSource(reqPub)).toFuture(), false, clientInitiatedTimeout ? DEADLINE_EXCEEDED : CANCELLED, null);
            // It is possible that the timeout on the client occurred before writing the request, in which case the
            // server will never request the request, and therefore no error is expected.
            Throwable cause = serverErrorQueue.poll(DEFAULT_DEADLINE.toNanos() * 2, NANOSECONDS);
            if (cause != null) {
                assertThat(cause, is(SERVER_PROCESSED_TOKEN));
                cause = serverErrorQueue.take();
                assertThat(cause, instanceOf(IOException.class));
            }
        } finally {
            closeAll(server, client);
        }
    }
}
Also used : ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) ServerContext(io.servicetalk.transport.api.ServerContext) PublisherSource(io.servicetalk.concurrent.PublisherSource) BlockingCompatClient(io.servicetalk.grpc.netty.CompatProto.Compat.BlockingCompatClient) CompatClient(io.servicetalk.grpc.netty.CompatProto.Compat.CompatClient) Duration(java.time.Duration) IOException(java.io.IOException) CompatRequest(io.servicetalk.grpc.netty.CompatProto.RequestContainer.CompatRequest) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 29 with CompatClient

use of io.servicetalk.grpc.netty.CompatProto.Compat.CompatClient in project servicetalk by apple.

the class ProtocolCompatibilityTest method grpcJavaToServiceTalkCompressionError.

@ParameterizedTest
@MethodSource("sslAndStreamingParams")
void grpcJavaToServiceTalkCompressionError(final boolean ssl, final boolean streaming) throws Exception {
    final String clientCompression = "gzip";
    final TestServerContext server = serviceTalkServer(ErrorMode.NONE, ssl, null, null);
    final CompatClient client = grpcJavaClient(server.listenAddress(), clientCompression, ssl, null);
    testGrpcError(client, server, false, streaming, clientCompression, GrpcStatusCode.UNIMPLEMENTED, null);
}
Also used : BlockingCompatClient(io.servicetalk.grpc.netty.CompatProto.Compat.BlockingCompatClient) CompatClient(io.servicetalk.grpc.netty.CompatProto.Compat.CompatClient) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 30 with CompatClient

use of io.servicetalk.grpc.netty.CompatProto.Compat.CompatClient in project servicetalk by apple.

the class ProtocolCompatibilityTest method grpcJavaToGrpcJavaClientTimeout.

@ParameterizedTest
@MethodSource("sslStreamingAndCompressionParams")
void grpcJavaToGrpcJavaClientTimeout(final boolean ssl, final boolean streaming, final String compression) throws Exception {
    final TestServerContext server = grpcJavaServer(ErrorMode.NONE, ssl, compression);
    try (ServerContext proxyCtx = buildTimeoutProxy(server.listenAddress(), null, ssl)) {
        final CompatClient client = grpcJavaClient(proxyCtx.listenAddress(), compression, ssl, DEFAULT_DEADLINE);
        testGrpcError(client, server, false, streaming, compression, DEADLINE_EXCEEDED, null);
    }
}
Also used : ServerContext(io.servicetalk.transport.api.ServerContext) BlockingCompatClient(io.servicetalk.grpc.netty.CompatProto.Compat.BlockingCompatClient) CompatClient(io.servicetalk.grpc.netty.CompatProto.Compat.CompatClient) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

BlockingCompatClient (io.servicetalk.grpc.netty.CompatProto.Compat.BlockingCompatClient)35 CompatClient (io.servicetalk.grpc.netty.CompatProto.Compat.CompatClient)35 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)34 MethodSource (org.junit.jupiter.params.provider.MethodSource)33 ServerContext (io.servicetalk.transport.api.ServerContext)5 PublisherSource (io.servicetalk.concurrent.PublisherSource)2 CompatRequest (io.servicetalk.grpc.netty.CompatProto.RequestContainer.CompatRequest)2 ManagedChannel (io.grpc.ManagedChannel)1 NettyChannelBuilder (io.grpc.netty.NettyChannelBuilder)1 StreamObserver (io.grpc.stub.StreamObserver)1 SslContext (io.netty.handler.ssl.SslContext)1 Processor (io.servicetalk.concurrent.SingleSource.Processor)1 Processors.newPublisherProcessor (io.servicetalk.concurrent.api.Processors.newPublisherProcessor)1 Processors.newSingleProcessor (io.servicetalk.concurrent.api.Processors.newSingleProcessor)1 Publisher (io.servicetalk.concurrent.api.Publisher)1 Single (io.servicetalk.concurrent.api.Single)1 DefaultGrpcClientMetadata (io.servicetalk.grpc.api.DefaultGrpcClientMetadata)1 GrpcClientMetadata (io.servicetalk.grpc.api.GrpcClientMetadata)1 BidirectionalStreamingCallMetadata (io.servicetalk.grpc.netty.CompatProto.Compat.BidirectionalStreamingCallMetadata)1 ClientStreamingCallMetadata (io.servicetalk.grpc.netty.CompatProto.Compat.ClientStreamingCallMetadata)1