Ignite-54-55 tests fix
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/00fa4700 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/00fa4700 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/00fa4700 Branch: refs/heads/ignite-57 Commit: 00fa47008c4cd46d8126a3ff74a1a4f67b29625b Parents: 7870d43 Author: Anton Vinogradov <[email protected]> Authored: Sun Jan 25 23:59:41 2015 +0300 Committer: Anton Vinogradov <[email protected]> Committed: Sun Jan 25 23:59:41 2015 +0300 ---------------------------------------------------------------------- .../cache/GridCacheClearAllSelfTest.java | 8 ++++---- .../distributed/GridCacheLockAbstractTest.java | 21 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/00fa4700/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllSelfTest.java index 7883067..8d4a2e6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllSelfTest.java @@ -249,7 +249,7 @@ public class GridCacheClearAllSelfTest extends GridCommonAbstractTest { // Ensure correct no-op clean of CLIENT_ONLY cache. warmCache(cachesPartitioned[2], keysCnt); assert cachesPartitioned[2].isEmpty(); - cachesPartitioned[2].clear(); + cachesPartitioned[2].clearLocally(); assert cachesPartitioned[2].isEmpty(); stopGrid(2); // Shutdown Grid in order to remove reader in NEAR_PARTITIONED cache. @@ -257,7 +257,7 @@ public class GridCacheClearAllSelfTest extends GridCommonAbstractTest { // Ensure correct clearLocally of NEA_ONLY cache. warmCache(cachesPartitioned[1], keysCnt); assert !cachesPartitioned[1].isEmpty(); - cachesPartitioned[1].clear(); + cachesPartitioned[1].clearLocally(); assert cachesPartitioned[1].isEmpty(); fillCache(cachesPartitioned[1], keysCnt); @@ -265,7 +265,7 @@ public class GridCacheClearAllSelfTest extends GridCommonAbstractTest { // Ensure correct clearLocally of NEAR_PARTITIONED cache. assert !cachesPartitioned[0].isEmpty(); - cachesPartitioned[0].clear(); + cachesPartitioned[0].clearLocally(); assert cachesPartitioned[0].isEmpty(); break; @@ -280,7 +280,7 @@ public class GridCacheClearAllSelfTest extends GridCommonAbstractTest { for (GridCache<Integer, Integer> cache : caches) { assert !cache.isEmpty(); - cache.clear(); + cache.clearLocally(); assert cache.isEmpty(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/00fa4700/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java index 9cf3c0d..ff9080d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java @@ -28,6 +28,7 @@ import org.apache.ignite.testframework.*; import org.apache.ignite.testframework.junits.common.*; import org.jetbrains.annotations.*; +import javax.cache.Cache; import java.util.*; import java.util.concurrent.*; @@ -122,10 +123,30 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest { cache1.removeAll(); + // Fix for tests where mapping was removed at primary node + // but was not removed at others. + // removeAll() removes mapping only when it presents at a primary node. + // To remove all mappings used force remove by key. + if (cache1.size() > 0) { + Iterator<Cache.Entry<Integer, String>> it = cache1.iterator(); + while (it.hasNext()) + cache1.remove(it.next().getKey()); + } + info("Before 2nd removeAll()."); cache2.removeAll(); + // Fix for tests where mapping was removed at primary node + // but was not removed at others. + // removeAll() removes mapping only when it presents at a primary node. + // To remove all mappings used force remove by key. + if (cache2.size() > 0) { + Iterator<Cache.Entry<Integer, String>> it = cache2.iterator(); + while (it.hasNext()) + cache2.remove(it.next().getKey()); + } + assert cache1.size() == 0 : "Cache is not empty: " + cache1; assert cache2.size() == 0 : "Cache is not empty: " + cache2; }
