You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by nt...@apache.org on 2016/03/22 17:49:39 UTC

[03/50] [abbrv] ignite git commit: Added tests.

Added tests.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/67db2645
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/67db2645
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/67db2645

Branch: refs/heads/ignite-2004
Commit: 67db26452ba7fb79d939fddbae598a35513558ed
Parents: b63cee4
Author: sboikov <sb...@gridgain.com>
Authored: Fri Mar 11 09:43:08 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Mar 11 09:43:08 2016 +0300

----------------------------------------------------------------------
 .../IgniteDynamicClientCacheStartSelfTest.java  | 78 ++++++++++++++++++++
 1 file changed, 78 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/67db2645/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicClientCacheStartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicClientCacheStartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicClientCacheStartSelfTest.java
index 0793dbe..cc7120e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicClientCacheStartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicClientCacheStartSelfTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.processors.cache;
 
+import java.util.List;
 import java.util.concurrent.Callable;
 import javax.cache.CacheException;
 import org.apache.ignite.Ignite;
@@ -29,6 +30,8 @@ import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridNoStorageCacheMap;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -36,6 +39,7 @@ import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_GRID_NAME;
 
 /**
  * Tests that cache specified in configuration start on client nodes.
@@ -226,6 +230,58 @@ public class IgniteDynamicClientCacheStartSelfTest extends GridCommonAbstractTes
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testCreateCloseClientCache1() throws Exception {
+        Ignite ignite0 = startGrid(0);
+
+        client = true;
+
+        Ignite clientNode = startGrid(1);
+
+        client = false;
+
+        ignite0.createCache(new CacheConfiguration<>());
+
+        clientNode.cache(null);
+
+        clientNode.cache(null).close();
+
+        clientNode.cache(null);
+
+        startGrid(2);
+
+        checkCache(clientNode, null, false, false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCreateCloseClientCache2() throws Exception {
+        Ignite ignite0 = startGrid(0);
+
+        Ignite ignite1 = startGrid(1);
+
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setNodeFilter(new CachePredicate(F.asList(ignite0.name())));
+
+        ignite1.createCache(ccfg);
+
+        assertNull(((IgniteKernal)ignite0).context().cache().internalCache(null));
+
+        ignite0.cache(null);
+
+        ignite0.cache(null).close();
+
+        ignite0.cache(null);
+
+        startGrid(2);
+
+        checkCache(ignite0, null, false, false);
+    }
+
+    /**
      * @param ignite Node.
      * @param cacheName Cache name
      * @param srv {@code True} if server cache is expected.
@@ -283,4 +339,26 @@ public class IgniteDynamicClientCacheStartSelfTest extends GridCommonAbstractTes
             assertFalse(disco.cacheNearNode(node, cacheName));
         }
     }
+
+    /**
+     *
+     */
+    static class CachePredicate implements IgnitePredicate<ClusterNode> {
+        /** */
+        private List<String> excludeNodes;
+
+        /**
+         * @param excludeNodes Nodes names.
+         */
+        public CachePredicate(List<String> excludeNodes) {
+            this.excludeNodes = excludeNodes;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean apply(ClusterNode clusterNode) {
+            String name = clusterNode.attribute(ATTR_GRID_NAME).toString();
+
+            return !excludeNodes.contains(name);
+        }
+    }
 }
\ No newline at end of file