ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [16/40] incubator-ignite git commit: # ignite-648: fix near tests
Date Wed, 01 Jul 2015 14:49:50 GMT
# ignite-648: fix near 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/3c7ff71a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/3c7ff71a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/3c7ff71a

Branch: refs/heads/ignite-648-failover
Commit: 3c7ff71abdcce93f227a704c9b69f9dcb7d61d21
Parents: 1146e41
Author: ashutak <ashutak@gridgain.com>
Authored: Mon Jun 29 21:56:25 2015 +0300
Committer: ashutak <ashutak@gridgain.com>
Committed: Mon Jun 29 21:56:25 2015 +0300

----------------------------------------------------------------------
 .../cache/GridCacheAbstractFullApiSelfTest.java | 41 +++++++++++++++-----
 .../cache/GridCacheAbstractSelfTest.java        |  2 +-
 ...achePartitionedMultiNodeFullApiSelfTest.java | 39 ++++++++++++++-----
 .../testframework/junits/GridAbstractTest.java  |  2 +-
 .../junits/common/GridCommonAbstractTest.java   | 22 +++++++++--
 .../junits/multijvm/IgniteProcessProxy.java     | 18 +++++++++
 6 files changed, 99 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c7ff71a/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 483fc20..d295be6 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
@@ -2317,25 +2317,46 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
 
             for (int g = 0; g < gridCount(); g++) {
                 for (int i = 0; i < cnt; i++) {
-                    String key = String.valueOf(i);
-
-                    GridCacheContext<String, Integer> cctx = context(g);
+                    if (!isMultiJvmAndNodeIsRemote(g))
+                        checkDeletedEntriesFlag(g, i);
+                    else {
+                        IgniteProcessProxy proxy = (IgniteProcessProxy)grid(g);
 
-                    GridCacheEntryEx entry = cctx.isNear() ? cctx.near().dht().peekEx(key)
:
-                        cctx.cache().peekEx(key);
+                        final int idx = g;
+                        final int key = i;
 
-                    if (grid(0).affinity(null).mapKeyToPrimaryAndBackups(key).contains(grid(g).localNode()))
{
-                        assertNotNull(entry);
-                        assertTrue(entry.deleted());
+                        proxy.remoteCompute().run(new GridAbsClosureX() {
+                            @Override public void applyx() throws IgniteCheckedException
{
+                                checkDeletedEntriesFlag(idx, key);
+                            }
+                        });
                     }
-                    else
-                        assertNull(entry);
                 }
             }
         }
     }
 
     /**
+     * @param idx Grid index.
+     * @param keyN Key.
+     */
+    private void checkDeletedEntriesFlag(int idx, int keyN) {
+        String key = String.valueOf(keyN);
+
+        GridCacheContext<String, Integer> cctx = context(idx);
+
+        GridCacheEntryEx entry = cctx.isNear() ? cctx.near().dht().peekEx(key) :
+            cctx.cache().peekEx(key);
+
+        if (grid(idx).affinity(null).mapKeyToPrimaryAndBackups(key).contains(grid(idx).localNode()))
{
+            assertNotNull(entry);
+            assertTrue(entry.deleted());
+        }
+        else
+            assertNull(entry);
+    }
+
+    /**
      * @throws Exception If failed.
      */
     public void testRemoveLoad() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c7ff71a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
