IGNITE-5963: Add additional check to Thread.sleep to make test correct in all cases. - Fixes #2422.
Signed-off-by: Alexey Goncharuk <alexey.goncha...@gmail.com> Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a7ac59f7 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a7ac59f7 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a7ac59f7 Branch: refs/heads/ignite-5872 Commit: a7ac59f7bb214fc9eb4fd4520aad7c40c4dd9ee9 Parents: 0d8d166 Author: Nikolay Izhikov <nizhikov....@gmail.com> Authored: Thu Aug 10 15:48:26 2017 +0300 Committer: Alexey Goncharuk <alexey.goncha...@gmail.com> Committed: Thu Aug 10 15:48:26 2017 +0300 ---------------------------------------------------------------------- .../distributed/IgniteOptimisticTxSuspendResumeTest.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/a7ac59f7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimisticTxSuspendResumeTest.java ---------------------------------------------------------------------- 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 d16aebd..37003a7 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.configuration.NearCacheConfiguration; 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 class IgniteOptimisticTxSuspendResumeTest extends GridCommonAbstractTest 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<Object>() { @Override public Object call() throws Exception { @@ -459,7 +463,10 @@ public class IgniteOptimisticTxSuspendResumeTest extends GridCommonAbstractTest 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<Object>() { @Override public Object call() throws Exception {