Skip to content

Commit

Permalink
test(spanner): update non-retryable error code in unit tests (#3176)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshachinta authored Jun 25, 2024
1 parent 89c09ce commit b8b5aed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void asyncRunnerUpdateAbortedWithoutGettingResult() throws Exception {
public void asyncRunnerCommitFails() throws Exception {
mockSpanner.setCommitExecutionTime(
SimulatedExecutionTime.ofException(
Status.RESOURCE_EXHAUSTED
Status.INVALID_ARGUMENT
.withDescription("mutation limit exceeded")
.asRuntimeException()));
AsyncRunner runner = client().runAsync();
Expand All @@ -245,7 +245,7 @@ public void asyncRunnerCommitFails() throws Exception {
ExecutionException e = assertThrows(ExecutionException.class, () -> updateCount.get());
assertThat(e.getCause()).isInstanceOf(SpannerException.class);
SpannerException se = (SpannerException) e.getCause();
assertThat(se.getErrorCode()).isEqualTo(ErrorCode.RESOURCE_EXHAUSTED);
assertThat(se.getErrorCode()).isEqualTo(ErrorCode.INVALID_ARGUMENT);
assertThat(se.getMessage()).contains("mutation limit exceeded");
}

Expand Down Expand Up @@ -432,7 +432,7 @@ public void asyncRunnerBatchUpdateAbortedWithoutGettingResult() throws Exception
public void asyncRunnerWithBatchUpdateCommitFails() throws Exception {
mockSpanner.setCommitExecutionTime(
SimulatedExecutionTime.ofException(
Status.RESOURCE_EXHAUSTED
Status.INVALID_ARGUMENT
.withDescription("mutation limit exceeded")
.asRuntimeException()));
AsyncRunner runner = client().runAsync();
Expand All @@ -448,7 +448,7 @@ public void asyncRunnerWithBatchUpdateCommitFails() throws Exception {
ExecutionException e = assertThrows(ExecutionException.class, () -> updateCount.get());
assertThat(e.getCause()).isInstanceOf(SpannerException.class);
SpannerException se = (SpannerException) e.getCause();
assertThat(se.getErrorCode()).isEqualTo(ErrorCode.RESOURCE_EXHAUSTED);
assertThat(se.getErrorCode()).isEqualTo(ErrorCode.INVALID_ARGUMENT);
assertThat(se.getMessage()).contains("mutation limit exceeded");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ public void asyncTransactionManagerUpdateAbortedWithoutGettingResult() throws Ex
public void asyncTransactionManagerCommitFails() throws Exception {
mockSpanner.setCommitExecutionTime(
SimulatedExecutionTime.ofException(
Status.RESOURCE_EXHAUSTED
Status.INVALID_ARGUMENT
.withDescription("mutation limit exceeded")
.asRuntimeException()));
try (AsyncTransactionManager mgr = client().transactionManagerAsync()) {
Expand All @@ -545,7 +545,7 @@ public void asyncTransactionManagerCommitFails() throws Exception {
AsyncTransactionManagerHelper.executeUpdateAsync(UPDATE_STATEMENT),
executor)
.commitAsync()));
assertThat(e.getErrorCode()).isEqualTo(ErrorCode.RESOURCE_EXHAUSTED);
assertThat(e.getErrorCode()).isEqualTo(ErrorCode.INVALID_ARGUMENT);
assertThat(e.getMessage()).contains("mutation limit exceeded");
}
}
Expand Down Expand Up @@ -928,7 +928,7 @@ public void asyncTransactionManagerBatchUpdateAbortedWithoutGettingResult() thro
public void asyncTransactionManagerWithBatchUpdateCommitFails() throws Exception {
mockSpanner.setCommitExecutionTime(
SimulatedExecutionTime.ofException(
Status.RESOURCE_EXHAUSTED
Status.INVALID_ARGUMENT
.withDescription("mutation limit exceeded")
.asRuntimeException()));
try (AsyncTransactionManager manager = clientWithEmptySessionPool().transactionManagerAsync()) {
Expand All @@ -945,7 +945,7 @@ public void asyncTransactionManagerWithBatchUpdateCommitFails() throws Exception
ImmutableList.of(UPDATE_STATEMENT, UPDATE_STATEMENT)),
executor)
.commitAsync()));
assertThat(e.getErrorCode()).isEqualTo(ErrorCode.RESOURCE_EXHAUSTED);
assertThat(e.getErrorCode()).isEqualTo(ErrorCode.INVALID_ARGUMENT);
assertThat(e.getMessage()).contains("mutation limit exceeded");
}
if (isMultiplexedSessionsEnabled()) {
Expand Down

0 comments on commit b8b5aed

Please sign in to comment.