You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2019/07/31 16:37:20 UTC

[geode] branch develop updated: GEODE-7003: Fix flaky tests in GemFireTransactionDataSourceIntegrationTest

This is an automated email from the ASF dual-hosted git repository.

klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 9f0f020  GEODE-7003: Fix flaky tests in GemFireTransactionDataSourceIntegrationTest
9f0f020 is described below

commit 9f0f02041e6084fb4ef8903c08b6c8fa04329e52
Author: Aaron Lindsey <al...@pivotal.io>
AuthorDate: Wed Jul 24 14:10:25 2019 -0700

    GEODE-7003: Fix flaky tests in GemFireTransactionDataSourceIntegrationTest
    
    There is a race condition within the test. When the test calls dataSource.getConnection(), that method will throw an (expected) exception and expire the connection from the connection pool. There is a background thread which goes through all the expired connections and calls Connection.close(). If this background thread calls close() while the main thread is in the middle of calling BrokeredConnection.isClosed(), the method isClosed() can throw a SQLNonTransientConnectionException.
---
 .../GemFireTransactionDataSourceIntegrationTest.java         | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/GemFireTransactionDataSourceIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/GemFireTransactionDataSourceIntegrationTest.java
index 7a6ed14..240f740 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/GemFireTransactionDataSourceIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/GemFireTransactionDataSourceIntegrationTest.java
@@ -100,7 +100,11 @@ public class GemFireTransactionDataSourceIntegrationTest {
         .hasMessageContaining("SQL exception");
 
     // wait for activation of clean thread
-    await().untilAsserted(() -> assertThat(connection.isClosed()).isTrue());
+    await()
+        // BrokeredConnection.isClosed() throws a SQLException if the clean thread closes the
+        // connection while we are in the middle of checking whether it is closed.
+        .ignoreExceptionsInstanceOf(SQLException.class)
+        .untilAsserted(() -> assertThat(connection.isClosed()).isTrue());
 
     // Check that all connections are cleaned
     assertThat(poolCache.getActiveCacheSize()).isZero();
@@ -135,7 +139,11 @@ public class GemFireTransactionDataSourceIntegrationTest {
         .hasMessageContaining("SQL exception2");
 
     // wait for activation of clean thread
-    await().untilAsserted(() -> assertThat(connection.isClosed()).isTrue());
+    await()
+        // BrokeredConnection.isClosed() throws a SQLException if the clean thread closes the
+        // connection while we are in the middle of checking whether it is closed.
+        .ignoreExceptionsInstanceOf(SQLException.class)
+        .untilAsserted(() -> assertThat(connection.isClosed()).isTrue());
 
     // Check that all connections are cleaned
     assertThat(poolCache.getActiveCacheSize()).isZero();