Repository: geode Updated Branches: refs/heads/develop 3b90f9f9b -> 03503ce7e
GEODE-3015: Fix a flaky test by adding wait. Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/03503ce7 Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/03503ce7 Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/03503ce7 Branch: refs/heads/develop Commit: 03503ce7eb81ff67906a6d8626e9fa2e5c8a716b Parents: 3b90f9f Author: eshu <e...@pivotal.io> Authored: Mon Jul 10 09:17:53 2017 -0700 Committer: eshu <e...@pivotal.io> Committed: Mon Jul 10 09:17:53 2017 -0700 ---------------------------------------------------------------------- .../cache/ClientServerTransactionDUnitTest.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/03503ce7/geode-core/src/test/java/org/apache/geode/internal/cache/ClientServerTransactionDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/ClientServerTransactionDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/ClientServerTransactionDUnitTest.java index ec4e179..96b89b9 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/ClientServerTransactionDUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/ClientServerTransactionDUnitTest.java @@ -39,6 +39,7 @@ import javax.transaction.RollbackException; import javax.transaction.Synchronization; import javax.transaction.UserTransaction; +import org.assertj.core.api.Assertions; import org.awaitility.Awaitility; import static org.apache.geode.distributed.ConfigurationProperties.*; @@ -3988,8 +3989,16 @@ public class ClientServerTransactionDUnitTest extends RemoteTransactionDUnitTest private void verifyTXStateEmpty(DistributedMember clientId) { TXManagerImpl txmgr = getGemfireCache().getTxManager(); - Set<TXId> states = txmgr.getTransactionsForClient((InternalDistributedMember) clientId); - assertEquals(0, states.size()); // both transactions should be rolled back. + // both transactions should be rolled back. + // Server sends reply with CommitMessage back to client before removing the TXState from its + // hostedTXStates map. Client finishes the JTA once it gets the reply from server. + // There exists a race that TXState is yet to be removed when client JTA tx is finished. + // Add the wait before checking the TXState. + Awaitility.await().pollInterval(10, TimeUnit.MILLISECONDS).pollDelay(10, TimeUnit.MILLISECONDS) + .atMost(30, TimeUnit.SECONDS) + .until(() -> Assertions + .assertThat(txmgr.getTransactionsForClient((InternalDistributedMember) clientId).size()) + .isEqualTo(0)); } private SerializableCallable getClientDM() {