Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BC7EB18069 for ; Thu, 3 Sep 2015 11:13:22 +0000 (UTC) Received: (qmail 26838 invoked by uid 500); 3 Sep 2015 11:13:22 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 26733 invoked by uid 500); 3 Sep 2015 11:13:22 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 26436 invoked by uid 99); 3 Sep 2015 11:13:22 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Sep 2015 11:13:22 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4F59DE7E5F; Thu, 3 Sep 2015 11:13:22 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Thu, 03 Sep 2015 11:13:29 -0000 Message-Id: In-Reply-To: <97d9c9cf5bae46468c93699f0d042e7b@git.apache.org> References: <97d9c9cf5bae46468c93699f0d042e7b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [08/30] ignite git commit: Fixed test. Fixed test. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ba756cdd Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ba756cdd Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ba756cdd Branch: refs/heads/ignite-1353 Commit: ba756cdd64bb6e9b1e678765245beea4e1181a98 Parents: 2c236ac Author: sboikov Authored: Wed Sep 2 13:40:53 2015 +0300 Committer: sboikov Committed: Wed Sep 2 13:46:06 2015 +0300 ---------------------------------------------------------------------- .../cache/CacheAffinityCallSelfTest.java | 85 ++++++++++++++------ 1 file changed, 62 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/ba756cdd/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java index 78d16f8..c25bc7c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java @@ -21,12 +21,15 @@ import java.util.concurrent.Callable; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteCompute; -import org.apache.ignite.IgniteException; import org.apache.ignite.cluster.ClusterGroupEmptyException; +import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.compute.ComputeTaskCancelledException; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.IgniteKernal; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.processors.affinity.GridAffinityProcessor; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.lang.IgniteRunnable; @@ -78,9 +81,12 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(ccfg); - if (gridName.equals(getTestGridName(SERVERS_COUNT))) + if (gridName.equals(getTestGridName(SERVERS_COUNT))) { cfg.setClientMode(true); + spi.setForceServerMode(true); + } + return cfg; } @@ -93,21 +99,35 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ public void testAffinityCallRestartNode() throws Exception { - startGrids(4); + startGridsMultiThreaded(SERVERS_COUNT); - Integer key = primaryKey(grid(0).cache(CACHE_NAME)); + final int ITERS = 5; - IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable() { - @Override public Object call() throws Exception { - U.sleep(500); - stopGrid(0); + for (int i = 0; i < ITERS; i++) { + log.info("Iteration: " + i); - return null; - } - }); + Integer key = primaryKey(grid(0).cache(CACHE_NAME)); + + long topVer = grid(0).cluster().topologyVersion(); + + IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable() { + @Override public Object call() throws Exception { + U.sleep(500); + + stopGrid(0); + + return null; + } + }); + + while (!fut.isDone()) + grid(1).compute().affinityCall(CACHE_NAME, key, new CheckCallable(key, topVer, topVer + 1)); - while (!fut.isDone()) - grid(1).compute().affinityCall(CACHE_NAME, key, new CheckCallable(key)); + fut.get(); + + if (i < ITERS - 1) + startGrid(0); + } stopAllGrids(); } @@ -116,12 +136,14 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ public void testAffinityCallNoServerNode() throws Exception { - startGrids(SERVERS_COUNT + 1); + startGridsMultiThreaded(SERVERS_COUNT + 1); final Integer key = 1; final Ignite client = grid(SERVERS_COUNT); + assertTrue(client.configuration().isClientMode()); + final IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable() { @Override public Object call() throws Exception { for (int i = 0; i < SERVERS_COUNT; ++i) @@ -136,15 +158,10 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest { client.compute().affinityCall(CACHE_NAME, key, new CheckCallable(key)); } catch (ComputeTaskCancelledException e) { - assertTrue(e.getMessage().contains("stopping")); + assertTrue("Unexpected error: " + e, e.getMessage().contains("stopping")); } catch(ClusterGroupEmptyException e) { - assertTrue(e.getMessage().contains("Topology projection is empty")); - } - catch(IgniteException e) { - assertTrue(e.getMessage().contains("Client node disconnected") || - e.getMessage().contains("Failed to reconnect to cluster") || - e.getMessage().contains("Failed to execute task, client node disconnected.")); + assertTrue("Unexpected error: " + e, e.getMessage().contains("Topology projection is empty")); } stopAllGrids(); @@ -161,16 +178,38 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest { @IgniteInstanceResource private Ignite ignite; + /** */ + private long[] topVers; + /** * @param key Key. + * @param topVers Topology versions to check. */ - public CheckCallable(Object key) { + public CheckCallable(Object key, long... topVers) { this.key = key; + this.topVers = topVers; } /** {@inheritDoc} */ @Override public Object call() throws IgniteCheckedException { - assert ignite.cluster().localNode().id().equals(ignite.cluster().mapKeyToNode(CACHE_NAME, key).id()); + if (topVers.length > 0) { + boolean pass = false; + + GridCacheAffinityManager aff = + ((IgniteKernal)ignite).context().cache().internalCache(CACHE_NAME).context().affinity(); + + ClusterNode loc = ignite.cluster().localNode(); + + for (long topVer : topVers) { + if (loc.equals(aff.primary(key, new AffinityTopologyVersion(topVer, 0)))) { + pass = true; + + break; + } + } + + assertTrue(pass); + } return null; }