Search in sources :

Example 11 with InternalException

use of com.google.api.gax.rpc.InternalException in project java-bigquerystorage by googleapis.

the class BigQueryReadClientTest method readRowsRetryingEOSExceptionTest.

@Test
@SuppressWarnings("all")
public void readRowsRetryingEOSExceptionTest() throws ExecutionException, InterruptedException {
    ApiException exception = new InternalException(new StatusRuntimeException(Status.INTERNAL.withDescription("Received unexpected EOS on DATA frame from server")), GrpcStatusCode.of(Code.INTERNAL), /* retryable = */
    false);
    mockBigQueryRead.addException(exception);
    long rowCount = 1340416618L;
    ReadRowsResponse expectedResponse = ReadRowsResponse.newBuilder().setRowCount(rowCount).build();
    mockBigQueryRead.addResponse(expectedResponse);
    ReadRowsRequest request = ReadRowsRequest.newBuilder().build();
    MockStreamObserver<ReadRowsResponse> responseObserver = new MockStreamObserver<>();
    ServerStreamingCallable<ReadRowsRequest, ReadRowsResponse> callable = client.readRowsCallable();
    callable.serverStreamingCall(request, responseObserver);
    List<ReadRowsResponse> actualResponses = responseObserver.future().get();
    Assert.assertEquals(1, actualResponses.size());
    Assert.assertEquals(retryCount, 1);
    Assert.assertEquals(lastRetryStatusCode, Code.INTERNAL);
}
Also used : StatusRuntimeException(io.grpc.StatusRuntimeException) MockStreamObserver(com.google.api.gax.grpc.testing.MockStreamObserver) ApiException(com.google.api.gax.rpc.ApiException) InternalException(com.google.api.gax.rpc.InternalException) Test(org.junit.Test)

Example 12 with InternalException

use of com.google.api.gax.rpc.InternalException in project java-bigquerystorage by googleapis.

the class BigQueryReadClientTest method readRowsRetryingHttp2StreamRstTest.

@Test
@SuppressWarnings("all")
public void readRowsRetryingHttp2StreamRstTest() throws ExecutionException, InterruptedException {
    ApiException exception = new InternalException(new StatusRuntimeException(Status.INTERNAL.withDescription("HTTP/2 error code: INTERNAL_ERROR\nReceived Rst Stream")), GrpcStatusCode.of(Code.INTERNAL), /* retryable = */
    false);
    mockBigQueryRead.addException(exception);
    long rowCount = 1340416618L;
    ReadRowsResponse expectedResponse = ReadRowsResponse.newBuilder().setRowCount(rowCount).build();
    mockBigQueryRead.addResponse(expectedResponse);
    ReadRowsRequest request = ReadRowsRequest.newBuilder().build();
    MockStreamObserver<ReadRowsResponse> responseObserver = new MockStreamObserver<>();
    ServerStreamingCallable<ReadRowsRequest, ReadRowsResponse> callable = client.readRowsCallable();
    callable.serverStreamingCall(request, responseObserver);
    List<ReadRowsResponse> actualResponses = responseObserver.future().get();
    Assert.assertEquals(1, actualResponses.size());
    Assert.assertEquals(retryCount, 1);
    Assert.assertEquals(lastRetryStatusCode, Code.INTERNAL);
}
Also used : StatusRuntimeException(io.grpc.StatusRuntimeException) MockStreamObserver(com.google.api.gax.grpc.testing.MockStreamObserver) ApiException(com.google.api.gax.rpc.ApiException) InternalException(com.google.api.gax.rpc.InternalException) Test(org.junit.Test)

Example 13 with InternalException

use of com.google.api.gax.rpc.InternalException in project java-bigquerystorage by googleapis.

the class BigQueryStorageClientTest method readRowsRetryingEOSExceptionTest.

@Test
@SuppressWarnings("all")
public void readRowsRetryingEOSExceptionTest() throws ExecutionException, InterruptedException {
    ApiException exception = new InternalException(new StatusRuntimeException(Status.INTERNAL.withDescription("Received unexpected EOS on DATA frame from server")), GrpcStatusCode.of(Code.INTERNAL), /* retryable = */
    false);
    mockBigQueryStorage.addException(exception);
    long rowCount = 1340416618L;
    ReadRowsResponse expectedResponse = ReadRowsResponse.newBuilder().setRowCount(rowCount).build();
    mockBigQueryStorage.addResponse(expectedResponse);
    ReadRowsRequest request = ReadRowsRequest.newBuilder().build();
    MockStreamObserver<ReadRowsResponse> responseObserver = new MockStreamObserver<>();
    ServerStreamingCallable<ReadRowsRequest, ReadRowsResponse> callable = client.readRowsCallable();
    callable.serverStreamingCall(request, responseObserver);
    List<ReadRowsResponse> actualResponses = responseObserver.future().get();
    Assert.assertEquals(1, actualResponses.size());
    Assert.assertEquals(retryCount, 1);
    Assert.assertEquals(lastRetryStatusCode, Code.INTERNAL);
}
Also used : ReadRowsResponse(com.google.cloud.bigquery.storage.v1beta1.Storage.ReadRowsResponse) StatusRuntimeException(io.grpc.StatusRuntimeException) ReadRowsRequest(com.google.cloud.bigquery.storage.v1beta1.Storage.ReadRowsRequest) MockStreamObserver(com.google.api.gax.grpc.testing.MockStreamObserver) ApiException(com.google.api.gax.rpc.ApiException) InternalException(com.google.api.gax.rpc.InternalException) Test(org.junit.Test)

