ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [2/2] incubator-ignite git commit: #ignite-860: Add closure tests.
Date Wed, 27 May 2015 16:47:09 GMT
#ignite-860: Add closure 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/411e2aea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/411e2aea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/411e2aea

Branch: refs/heads/ignite-860
Commit: 411e2aea946d60d4c884b3bb8a7a1207874ad540
Parents: 236d224
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Wed May 27 19:46:46 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Wed May 27 19:46:46 2015 +0300

----------------------------------------------------------------------
 .../service/ClosureServiceClientsNodesTest.java | 123 +++++++++++++++++++
 .../ignite/testsuites/IgniteBasicTestSuite.java |   2 +
 2 files changed, 125 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/411e2aea/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ClosureServiceClientsNodesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ClosureServiceClientsNodesTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ClosureServiceClientsNodesTest.java
new file mode 100644
index 0000000..c1849c4
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ClosureServiceClientsNodesTest.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.service;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.marshaller.optimized.*;
+import org.apache.ignite.resources.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+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 java.util.*;
+
+/**
+ * Test that compute and service run only on server nodes by default.
+ */
+public class ClosureServiceClientsNodesTest extends GridCommonAbstractTest {
+    /** Number of grids started for tests. */
+    private static final int NODES_CNT = 4;
+
+    /** IP finder. */
+    private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setMarshaller(new OptimizedMarshaller(false));
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+        discoSpi.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(discoSpi);
+
+        cfg.setCacheConfiguration();
+
+        if (gridName.equals(getTestGridName(0)))
+            cfg.setClientMode(true);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings({"ConstantConditions"})
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGrids(NODES_CNT);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDefaultClosure() throws Exception {
+        Ignite ignite = grid(0);
+
+        Collection<String> res = ignite.compute().broadcast(new IgniteCallable<String>()
{
+            @IgniteInstanceResource
+            Ignite ignite;
+
+            @Override public String call() throws Exception {
+                return ignite.name();
+            }
+        });
+
+        assertEquals(res.size(), NODES_CNT - 1);
+
+        Set<String> serverNames = new HashSet<>(NODES_CNT - 1);
+
+        for (int i = 1; i < NODES_CNT; ++i)
+            serverNames.add(getTestGridName(i));
+
+        for (String name : res) {
+            assertTrue(serverNames.contains(name));
+
+            serverNames.remove(name);
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClientClosure() throws Exception {
+        Ignite ignite = grid(0);
+
+        Collection<String> res = ignite.compute(ignite.cluster().forClients()).
+            broadcast(new IgniteCallable<String>() {
+                @IgniteInstanceResource
+                Ignite ignite;
+
+                @Override public String call() throws Exception {
+                    return ignite.name();
+                }
+            });
+
+        assertEquals(1, res.size());
+
+        assertEquals(getTestGridName(0), F.first(res));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/411e2aea/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index 56ff951..6382059 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.closure.*;
 import org.apache.ignite.internal.processors.continuous.*;
+import org.apache.ignite.internal.processors.service.*;
 import org.apache.ignite.internal.product.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.messaging.*;
@@ -61,6 +62,7 @@ public class IgniteBasicTestSuite extends TestSuite {
         suite.addTestSuite(GridProductVersionSelfTest.class);
         suite.addTestSuite(GridAffinityProcessorRendezvousSelfTest.class);
         suite.addTestSuite(GridClosureProcessorSelfTest.class);
+        suite.addTestSuite(ClosureServiceClientsNodesTest.class);
         suite.addTestSuite(GridStartStopSelfTest.class);
         suite.addTestSuite(GridProjectionForCachesSelfTest.class);
         suite.addTestSuite(GridProjectionForCachesOnDaemonNodeSelfTest.class);


Mime
View raw message