IGNITE-45 - Fixing tests.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7d8c8ceb Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7d8c8ceb Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7d8c8ceb Branch: refs/heads/ignite-45 Commit: 7d8c8ceb9ccba9b06392b254c9282ab1e7e2b2e9 Parents: 35cda40 Author: Alexey Goncharuk <agoncha...@gridgain.com> Authored: Mon Mar 16 18:38:28 2015 -0700 Committer: Alexey Goncharuk <agoncha...@gridgain.com> Committed: Mon Mar 16 18:38:28 2015 -0700 ---------------------------------------------------------------------- .../discovery/GridDiscoveryManager.java | 10 +---- .../discovery/GridDiscoveryManagerSelfTest.java | 41 ++++++++++---------- .../GridCacheClientModesAbstractSelfTest.java | 18 +++++---- .../near/GridCacheNearOnlyTopologySelfTest.java | 38 ++++++++++++------ 4 files changed, 59 insertions(+), 48 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d8c8ceb/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java index 460c775..b818e34 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java @@ -218,7 +218,8 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> { boolean nearEnabled, boolean loc ) { - registeredCaches.put(cacheName, new CachePredicate(filter, nearEnabled, loc)); + if (!registeredCaches.containsKey(cacheName)) + registeredCaches.put(cacheName, new CachePredicate(filter, nearEnabled, loc)); } /** @@ -2384,13 +2385,6 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> { } /** - * @param nodeId Near node ID to remove. - */ - public void removeNearNode(UUID nodeId) { - clientNodes.remove(nodeId); - } - - /** * @param leftNodeId Left node ID. */ public void onNodeLeft(UUID leftNodeId) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d8c8ceb/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java index 2fd4b29..eb8d3fa 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.managers.discovery; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.affinity.*; @@ -29,7 +28,6 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import org.apache.ignite.testframework.junits.common.*; -import static org.apache.ignite.cache.CacheDistributionMode.*; import static org.apache.ignite.cache.CacheMode.*; /** @@ -66,22 +64,15 @@ public class GridDiscoveryManagerSelfTest extends GridCommonAbstractTest { ccfg2.setName(null); - CacheDistributionMode distrMode; - if (gridName.equals(getTestGridName(1))) - distrMode = NEAR_ONLY; - else if (gridName.equals(getTestGridName(2))) - distrMode = NEAR_PARTITIONED; - else - distrMode = PARTITIONED_ONLY; + cfg.setClientMode(true); + + ccfg1.setNearConfiguration(null); + ccfg2.setNearConfiguration(null); ccfg1.setCacheMode(PARTITIONED); ccfg2.setCacheMode(PARTITIONED); - // TODO IGNITE-45. -// ccfg1.setDistributionMode(distrMode); -// ccfg2.setDistributionMode(distrMode); - cfg.setCacheConfiguration(ccfg1, ccfg2); return cfg; @@ -95,7 +86,7 @@ public class GridDiscoveryManagerSelfTest extends GridCommonAbstractTest { AffinityTopologyVersion zero = new AffinityTopologyVersion(0); AffinityTopologyVersion one = new AffinityTopologyVersion(1); - AffinityTopologyVersion two = new AffinityTopologyVersion(2); + AffinityTopologyVersion two = new AffinityTopologyVersion(2, 2); AffinityTopologyVersion three = new AffinityTopologyVersion(3); AffinityTopologyVersion four = new AffinityTopologyVersion(4); AffinityTopologyVersion five = new AffinityTopologyVersion(5); @@ -108,6 +99,14 @@ public class GridDiscoveryManagerSelfTest extends GridCommonAbstractTest { IgniteKernal g1 = (IgniteKernal)startGrid(1); // NEAR_ONLY cache. + grid(1).createCache(new NearCacheConfiguration()); + + NearCacheConfiguration near = new NearCacheConfiguration(); + + near.setName(CACHE_NAME); + + grid(1).createCache(near); + assertFalse(g0.context().discovery().hasNearCache(CACHE_NAME, one)); assertTrue(g0.context().discovery().hasNearCache(CACHE_NAME, two)); assertFalse(g0.context().discovery().hasNearCache(null, one)); @@ -116,7 +115,7 @@ public class GridDiscoveryManagerSelfTest extends GridCommonAbstractTest { assertTrue(g1.context().discovery().hasNearCache(CACHE_NAME, two)); assertTrue(g1.context().discovery().hasNearCache(null, two)); - IgniteKernal g2 = (IgniteKernal)startGrid(2); // NEAR_PARTITIONED cache. + IgniteKernal g2 = (IgniteKernal)startGrid(2); // PARTITIONED_ONLY cache. assertFalse(g0.context().discovery().hasNearCache(CACHE_NAME, one)); assertTrue(g0.context().discovery().hasNearCache(CACHE_NAME, two)); @@ -133,7 +132,7 @@ public class GridDiscoveryManagerSelfTest extends GridCommonAbstractTest { assertTrue(g2.context().discovery().hasNearCache(CACHE_NAME, three)); assertTrue(g2.context().discovery().hasNearCache(null, three)); - stopGrid(1); + stopGrid(2); // Wait all nodes are on version 4. for (;;) { @@ -158,12 +157,12 @@ public class GridDiscoveryManagerSelfTest extends GridCommonAbstractTest { assertTrue(g0.context().discovery().hasNearCache(null, three)); assertTrue(g0.context().discovery().hasNearCache(null, four)); - assertTrue(g2.context().discovery().hasNearCache(CACHE_NAME, three)); - assertTrue(g2.context().discovery().hasNearCache(CACHE_NAME, four)); - assertTrue(g2.context().discovery().hasNearCache(null, three)); - assertTrue(g2.context().discovery().hasNearCache(null, four)); + assertTrue(g1.context().discovery().hasNearCache(CACHE_NAME, three)); + assertTrue(g1.context().discovery().hasNearCache(CACHE_NAME, four)); + assertTrue(g1.context().discovery().hasNearCache(null, three)); + assertTrue(g1.context().discovery().hasNearCache(null, four)); - stopGrid(2); + stopGrid(1); // Wait all nodes are on version 5. for (;;) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d8c8ceb/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java index 4911a49..9030365 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java @@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.cache.distributed; import org.apache.ignite.*; import org.apache.ignite.cache.*; import org.apache.ignite.cache.affinity.rendezvous.*; -import org.apache.ignite.cache.store.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; @@ -28,7 +27,6 @@ import org.apache.ignite.internal.util.typedef.*; import java.util.concurrent.atomic.*; -import static org.apache.ignite.cache.CacheDistributionMode.*; import static org.apache.ignite.cache.CacheMode.*; /** @@ -53,17 +51,23 @@ public abstract class GridCacheClientModesAbstractSelfTest extends GridCacheAbst super.beforeTestsStarted(); } - /** {@inheritDoc} */ - @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { - CacheConfiguration cfg = super.cacheConfiguration(gridName); + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + // TODO IGNITE-45 test hangs if (gridCnt.getAndIncrement() == 0) { - // TODO IGNITE-45 -// cfg.setDistributionMode(clientOnly() ? CLIENT_ONLY : NEAR_ONLY); + cfg.setClientMode(true); nearOnlyGridName = gridName; } + return cfg; + } + + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration cfg = super.cacheConfiguration(gridName); + cfg.setCacheStoreFactory(null); cfg.setReadThrough(false); cfg.setWriteThrough(false); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d8c8ceb/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java index f5c1785..b2c8e0f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java @@ -45,7 +45,7 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest { private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); /** Near only flag. */ - private boolean nearOnly; + private boolean cilent; /** Use cache flag. */ private boolean cache = true; @@ -54,13 +54,14 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - if (cache && !nearOnly) { + if (cilent) + cfg.setClientMode(true); + + if (cache) { CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(PARTITIONED); cacheCfg.setBackups(1); - // TODO IGNITE-45 -// cacheCfg.setDistributionMode(nearOnly ? NEAR_ONLY : NEAR_PARTITIONED); cacheCfg.setRebalanceMode(SYNC); cacheCfg.setAtomicityMode(TRANSACTIONAL); @@ -107,9 +108,12 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest { cache = true; for (int i = 0; i < 4; i++) { - nearOnly = i == 0; + cilent = i == 0; + + Ignite ignite = startGrid(i); - startGrid(i); + if (cilent) + ignite.createCache(new NearCacheConfiguration()); } for (int i = 0; i < 100; i++) @@ -126,12 +130,16 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest { cache = true; for (int i = 0; i < 4; i++) { - nearOnly = i == 0; + cilent = i == 0; + + Ignite ignite = startGrid(i); - startGrid(i); + if (cilent) + ignite.createCache(new NearCacheConfiguration()); } cache = false; + cilent = true; Ignite compute = startGrid(4); @@ -153,9 +161,12 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest { cache = true; for (int i = 0; i < 2; i++) { - nearOnly = i == 0; + cilent = i == 0; - startGrid(i); + Ignite ignite = startGrid(i); + + if (cilent) + ignite.createCache(new NearCacheConfiguration()); } for (int i = 0; i < 10; i++) @@ -223,9 +234,12 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest { cache = true; for (int i = 0; i < totalNodeCnt; i++) { - nearOnly = nearNodeIdx == i; + cilent = nearNodeIdx == i; + + Ignite ignite = startGrid(i); - startGrid(i); + if (cilent) + ignite.createCache(new NearCacheConfiguration()); } } finally {