From de7c1df78c8d49889760056d7bffb7daf740e2d0 Mon Sep 17 00:00:00 2001 From: Olav Loite Date: Thu, 23 Jan 2020 14:04:49 +0100 Subject: [PATCH] test: fix flaky integration test The ITClosedSessionTest could cause a flaky failure because it deletes sessions on the server and then repeatedly executes queries on the session until it returns a NOT_FOUND error. The actual deletion could however happen exactly at the moment that the test query was executed, which will cause Cloud Spanner to return a different error message than the standard 'Session not found' error message. Fixes #41 --- .../cloud/spanner/IntegrationTestWithClosedSessionsEnv.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestWithClosedSessionsEnv.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestWithClosedSessionsEnv.java index 66e0893be7b..07e6a08e045 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestWithClosedSessionsEnv.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestWithClosedSessionsEnv.java @@ -114,7 +114,8 @@ private void awaitDeleted(Session session) { Thread.sleep(500L); } catch (SpannerException e) { if (e.getErrorCode() == ErrorCode.NOT_FOUND - && e.getMessage().contains("Session not found")) { + && (e.getMessage().contains("Session not found") + || e.getMessage().contains("Session was concurrently deleted"))) { break; } else { throw e;