Fixed test to really check query result.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/dcd8b42a Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/dcd8b42a Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/dcd8b42a Branch: refs/heads/ignite-843 Commit: dcd8b42aa696bafbb4d7c11a9cf1520d54539001 Parents: ae1e1dc Author: sboikov <sboi...@gridgain.com> Authored: Tue Sep 15 16:44:05 2015 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Tue Sep 15 16:44:05 2015 +0300 ---------------------------------------------------------------------- ...CacheScanPartitionQueryFallbackSelfTest.java | 54 ++++++++------------ 1 file changed, 21 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/dcd8b42a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheScanPartitionQueryFallbackSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheScanPartitionQueryFallbackSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheScanPartitionQueryFallbackSelfTest.java index df310b4..1ef470a 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheScanPartitionQueryFallbackSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheScanPartitionQueryFallbackSelfTest.java @@ -146,7 +146,7 @@ public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractT CacheQuery<Map.Entry<Integer, Integer>> qry = cache.context().queries().createScanQuery(null, part, false); - doTestScanQuery(qry); + doTestScanQuery(qry, part); } finally { stopAllGrids(); @@ -176,7 +176,7 @@ public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractT CacheQuery<Map.Entry<Integer, Integer>> qry = cache.context().queries().createScanQuery(null, part, false); - doTestScanQuery(qry); + doTestScanQuery(qry, part); } finally { stopAllGrids(); @@ -198,7 +198,7 @@ public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractT try { Ignite ignite = startGrids(GRID_CNT); - final IgniteCacheProxy<Integer, Integer> cache = fillCache(ignite); + fillCache(ignite); final AtomicBoolean done = new AtomicBoolean(false); @@ -211,6 +211,7 @@ public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractT while (!done.get()) { startGrid(id); + Thread.sleep(3000); stopGrid(id); @@ -240,15 +241,10 @@ public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractT int part = tup.get1(); - try { - CacheQuery<Map.Entry<Integer, Integer>> qry = cache.context().queries().createScanQuery( - null, part, false); + CacheQuery<Map.Entry<Integer, Integer>> qry = cache.context().queries().createScanQuery( + null, part, false); - doTestScanQuery(qry); - } - catch (ClusterGroupEmptyCheckedException e) { - log.warning("Invalid partition: " + part, e); - } + doTestScanQuery(qry, part); } return null; @@ -315,17 +311,12 @@ public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractT while (!done.get()) { int part = ThreadLocalRandom.current().nextInt(ignite(nodeId).affinity(null).partitions()); - try { - QueryCursor<Cache.Entry<Integer, Integer>> cur = - cache.query(new ScanQuery<Integer, Integer>(part)); + QueryCursor<Cache.Entry<Integer, Integer>> cur = + cache.query(new ScanQuery<Integer, Integer>(part)); - U.debug(log, "Running query [node=" + nodeId + ", part=" + part + ']'); + U.debug(log, "Running query [node=" + nodeId + ", part=" + part + ']'); - doTestScanQueryCursor(cur, part); - } - catch (ClusterGroupEmptyCheckedException e) { - log.warning("Invalid partition: " + part, e); - } + doTestScanQueryCursor(cur, part); } return null; @@ -404,7 +395,7 @@ public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractT } }; - int part; + Integer part = null; CacheQuery<Map.Entry<Integer, Integer>> qry = null; if (test.get()) { @@ -416,7 +407,7 @@ public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractT new Thread(run).start(); if (test.get()) - doTestScanQuery(qry); + doTestScanQuery(qry, part); else latch.await(); } @@ -454,20 +445,18 @@ public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractT /** * @param qry Query. */ - protected void doTestScanQuery( - CacheQuery<Map.Entry<Integer, Integer>> qry) throws IgniteCheckedException { + protected void doTestScanQuery(CacheQuery<Map.Entry<Integer, Integer>> qry, int part) + throws IgniteCheckedException { CacheQueryFuture<Map.Entry<Integer, Integer>> fut = qry.execute(); - Collection<Map.Entry<Integer, Integer>> expEntries = fut.get(); + Collection<Map.Entry<Integer, Integer>> qryEntries = fut.get(); - for (Map.Entry<Integer, Integer> e : expEntries) { - Map<Integer, Integer> map = entries.get(((GridCacheQueryAdapter)qry).partition()); + Map<Integer, Integer> map = entries.get(part); - if (map == null) - assertTrue(expEntries.isEmpty()); - else - assertEquals(map.get(e.getKey()), e.getValue()); - } + for (Map.Entry<Integer, Integer> e : qryEntries) + assertEquals(map.get(e.getKey()), e.getValue()); + + assertEquals("Invalid number of entries for partition: " + part, map.size(), qryEntries.size()); } /** @@ -484,7 +473,6 @@ public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractT int cnt = 0; for (Cache.Entry<Integer, Integer> e : cur) { - assertEquals(map.get(e.getKey()), e.getValue()); cnt++;