Example 14 with InternalException

use of com.google.api.gax.rpc.InternalException in project java-bigquerystorage by googleapis.

the class BigQueryStorageClientTest method readRowsRetryingHttp2StreamRstTest.

@Test
@SuppressWarnings("all")
public void readRowsRetryingHttp2StreamRstTest() throws ExecutionException, InterruptedException {
    ApiException exception = new InternalException(new StatusRuntimeException(Status.INTERNAL.withDescription("HTTP/2 error code: INTERNAL_ERROR\nReceived Rst Stream")), GrpcStatusCode.of(Code.INTERNAL), /* retryable = */
    false);
    mockBigQueryStorage.addException(exception);
    long rowCount = 1340416618L;
    ReadRowsResponse expectedResponse = ReadRowsResponse.newBuilder().setRowCount(rowCount).build();
    mockBigQueryStorage.addResponse(expectedResponse);
    ReadRowsRequest request = ReadRowsRequest.newBuilder().build();
    MockStreamObserver<ReadRowsResponse> responseObserver = new MockStreamObserver<>();
    ServerStreamingCallable<ReadRowsRequest, ReadRowsResponse> callable = client.readRowsCallable();
    callable.serverStreamingCall(request, responseObserver);
    List<ReadRowsResponse> actualResponses = responseObserver.future().get();
    Assert.assertEquals(1, actualResponses.size());
    Assert.assertEquals(retryCount, 1);
    Assert.assertEquals(lastRetryStatusCode, Code.INTERNAL);
}
Also used : ReadRowsResponse(com.google.cloud.bigquery.storage.v1beta1.Storage.ReadRowsResponse) StatusRuntimeException(io.grpc.StatusRuntimeException) ReadRowsRequest(com.google.cloud.bigquery.storage.v1beta1.Storage.ReadRowsRequest) MockStreamObserver(com.google.api.gax.grpc.testing.MockStreamObserver) ApiException(com.google.api.gax.rpc.ApiException) InternalException(com.google.api.gax.rpc.InternalException) Test(org.junit.Test)

Example 15 with InternalException

use of com.google.api.gax.rpc.InternalException in project java-bigquerystorage by googleapis.

the class BigQueryReadClientTest method readRowsRetryingEOSExceptionTest.

@Test
@SuppressWarnings("all")
public void readRowsRetryingEOSExceptionTest() throws ExecutionException, InterruptedException {
    ApiException exception = new InternalException(new StatusRuntimeException(Status.INTERNAL.withDescription("Received unexpected EOS on DATA frame from server")), GrpcStatusCode.of(Code.INTERNAL), /* retryable = */
    false);
    mockBigQueryRead.addException(exception);
    long rowCount = 1340416618L;
    ReadRowsResponse expectedResponse = ReadRowsResponse.newBuilder().setRowCount(rowCount).build();
    mockBigQueryRead.addResponse(expectedResponse);
    ReadRowsRequest request = ReadRowsRequest.newBuilder().build();
    MockStreamObserver<ReadRowsResponse> responseObserver = new MockStreamObserver<>();
    ServerStreamingCallable<ReadRowsRequest, ReadRowsResponse> callable = client.readRowsCallable();
    callable.serverStreamingCall(request, responseObserver);
    List<ReadRowsResponse> actualResponses = responseObserver.future().get();
    Assert.assertEquals(1, actualResponses.size());
    Assert.assertEquals(retryCount, 1);
    Assert.assertEquals(lastRetryStatusCode, Code.INTERNAL);
}
Also used : StatusRuntimeException(io.grpc.StatusRuntimeException) MockStreamObserver(com.google.api.gax.grpc.testing.MockStreamObserver) ApiException(com.google.api.gax.rpc.ApiException) InternalException(com.google.api.gax.rpc.InternalException) Test(org.junit.Test)

Aggregations

InternalException (com.google.api.gax.rpc.InternalException)16 Test (org.junit.Test)15 ApiException (com.google.api.gax.rpc.ApiException)7 StatusRuntimeException (io.grpc.StatusRuntimeException)7 MockStreamObserver (com.google.api.gax.grpc.testing.MockStreamObserver)6 PartialResultSet (com.google.spanner.v1.PartialResultSet)3 Duration (org.threeten.bp.Duration)3 ReadRowsRequest (com.google.cloud.bigquery.storage.v1beta1.Storage.ReadRowsRequest)2 ReadRowsResponse (com.google.cloud.bigquery.storage.v1beta1.Storage.ReadRowsResponse)2 ByteString (com.google.protobuf.ByteString)2 BeginTransactionRequest (com.google.spanner.v1.BeginTransactionRequest)2 AbortedException (com.google.api.gax.rpc.AbortedException)1 DeadlineExceededException (com.google.api.gax.rpc.DeadlineExceededException)1 UnavailableException (com.google.api.gax.rpc.UnavailableException)1 BaseServiceException (com.google.cloud.BaseServiceException)1 Stopwatch (com.google.common.base.Stopwatch)1 ExecuteSqlRequest (com.google.spanner.v1.ExecuteSqlRequest)1 RequestOptions (com.google.spanner.v1.RequestOptions)1 ResultSetStats (com.google.spanner.v1.ResultSetStats)1 TransactionOptions (com.google.spanner.v1.TransactionOptions)1