# ignite-648: fix testSize
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/ff4f2571 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ff4f2571 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ff4f2571 Branch: refs/heads/ignite-648 Commit: ff4f2571dc3eec4cfba13f369451d30786b6d2db Parents: 2310936 Author: ashutak <ashu...@gridgain.com> Authored: Thu Jun 25 13:41:20 2015 +0300 Committer: ashutak <ashu...@gridgain.com> Committed: Thu Jun 25 13:41:20 2015 +0300 ---------------------------------------------------------------------- .../cache/GridCacheAbstractFullApiSelfTest.java | 38 ++++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ff4f2571/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java index b73a209..606f64a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -288,6 +288,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assert jcache(i).localSize() != 0 || F.isEmpty(keysCol); } + // TODO for (int i = 0; i < gridCount(); i++) { if (!isMultiJvmAndNodeIsRemote(i)) { GridCacheContext<String, Integer> ctx = context(i); @@ -3923,21 +3924,44 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract * @param keys Expected keys. * @throws Exception If failed. */ - protected void checkKeySize(Collection<String> keys) throws Exception { + protected void checkKeySize(final Collection<String> keys) throws Exception { if (nearEnabled()) assertEquals("Invalid key size: " + jcache().localSize(ALL), keys.size(), jcache().localSize(ALL)); else { for (int i = 0; i < gridCount(); i++) { - GridCacheContext<String, Integer> ctx = context(i); + if (!isMultiJvmAndNodeIsRemote(i)) { + GridCacheContext<String, Integer> ctx = context(i); - int size = 0; + int size = 0; - for (String key : keys) - if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx())) - size++; + for (String key : keys) + if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx())) + size++; + + assertEquals("Incorrect key size on cache #" + i, size, jcache(i).localSize(ALL)); + } + else { + final int finI = i; + final UUID id = grid(i).localNode().id(); + + ((IgniteProcessProxy)grid(i)).remoteCompute().run(new IgniteRunnable() { + @Override public void run() { + Ignite grid = Ignition.ignite(id); + + GridCacheContext<String, Integer> ctx = + ((IgniteKernal)grid).<String, Integer>internalCache().context(); + + int size = 0; + + for (String key : keys) + if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx())) + size++; - assertEquals("Incorrect key size on cache #" + i, size, jcache(i).localSize(ALL)); + assertEquals("Incorrect key size on cache #" + finI, size, grid.cache(null).localSize(ALL)); + } + }); + } } } }