From e12de1f4471de5ae46eb35f9dbb275403a8bf4ca Mon Sep 17 00:00:00 2001 From: Nikolay Izhikov Date: Wed, 9 Aug 2017 18:37:09 +0300 Subject: [PATCH] IGNITE-5963: Add additional check to Thread.sleep to make test correct in all cases. --- .../IgniteOptimisticTxSuspendResumeTest.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimisticTxSuspendResumeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimisticTxSuspendResumeTest.java index d16aebd61ca9e..37003a7ba0f4e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimisticTxSuspendResumeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimisticTxSuspendResumeTest.java @@ -32,6 +32,7 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.util.typedef.CI1; import org.apache.ignite.internal.util.typedef.CI2; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; @@ -428,7 +429,10 @@ public void testTxTimeoutOnResumed() throws Exception { tx.suspend(); - Thread.sleep(TX_TIMEOUT * 2); + long start = U.currentTimeMillis(); + + while(TX_TIMEOUT >= U.currentTimeMillis() - start) + Thread.sleep(TX_TIMEOUT * 2); GridTestUtils.assertThrowsWithCause(new Callable() { @Override public Object call() throws Exception { @@ -459,7 +463,10 @@ public void testTxTimeoutOnSuspend() throws Exception { cache.put(1, 1); - Thread.sleep(TX_TIMEOUT * 2); + long start = U.currentTimeMillis(); + + while(TX_TIMEOUT >= U.currentTimeMillis() - start) + Thread.sleep(TX_TIMEOUT * 2); GridTestUtils.assertThrowsWithCause(new Callable() { @Override public Object call() throws Exception {