ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [04/11] incubator-ignite git commit: # IGNITE-709 Add additional tests.
Date Tue, 19 May 2015 19:39:56 GMT
# IGNITE-709 Add additional 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/feee7d42
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/feee7d42
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/feee7d42

Branch: refs/heads/ignite-23
Commit: feee7d4219963560ae9d839df3ac29812b025cab
Parents: 0d8f73e
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Mon May 18 18:38:06 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Mon May 18 18:38:06 2015 +0300

----------------------------------------------------------------------
 .../discovery/tcp/TcpDiscoverySpiAdapter.java   |   2 +-
 .../GridDiscoveryManagerAliveCacheSelfTest.java |  12 +-
 .../GridDiscoveryManagerAttributesSelfTest.java | 120 +++++++++++--------
 .../discovery/GridDiscoveryManagerSelfTest.java |  44 +++++--
 .../tcp/TcpClientDiscoverySpiSelfTest.java      |   2 -
 .../testframework/junits/GridAbstractTest.java  |   3 +-
 .../testsuites/IgniteKernalSelfTestSuite.java   |   6 +-
 7 files changed, 124 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/feee7d42/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java
index a89dbcc..e80272e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java
@@ -45,7 +45,7 @@ import java.util.concurrent.atomic.*;
 /**
  * Base class for TCP discovery SPIs.
  */