index f75f77d..d98a550 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
@@ -371,7 +371,7 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest
{
     protected GridCacheContext<String, Integer> context(final int idx) {
         if (isMultiJvmAndNodeIsRemote(idx) && !weAreOnRemoteJvm())
             throw new UnsupportedOperationException("Operation can't be done automatically
via proxy. " +
-                "Send task with this logic on remote jvm.");
+                "Send task with this logic on remote jvm instead.");
 
         return ((IgniteKernal)grid(idx)).<String, Integer>internalCache().context();
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c7ff71a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
index 1864c0a..003c186 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
@@ -26,6 +26,7 @@ import org.apache.ignite.events.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.lang.*;
+import org.apache.ignite.testframework.junits.multijvm.*;
 
 import java.util.*;
 
@@ -134,7 +135,7 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
         for (int i = 0; i < gridCount(); i++)
             info(">>>>> Grid" + i + ": " + grid(i).localNode().id());
 
-        int size = 10;
+        final int size = 10;
 
         IgniteCache<Object, Object> chache0 = grid(0).cache(null);
 
@@ -147,15 +148,16 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
         }
 
         for (int i = 0; i < gridCount(); i++) {
-            assertEquals(0, context(i).tm().idMapSize());
-
-            IgniteCache<Object, Object> cache = grid(i).cache(null);
-            ClusterNode node = grid(i).localNode();
-
-            for (int k = 0; k < size; k++) {
-                if (affinity(cache).isPrimaryOrBackup(node, k))
-                    assertEquals("Check failed for node: " + node.id(), k,
-                        cache.localPeek(k, CachePeekMode.ONHEAP, CachePeekMode.OFFHEAP));
+            if (!isMultiJvmAndNodeIsRemote(i))
+                putDebugCheck0(i, size);
+            else {
+                final int iCopy = i;
+
+                ((IgniteProcessProxy)grid(i)).remoteCompute().run(new IgniteRunnable() {
+                    @Override public void run() {
+                        putDebugCheck0(iCopy, size);
+                    }
+                });
             }
         }
 
@@ -172,6 +174,23 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
     }
 
     /**
+     * @param gridIdx Grid index.
+     * @param size Size.
+     */
+    private void putDebugCheck0(int gridIdx, int size) {
+        assertEquals(0, context(gridIdx).tm().idMapSize());
+
+        IgniteCache<Object, Object> cache = grid(gridIdx).cache(null);
+        ClusterNode node = grid(gridIdx).localNode();
+
+        for (int k = 0; k < size; k++) {
+            if (affinity(cache).isPrimaryOrBackup(node, k))
+                assertEquals("Check failed for node: " + node.id(), k,
+                    cache.localPeek(k, CachePeekMode.ONHEAP, CachePeekMode.OFFHEAP));
+        }
+    }
+
+    /**
      * @throws Exception If failed.
      */
     public void testUnswapShort() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c7ff71a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 0a43059..fc7cc88 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -910,7 +910,7 @@ public abstract class GridAbstractTest extends TestCase {
         if (!isMultiJvm())
             return G.ignite(node.id());
         else
-            throw new UnsupportedOperationException("Operation doesn't supported yet.");
+            return IgniteProcessProxy.ignite(node.id());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c7ff71a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index 9941ca8..1fc4415 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -36,6 +36,7 @@ import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.testframework.junits.*;
+import org.apache.ignite.testframework.junits.multijvm.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.*;
@@ -201,9 +202,24 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest
{
      * @param cache Cache.
      * @return {@code True} if near cache is enabled.
      */
-    protected static <K, V> boolean nearEnabled(IgniteCache<K,V> cache) {
-        CacheConfiguration cfg = ((IgniteKernal)cache.unwrap(Ignite.class)).
-            <K, V>internalCache(cache.getName()).context().config();
+    protected static <K, V> boolean nearEnabled(final IgniteCache<K,V> cache)
{
+        final Ignite ignite = cache.unwrap(Ignite.class);
+
+        CacheConfiguration cfg;
+
+        if (!(ignite instanceof IgniteProcessProxy))
+            cfg = ((IgniteKernal)ignite).<K, V>internalCache(cache.getName()).context().config();
+        else {
+            final String cacheName = cache.getName();
+
+            cfg = ((IgniteProcessProxy)ignite).remoteCompute().call(new IgniteCallable<CacheConfiguration>()
{
+                @Override public CacheConfiguration call() throws Exception {
+                    IgniteEx grid = IgniteNodeRunner.startedInstance();
+
+                    return ((IgniteKernal)grid).<K, V>internalCache(cacheName).context().config();
+                }
+            });
+        }
 
         return isNearEnabled(cfg);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c7ff71a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
index 42436e5..5ed5b87 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
@@ -131,6 +131,24 @@ public class IgniteProcessProxy implements IgniteEx {
     }
 
     /**
+     * @param locNodeId ID of local node the requested grid instance is managing.
+     * @return An instance of named grid. This method never returns {@code null}.
+     * @throws IgniteIllegalStateException Thrown if grid was not properly initialized or
grid instance was stopped or
+     * was not started.
+     */
+    public static Ignite ignite(UUID locNodeId) {
+        A.notNull(locNodeId, "locNodeId");
+
+        for (IgniteProcessProxy ignite : gridProxies.values()) {
+            if (ignite.getId().equals(locNodeId))
+                return ignite;
+        }
+
+        throw new IgniteIllegalStateException("Grid instance with given local node ID was
not properly " +
+            "started or was stopped: " + locNodeId);
+    }
+
+    /**
      * Kill all running processes.
      */
     public static void killAll() {


Mime
View raw message