Skip to content

Commit 9af0a27

Browse files
authored
test: do not use RESOURCE_EXHAUSTED as it is retryable (#3227)
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
1 parent c46eb45 commit 9af0a27

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchCreateSessionsTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ public void testSpannerReturnsAllAvailableSessionsAndThenNoSessions()
207207
}
208208

209209
@Test
210-
public void testSpannerReturnsResourceExhausted() throws InterruptedException {
210+
public void testSpannerReturnsFailedPrecondition() throws InterruptedException {
211211
int minSessions = 100;
212212
int maxSessions = 1000;
213213
int expectedSessions;
214214
DatabaseClientImpl client;
215215
// Make the first BatchCreateSessions return an error.
216-
mockSpanner.addException(Status.RESOURCE_EXHAUSTED.asRuntimeException());
216+
mockSpanner.addException(Status.FAILED_PRECONDITION.asRuntimeException());
217217
try (Spanner spanner = createSpanner(minSessions, maxSessions)) {
218218
// Create a database client which will create a session pool.
219219
client =

‎java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockSpannerServiceImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ public void batchCreateSessions(
808808
batchCreateSessionsExecutionTime.simulateExecutionTime(
809809
exceptions, stickyGlobalExceptions, freezeLock);
810810
if (sessions.size() >= maxTotalSessions) {
811-
throw Status.RESOURCE_EXHAUSTED
811+
throw Status.FAILED_PRECONDITION
812812
.withDescription("Maximum number of sessions reached")
813813
.asRuntimeException();
814814
}

0 commit comments

Comments
 (0)