From f08f20760e6d80c42c9add2207045d186f14be1c Mon Sep 17 00:00:00 2001 From: Sakthivel Subramanian Date: Tue, 28 Apr 2026 07:04:34 +0000 Subject: [PATCH] fix(spanner): fix flakiness in testCreateSessionDeadlineExceeded The test `testCreateSessionDeadlineExceeded` in `MultiplexedSessionDatabaseClientMockServerTest` was flaky because it used a non-sticky exception for simulated `DEADLINE_EXCEEDED` on `CreateSession`. This exception could be consumed by background session creation tasks before the test could verify it. This change uses `ofStickyException` to ensure the exception persists until explicitly cleared by `mockSpanner.removeAllExecutionTimes()`, making the test robust against concurrent background activity. Fixes: https://github.com/googleapis/google-cloud-java/issues/12890 --- .../spanner/MultiplexedSessionDatabaseClientMockServerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java b/java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java index 629b5611862d..61d06da821c0 100644 --- a/java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java +++ b/java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java @@ -105,7 +105,7 @@ public void createSpannerInstance() { public void testCreateSessionDeadlineExceeded() { // Simulate a problem with the CreateSession RPC making it slow. mockSpanner.setCreateSessionExecutionTime( - SimulatedExecutionTime.ofException(Status.DEADLINE_EXCEEDED.asRuntimeException())); + SimulatedExecutionTime.ofStickyException(Status.DEADLINE_EXCEEDED.asRuntimeException())); Spanner testSpanner = SpannerOptions.newBuilder()