# ignite-sprint-4 changed test to detect 'get' hang
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/658fb44a Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/658fb44a Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/658fb44a Branch: refs/heads/ignite-424 Commit: 658fb44a961f555a9d7eab95880ab1a44257b1d7 Parents: 4649f85 Author: sboikov <sboi...@gridgain.com> Authored: Tue Apr 14 12:51:02 2015 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Tue Apr 14 12:51:02 2015 +0300 ---------------------------------------------------------------------- .../GridCacheAbstractFailoverSelfTest.java | 25 ++++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/658fb44a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java index aee3588..f5aa06b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java @@ -30,6 +30,7 @@ import org.jetbrains.annotations.*; import javax.cache.*; import java.util.*; +import java.util.concurrent.atomic.*; import static org.apache.ignite.cache.CacheRebalanceMode.*; @@ -168,12 +169,14 @@ public abstract class GridCacheAbstractFailoverSelfTest extends GridCacheAbstrac final int half = ENTRY_CNT / 2; + final AtomicReference<Exception> err = new AtomicReference<>(); + IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new CA() { @Override public void apply() { info("Run topology change."); try { - for (int i = 0; i < TOP_CHANGE_CNT; i++) { + for (int i = 0; i < TOP_CHANGE_CNT && err.get() == null; i++) { info("Topology change " + i); String name = UUID.randomUUID().toString(); @@ -181,8 +184,15 @@ public abstract class GridCacheAbstractFailoverSelfTest extends GridCacheAbstrac try { final Ignite g = startGrid(name); - for (int k = half; k < ENTRY_CNT; k++) - assertNotNull("Failed to get key: 'key" + k + "'", cache(g).get("key" + k)); + IgniteCache<String, Object> cache = g.<String, Object>cache(null).withAsync(); + + for (int k = half; k < ENTRY_CNT; k++) { + String key = "key" + k; + + cache.get(key); + + assertNotNull("Failed to get key: 'key" + k + "'", cache.future().get(30_000)); + } } finally { G.stop(name, false); @@ -190,9 +200,9 @@ public abstract class GridCacheAbstractFailoverSelfTest extends GridCacheAbstrac } } catch (Exception e) { - log.error("Unexpected exception in topology-change-thread: " + e, e); + err.set(e); - throw F.wrap(e); + log.error("Unexpected exception in topology-change-thread: " + e, e); } } }, TOP_CHANGE_THREAD_CNT, "topology-change-thread"); @@ -216,6 +226,11 @@ public abstract class GridCacheAbstractFailoverSelfTest extends GridCacheAbstrac } fut.get(); + + Exception err0 = err.get(); + + if (err0 != null) + throw err0; } /**