Skip to content

Commit

Permalink
test: do not use RESOURCE_EXHAUSTED as it is retryable (#3227)
Browse files Browse the repository at this point in the history
The test used the error code RESOURCE_EXHAUSTED to indicate that
the server could not create any more sessions. This error code is
now retryable, causing the test to become flaky. Change the error
code to one that is not retryable.

Fixes #3224
  • Loading branch information
olavloite authored Jul 29, 2024
1 parent 9de91d7 commit c4c09dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,13 @@ public void testSpannerReturnsAllAvailableSessionsAndThenNoSessions()
}

@Test
public void testSpannerReturnsResourceExhausted() throws InterruptedException {
public void testSpannerReturnsFailedPrecondition() throws InterruptedException {
int minSessions = 100;
int maxSessions = 1000;
int expectedSessions;
DatabaseClientImpl client;
// Make the first BatchCreateSessions return an error.
mockSpanner.addException(Status.RESOURCE_EXHAUSTED.asRuntimeException());
mockSpanner.addException(Status.FAILED_PRECONDITION.asRuntimeException());
try (Spanner spanner = createSpanner(minSessions, maxSessions)) {
// Create a database client which will create a session pool.
client =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ public void batchCreateSessions(
batchCreateSessionsExecutionTime.simulateExecutionTime(
exceptions, stickyGlobalExceptions, freezeLock);
if (sessions.size() >= maxTotalSessions) {
throw Status.RESOURCE_EXHAUSTED
throw Status.FAILED_PRECONDITION
.withDescription("Maximum number of sessions reached")
.asRuntimeException();
}
Expand Down

0 comments on commit c4c09dc

Please sign in to comment.