Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void testCreateSessionDeadlineExceededWithNoSessionCreateWaitTime() throw
// Simulate a problem with the CreateSession RPC making it slow.
mockSpanner.setCreateSessionExecutionTime(
SimulatedExecutionTime.ofException(Status.DEADLINE_EXCEEDED.asRuntimeException()));
mockSpanner.freezeAfter(1);
mockSpanner.freeze();

Spanner testSpanner =
SpannerOptions.newBuilder()
Expand All @@ -119,17 +119,22 @@ public void testCreateSessionDeadlineExceededWithNoSessionCreateWaitTime() throw
DatabaseClientImpl client =
(DatabaseClientImpl) testSpanner.getDatabaseClient(DatabaseId.of("p", "i", "d"));

// The first attempt should lead to a DEADLINE_EXCEEDED error being propagated from the
// CreateSession attempt.
try (ResultSet resultSet = client.singleUse().executeQuery(STATEMENT)) {
SpannerException exception = assertThrows(SpannerException.class, resultSet::next);
assertEquals(ErrorCode.DEADLINE_EXCEEDED, exception.getErrorCode());
// Wait until the initial CreateSession request has reached the mock server and is frozen.
mockSpanner.waitForRequestsToContain(CreateSessionRequest.class, 5000);

// Acquire the transaction while the initial CreateSession request is in progress.
// This guarantees that this transaction binds to the initial (failing) attempt.
try (ReadContext readContext = client.singleUse()) {
// The first attempt should lead to a DEADLINE_EXCEEDED error being propagated from the
// CreateSession attempt.
try (ResultSet resultSet = readContext.executeQuery(STATEMENT)) {
mockSpanner.unfreeze();
SpannerException exception = assertThrows(SpannerException.class, resultSet::next);
assertEquals(ErrorCode.DEADLINE_EXCEEDED, exception.getErrorCode());
}
}
Comment thread
sakthivelmanii marked this conversation as resolved.

// The next attempt should then succeed.
mockSpanner.unfreeze();
assertNotNull(client.multiplexedSessionDatabaseClient.getCurrentSessionReference());

try (ResultSet resultSet = client.singleUse().executeQuery(STATEMENT)) {
//noinspection StatementWithEmptyBody
while (resultSet.next()) {}
Expand Down
Loading