-abstract class TcpDiscoverySpiAdapter extends IgniteSpiAdapter implements DiscoverySpi {
+public abstract class TcpDiscoverySpiAdapter extends IgniteSpiAdapter implements DiscoverySpi
{
     /** Default port to listen (value is <tt>47500</tt>). */
     public static final int DFLT_PORT = 47500;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/feee7d42/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
index b36c6f1..da1e1d7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
@@ -86,7 +86,12 @@ public class GridDiscoveryManagerAliveCacheSelfTest extends GridCommonAbstractTe
         cCfg.setRebalanceMode(SYNC);
         cCfg.setWriteSynchronizationMode(FULL_SYNC);
 
-        TcpDiscoverySpi disc = new TcpDiscoverySpi();
+        TcpDiscoverySpiAdapter disc;
+
+        if (((gridName.charAt(gridName.length() - 1) - '0') & 1) == 0)
+            disc = new TcpDiscoverySpi();
+        else
+            disc = new TcpClientDiscoverySpi();
 
         disc.setIpFinder(IP_FINDER);
 
@@ -148,7 +153,12 @@ public class GridDiscoveryManagerAliveCacheSelfTest extends GridCommonAbstractTe
      */
     @SuppressWarnings("BusyWait")
     private void awaitDiscovery(long nodesCnt) throws InterruptedException {
+        Thread.sleep(50);
+
         for (Ignite g : alive) {
+            if (g.configuration().getDiscoverySpi() instanceof TcpClientDiscoverySpi)
+                ((TcpClientDiscoverySpi)g.configuration().getDiscoverySpi()).waitForMessagePrecessed();
+
             while (g.cluster().nodes().size() != nodesCnt)
                 Thread.sleep(10);
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/feee7d42/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
index 538ea39..77e6d52 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.managers.discovery;
 
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
+import org.apache.ignite.spi.discovery.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
@@ -29,7 +30,7 @@ import static org.apache.ignite.configuration.DeploymentMode.*;
 /**
  * Tests for node attributes consistency checks.
  */
-public class GridDiscoveryManagerAttributesSelfTest extends GridCommonAbstractTest {
+public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonAbstractTest
{
     /** */
     private static final String PREFER_IPV4 = "java.net.preferIPv4Stack";
 
@@ -46,18 +47,34 @@ public class GridDiscoveryManagerAttributesSelfTest extends GridCommonAbstractTe
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        TcpDiscoverySpi disc = new TcpDiscoverySpi();
-
-        disc.setIpFinder(IP_FINDER);
+        if (gridName.equals(getTestGridName(1)))
+            cfg.setClientMode(true);
 
         cfg.setIncludeProperties(PREFER_IPV4);
         cfg.setDeploymentMode(mode);
         cfg.setPeerClassLoadingEnabled(p2pEnabled);
-        cfg.setDiscoverySpi(disc);
+        cfg.setDiscoverySpi(createDiscovery(cfg));
 
         return cfg;
     }
 
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @return Discovery SPI.
+     * @param cfg DiscoverySpi
+     */
+    protected DiscoverySpi createDiscovery(IgniteConfiguration cfg) {
+        TcpDiscoverySpi disc = new TcpDiscoverySpi();
+
+        disc.setIpFinder(IP_FINDER);
+
+        return disc;
+    }
+
     /**
      * @throws Exception If failed.
      */
@@ -83,44 +100,34 @@ public class GridDiscoveryManagerAttributesSelfTest extends GridCommonAbstractTe
      * @throws Exception If failed.
      */
     public void testPreferIpV4StackDifferentValues() throws Exception {
-        try {
-            System.setProperty(PREFER_IPV4, "true");
+        System.setProperty(PREFER_IPV4, "true");
 
-            for (int i = 0; i < 2; i++) {
-                Ignite g = startGrid(i);
+        for (int i = 0; i < 2; i++) {
+            Ignite g = startGrid(i);
 
-                assert "true".equals(g.cluster().localNode().attribute(PREFER_IPV4));
-            }
+            assert "true".equals(g.cluster().localNode().attribute(PREFER_IPV4));
+        }
 
-            System.setProperty(PREFER_IPV4, "false");
+        System.setProperty(PREFER_IPV4, "false");
 
-            startGrid(2);
-        }
-        finally {
-            stopAllGrids();
-        }
+        startGrid(2);
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testDifferentDeploymentModes() throws Exception {
-        try {
-            startGrid(1);
+        startGrid(0);
 
-            mode = CONTINUOUS;
+        mode = CONTINUOUS;
 
-            try {
-                startGrid(2);
+        try {
+            startGrid(1);
 
-                fail();
-            }
-            catch (IgniteCheckedException e) {
-                assertTrue(e.getCause().getMessage().startsWith("Remote node has deployment
mode different from"));
-            }
+            fail();
         }
-        finally {
-            stopAllGrids();
+        catch (IgniteCheckedException e) {
+            assertTrue(e.getCause().getMessage().startsWith("Remote node has deployment mode
different from"));
         }
     }
 
@@ -128,23 +135,18 @@ public class GridDiscoveryManagerAttributesSelfTest extends GridCommonAbstractTe
      * @throws Exception If failed.
      */
     public void testDifferentPeerClassLoadingEnabledFlag() throws Exception {
-        try {
-            startGrid(1);
+        startGrid(0);
 
-            p2pEnabled = true;
+        p2pEnabled = true;
 
-            try {
-                startGrid(2);
+        try {
+            startGrid(1);
 
-                fail();
-            }
-            catch (IgniteCheckedException e) {
-                assertTrue(e.getCause().getMessage().startsWith("Remote node has peer class
loading enabled flag " +
-                    "different from"));
-            }
+            fail();
         }
-        finally {
-            stopAllGrids();
+        catch (IgniteCheckedException e) {
+            assertTrue(e.getCause().getMessage().startsWith("Remote node has peer class loading
enabled flag " +
+                "different from"));
         }
     }
 
@@ -153,19 +155,35 @@ public class GridDiscoveryManagerAttributesSelfTest extends GridCommonAbstractTe
      * @throws Exception If failed.
      */
     private void testPreferIpV4Stack(boolean preferIpV4) throws Exception {
-        try {
-            String val = String.valueOf(preferIpV4);
+        String val = String.valueOf(preferIpV4);
 
-            System.setProperty(PREFER_IPV4, val);
+        System.setProperty(PREFER_IPV4, val);
 
-            for (int i = 0; i < 2; i++) {
-                Ignite g = startGrid(i);
+        for (int i = 0; i < 2; i++) {
+            Ignite g = startGrid(i);
 
-                assert val.equals(g.cluster().localNode().attribute(PREFER_IPV4));
-            }
+            assert val.equals(g.cluster().localNode().attribute(PREFER_IPV4));
         }
-        finally {
-            stopAllGrids();
+    }
+
+    /**
+     *
+     */
+    public static class RegularDiscovery extends GridDiscoveryManagerAttributesSelfTest {
+        // No-op.
+    }
+
+    /**
+     *
+     */
+    public static class ClientDiscovery extends GridDiscoveryManagerAttributesSelfTest {
+        /** {@inheritDoc}
+         * @param cfg*/
+        @Override protected DiscoverySpi createDiscovery(IgniteConfiguration cfg) {
+            if (Boolean.TRUE.equals(cfg.isClientMode()))
+                return createClientDiscovery(IP_FINDER);
+
+            return super.createDiscovery(cfg);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/feee7d42/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
index be5b9c6..2fdc084 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
@@ -23,6 +23,7 @@ import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.lang.*;
+import org.apache.ignite.spi.discovery.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
@@ -33,7 +34,7 @@ import static org.apache.ignite.cache.CacheMode.*;
 /**
  *
  */
-public class GridDiscoveryManagerSelfTest extends GridCommonAbstractTest {
+public abstract class GridDiscoveryManagerSelfTest extends GridCommonAbstractTest {
     /** */
     private static final String CACHE_NAME = "cache";
 
@@ -50,12 +51,6 @@ public class GridDiscoveryManagerSelfTest extends GridCommonAbstractTest
{
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        TcpDiscoverySpi disc = new TcpDiscoverySpi();
-
-        disc.setIpFinder(IP_FINDER);
-
-        cfg.setDiscoverySpi(disc);
-
         CacheConfiguration ccfg1 = defaultCacheConfiguration();
 
         ccfg1.setName(CACHE_NAME);
@@ -76,10 +71,24 @@ public class GridDiscoveryManagerSelfTest extends GridCommonAbstractTest
{
             cfg.setCacheConfiguration(ccfg1, ccfg2);
         }
 
+        cfg.setDiscoverySpi(createDiscovery(cfg));
+
         return cfg;
     }
 
     /**
+     * @return Discovery SPI.
+     * @param cfg DiscoverySpi
+     */
+    protected DiscoverySpi createDiscovery(IgniteConfiguration cfg) {
+        TcpDiscoverySpi disc = new TcpDiscoverySpi();
+
+        disc.setIpFinder(IP_FINDER);
+
+        return disc;
+    }
+
+    /**
      * @throws Exception If failed.
      */
     public void testHasNearCache() throws Exception {
@@ -187,4 +196,25 @@ public class GridDiscoveryManagerSelfTest extends GridCommonAbstractTest
{
         assertTrue(g0.context().discovery().hasNearCache(null, four));
         assertFalse(g0.context().discovery().hasNearCache(null, five));
     }
+
+    /**
+     *
+     */
+    public static class RegularDiscovery extends GridDiscoveryManagerSelfTest {
+        // No-op.
+    }
+
+    /**
+     *
+     */
+    public static class ClientDiscovery extends GridDiscoveryManagerSelfTest {
+        /** {@inheritDoc}
+         * @param cfg*/
+        @Override protected DiscoverySpi createDiscovery(IgniteConfiguration cfg) {
+            if (Boolean.TRUE.equals(cfg.isClientMode()))
+                return createClientDiscovery(IP_FINDER);
+
+            return super.createDiscovery(cfg);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/feee7d42/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
index ba8200e..d534d6a 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
@@ -102,8 +102,6 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest
{
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        cfg.setLocalHost("127.0.0.1");
-
         if (gridName.startsWith("server")) {
             TcpDiscoverySpi disco = new TcpDiscoverySpi();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/feee7d42/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 37a5dc5..dd7073d 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
@@ -676,7 +676,8 @@ public abstract class GridAbstractTest extends TestCase {
     protected IgniteConfiguration optimize(IgniteConfiguration cfg) throws IgniteCheckedException
{
         // TODO: IGNITE-605: propose another way to avoid network overhead in tests.
         if (cfg.getLocalHost() == null) {
-            if (cfg.getDiscoverySpi() instanceof TcpDiscoverySpi)
+            if (cfg.getDiscoverySpi() instanceof TcpDiscoverySpi
+                || cfg.getDiscoverySpi() instanceof TcpClientDiscoverySpi)
                 cfg.setLocalHost("127.0.0.1");
             else
                 cfg.setLocalHost(getTestResources().getLocalHost());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/feee7d42/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
index 20c32b2..f0080d5 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
@@ -55,9 +55,11 @@ public class IgniteKernalSelfTestSuite extends TestSuite {
         suite.addTestSuite(GridCacheMessageSelfTest.class);
         suite.addTestSuite(GridDeploymentManagerStopSelfTest.class);
         suite.addTestSuite(GridManagerStopSelfTest.class);
-        suite.addTestSuite(GridDiscoveryManagerAttributesSelfTest.class);
+        suite.addTestSuite(GridDiscoveryManagerAttributesSelfTest.RegularDiscovery.class);
+        suite.addTestSuite(GridDiscoveryManagerAttributesSelfTest.ClientDiscovery.class);
         suite.addTestSuite(GridDiscoveryManagerAliveCacheSelfTest.class);
-        suite.addTestSuite(GridDiscoveryManagerSelfTest.class);
+        suite.addTestSuite(GridDiscoveryManagerSelfTest.RegularDiscovery.class);
+        suite.addTestSuite(GridDiscoveryManagerSelfTest.ClientDiscovery.class);
         suite.addTestSuite(GridDiscoveryEventSelfTest.class);
         suite.addTestSuite(GridPortProcessorSelfTest.class);
         suite.addTestSuite(GridHomePathSelfTest.class);


Mime
View raw message