ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ivasilin...@apache.org
Subject incubator-ignite git commit: #ignite-1087: add tests.
Date Mon, 13 Jul 2015 13:31:38 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-1087 17b0fb7be -> 14b58dbc7


#ignite-1087: add 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/14b58dbc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/14b58dbc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/14b58dbc

Branch: refs/heads/ignite-1087
Commit: 14b58dbc799885989b20e91868848de828df7972
Parents: 17b0fb7
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Mon Jul 13 16:31:33 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Mon Jul 13 16:31:33 2015 +0300

----------------------------------------------------------------------
 .../cache/CacheAffinityCallSelfTest.java        | 42 ++++++++++++++++++--
 1 file changed, 39 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/14b58dbc/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 a8a838e..2505eb9 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
@@ -1,6 +1,7 @@
 package org.apache.ignite.internal.processors.cache;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
@@ -29,6 +30,9 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest {
     private static final int MAX_FAILOVER_ATTEMPTS = 5;
 
     /** */
+    private static final int SERVERS_COUNT = 4;
+
+    /** */
     private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
 
     /** {@inheritDoc} */
@@ -52,6 +56,9 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest {
 
         cfg.setCacheConfiguration(ccfg);
 
+        if (gridName.equals(getTestGridName(SERVERS_COUNT)))
+            cfg.setClientMode(true);
+
         return cfg;
     }
 
@@ -84,6 +91,37 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testAffinityCallNoServerNode() throws Exception {
+        startGrids(SERVERS_COUNT + 1);
+
+        final Integer key = 1;
+
+        final Ignite client = grid(SERVERS_COUNT);
+
+        final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>()
{
+            @Override public Object call() throws Exception {
+                for (int i = 0; i < SERVERS_COUNT; ++i)
+                    stopGrid(i);
+
+                return null;
+            }
+        });
+
+        GridTestUtils.assertThrows(log, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                while (!fut.isDone())
+                    client.compute().affinityCall(CACHE_NAME, key, new CheckCallable(key));
+
+                return null;
+            }
+        }, ClusterGroupEmptyException.class, "Topology projection is empty");
+
+        stopAllGrids();
+    }
+
+    /**
      * Test callable.
      */
     public static class CheckCallable implements IgniteCallable<Object> {
@@ -103,11 +141,9 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest
{
 
         /** {@inheritDoc} */
         @Override public Object call() throws IgniteCheckedException {
-            assert ignite.cluster().localNode().id().equals(ignite.cluster().mapKeyToNode(null,
key).id());
+            assert ignite.cluster().localNode().id().equals(ignite.cluster().mapKeyToNode(CACHE_NAME,
key).id());
 
             return null;
         }
     }
-
-
 }


Mime
View raw message