ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [17/28] incubator-ignite git commit: IGNITE-709 Fix tests.
Date Thu, 21 May 2015 07:53:16 GMT
IGNITE-709 Fix 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/ce20aec3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ce20aec3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ce20aec3

Branch: refs/heads/ignite-23
Commit: ce20aec3c8046bb3635893ec181ba027691db638
Parents: 9d4d01c
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Wed May 20 16:41:45 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Wed May 20 16:41:45 2015 +0300

----------------------------------------------------------------------
 .../continuous/GridContinuousProcessor.java     |  2 +-
 .../discovery/tcp/TcpClientDiscoverySpi.java    |  2 +-
 .../IgniteClientDataStructuresAbstractTest.java |  6 +--
 ...ientModesTcpClientDiscoveryAbstractTest.java |  9 ++--
 ...pClientDiscoveryMarshallerCheckSelfTest.java | 16 +++----
 .../tcp/TcpDiscoveryConcurrentStartTest.java    | 45 ++++++++++++++------
 .../ignite/testframework/GridTestUtils.java     | 15 +++++++
 .../testframework/junits/GridAbstractTest.java  | 19 +++++++--
 .../junits/common/GridCommonAbstractTest.java   | 31 --------------
 .../IgniteSpiDiscoverySelfTestSuite.java        |  2 +
 10 files changed, 81 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ce20aec3/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
index 1b204a6..d67a45a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
@@ -168,7 +168,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
         ctx.discovery().setCustomEventListener(StartRoutineDiscoveryMessage.class,
             new CustomEventListener<StartRoutineDiscoveryMessage>() {
                 @Override public void onCustomEvent(ClusterNode snd, StartRoutineDiscoveryMessage
msg) {
-                    if (!snd.id().equals(ctx.localNodeId()))
+                    if (!snd.id().equals(ctx.localNodeId()) && !ctx.isStopping())
                         processStartRequest(snd, msg);
                 }
             });

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ce20aec3/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
index 7097e1b..e4c5147 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
@@ -1461,7 +1461,7 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements
Tcp
          * @param msg Message.
          */
         private void processCustomMessage(TcpDiscoveryCustomEventMessage msg) {
-            if (msg.verified()) {
+            if (msg.verified() && joinLatch.getCount() == 0) {
                 DiscoverySpiListener lsnr = TcpClientDiscoverySpi.this.lsnr;
 
                 if (lsnr != null) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ce20aec3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
index 36f1910..21233cc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
@@ -43,16 +43,14 @@ public abstract class IgniteClientDataStructuresAbstractTest extends GridCommonA
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
-
         if (gridName.equals(getTestGridName(NODE_CNT - 1))) {
             cfg.setClientMode(true);
 
             if (clientDiscovery())
-                cfg.setDiscoverySpi(createClientDiscovery(ipFinder));
+                cfg.setDiscoverySpi(new TcpClientDiscoverySpi());
         }
 
-        cfg.setLocalHost("127.0.0.1");
+        ((TcpDiscoverySpiAdapter)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
 
         return cfg;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ce20aec3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesTcpClientDiscoveryAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesTcpClientDiscoveryAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesTcpClientDiscoveryAbstractTest.java
index 127c150..62dbb18 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesTcpClientDiscoveryAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesTcpClientDiscoveryAbstractTest.java
@@ -37,10 +37,13 @@ public abstract class GridCacheClientModesTcpClientDiscoveryAbstractTest
extends
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        if (cfg.isClientMode() != null && cfg.isClientMode())
-            cfg.setDiscoverySpi(createClientDiscovery(ipFinder));
+        if (cfg.isClientMode() != null && cfg.isClientMode()) {
+            TcpClientDiscoverySpi discoverySpi = new TcpClientDiscoverySpi();
 
-        cfg.setLocalHost("127.0.0.1");
+            discoverySpi.setIpFinder(ipFinder);
+
+            cfg.setDiscoverySpi(discoverySpi);
+        }
 
         return cfg;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ce20aec3/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
index 78435fd..ad61755 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
@@ -37,23 +37,23 @@ public class TcpClientDiscoveryMarshallerCheckSelfTest extends GridCommonAbstrac
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg =  super.getConfiguration(gridName);
 
-        if (gridName.endsWith("0")) {
-            TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
-            discoSpi.setIpFinder(ipFinder);
-
-            cfg.setDiscoverySpi(discoSpi);
+        TcpDiscoverySpiAdapter discoSpi;
 
-            cfg.setLocalHost("127.0.0.1");
+        if (gridName.endsWith("0")) {
+            discoSpi = new TcpDiscoverySpi();
 
             cfg.setMarshaller(new JdkMarshaller());
         }
         else {
-            cfg.setDiscoverySpi(createClientDiscovery(ipFinder));
+            discoSpi = new TcpClientDiscoverySpi();
 
             cfg.setMarshaller(new OptimizedMarshaller());
         }
 
+        discoSpi.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(discoSpi);
+
         return cfg;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ce20aec3/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryConcurrentStartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryConcurrentStartTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryConcurrentStartTest.java
index f79c24b..67566a8 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryConcurrentStartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryConcurrentStartTest.java
@@ -20,14 +20,19 @@ package org.apache.ignite.spi.discovery.tcp;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
+import org.jetbrains.annotations.*;
+
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
 
 /**
  * Test for {@link TcpDiscoverySpi}.
  */
 public class TcpDiscoveryConcurrentStartTest extends GridCommonAbstractTest {
     /** */
-    private static final int TOP_SIZE = 1;
+    private static final int TOP_SIZE = 3;
 
     /** */
     private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
@@ -39,17 +44,11 @@ public class TcpDiscoveryConcurrentStartTest extends GridCommonAbstractTest
{
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg =  super.getConfiguration(gridName);
 
-        if (client)
-            cfg.setDiscoverySpi(createClientDiscovery(ipFinder));
-        else {
-            TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
-            discoSpi.setIpFinder(ipFinder);
+        TcpDiscoverySpiAdapter discoSpi = client ? new TcpClientDiscoverySpi() : new TcpDiscoverySpi();
 
-            cfg.setDiscoverySpi(discoSpi);
-        }
+        discoSpi.setIpFinder(ipFinder);
 
-        cfg.setLocalHost("127.0.0.1");
+        cfg.setDiscoverySpi(discoSpi);
 
         cfg.setCacheConfiguration();
 
@@ -61,11 +60,16 @@ public class TcpDiscoveryConcurrentStartTest extends GridCommonAbstractTest
{
         return Long.MAX_VALUE;
     }
 
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        client = false;
+    }
+
     /**
      * @throws Exception If failed.
      */
     public void testConcurrentStart() throws Exception {
-        for (int i = 0; i < 50; i++) {
+        for (int i = 0; i < 10; i++) {
             try {
                 startGridsMultiThreaded(TOP_SIZE);
             }
@@ -79,15 +83,28 @@ public class TcpDiscoveryConcurrentStartTest extends GridCommonAbstractTest
{
      * @throws Exception If failed.
      */
     public void testConcurrentStartClients() throws Exception {
-        for (int i = 0; i < 50; i++) {
+        for (int i = 0; i < 20; i++) {
             try {
                 client = false;
 
-                startGrid();
+                startGrid(0);
 
                 client = true;
 
-                startGridsMultiThreaded(TOP_SIZE);
+                final AtomicInteger gridIdx = new AtomicInteger(1);
+
+                GridTestUtils.runMultiThreaded(new Callable<Object>() {
+                        @Nullable @Override public Object call() throws Exception {
+                            startGrid(gridIdx.getAndIncrement());
+
+                            return null;
+                        }
+                    },
+                    TOP_SIZE,
+                    "grid-starter-" + getName()
+                );
+
+                checkTopology(TOP_SIZE + 1);
             }
             finally {
                 stopAllGrids();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ce20aec3/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
index e25aaee..435ff46 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
@@ -1495,4 +1495,19 @@ public final class GridTestUtils {
     public static String apacheIgniteTestPath() {
         return System.getProperty("IGNITE_TEST_PATH", U.getIgniteHome() + "/target/ignite");
     }
+
+    /**
+     * {@link Class#getSimpleName()} does not return outer class name prefix for inner classes,
for example,
+     * getSimpleName() returns "RegularDiscovery" instead of "GridDiscoveryManagerSelfTest$RegularDiscovery"
+     * This method return correct simple name for inner classes.
+     *
+     * @param cls Class
+     * @return Simple name with outer class prefix.
+     */
+    public static String fullSimpleName(@NotNull Class cls) {
+        if (cls.getEnclosingClass() != null)
+            return cls.getEnclosingClass().getSimpleName() + "." + cls.getSimpleName();
+        else
+            return cls.getSimpleName();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ce20aec3/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 be849f0..0ecee09 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
@@ -455,7 +455,7 @@ public abstract class GridAbstractTest extends TestCase {
         }
 
         if (isFirstTest()) {
-            info(">>> Starting test class: " + getClass().getSimpleName() + " <<<");
+            info(">>> Starting test class: " + GridTestUtils.fullSimpleName(getClass())
+ " <<<");
 
             if (startGrid) {
                 IgniteConfiguration cfg = optimize(getConfiguration());
@@ -736,9 +736,20 @@ public abstract class GridAbstractTest extends TestCase {
      * @param cancel Cancel flag.
      */
     protected void stopAllGrids(boolean cancel) {
-        List<Ignite> ignites = G.allGrids();
+        Collection<Ignite> clients = new ArrayList<>();
+        Collection<Ignite> srvs = new ArrayList<>();
+
+        for (Ignite g : G.allGrids()) {
+            if (g.configuration().getDiscoverySpi() instanceof TcpClientDiscoverySpi)
+                clients.add(g);
+            else
+                srvs.add(g);
+        }
+
+        for (Ignite g : clients)
+            stopGrid(g.name(), cancel);
 
-        for (Ignite g : ignites)
+        for (Ignite g : srvs)
             stopGrid(g.name(), cancel);
 
         assert G.allGrids().isEmpty();
@@ -1205,7 +1216,7 @@ public abstract class GridAbstractTest extends TestCase {
             serializedObj.clear();
 
             if (isLastTest()) {
-                info(">>> Stopping test class: " + getClass().getSimpleName() +
" <<<");
+                info(">>> Stopping test class: " + GridTestUtils.fullSimpleName(getClass())
+ " <<<");
 
                 TestCounters counters = getTestCounters();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ce20aec3/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 c8a256f..3c54efe 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
@@ -34,16 +34,12 @@ import org.apache.ignite.internal.processors.cache.local.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
-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.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.*;
 import javax.cache.integration.*;
 import javax.net.ssl.*;
-import java.net.*;
 import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
@@ -853,33 +849,6 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest
{
     }
 
     /**
-     * Create TcpClientDiscoverySpi configured to connect to last started server.
-     *
-     * @param srvIpFinder IpFinder that was provided to servers. Used to obtain addreses
to connect.
-     */
-    protected static TcpClientDiscoverySpi createClientDiscovery(TcpDiscoveryIpFinder srvIpFinder)
{
-        TcpDiscoveryVmIpFinder clientFinder = new TcpDiscoveryVmIpFinder();
-
-        Collection<InetSocketAddress> srvAddrs = srvIpFinder.getRegisteredAddresses();
-
-        if (srvAddrs.isEmpty())
-            throw new IgniteException("Failed to create client IpFinder, no server addresses
registered.");
-
-        String firstSrvAddr = F.first(srvAddrs).toString();
-
-        if (firstSrvAddr.startsWith("/"))
-            firstSrvAddr = firstSrvAddr.substring(1);
-
-        clientFinder.setAddresses(Collections.singletonList(firstSrvAddr));
-
-        TcpClientDiscoverySpi res = new TcpClientDiscoverySpi();
-
-        res.setIpFinder(clientFinder);
-
-        return res;
-    }
-
-    /**
      * In ATOMIC cache with CLOCK mode if key is updated from different nodes at same time
      * only one update wins others are ignored (can happen in test event when updates are
executed from
      * different nodes sequentially), this delay is used to avoid lost updates.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ce20aec3/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
index 8bf8dbc..ec5ebc3 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
@@ -55,6 +55,8 @@ public class IgniteSpiDiscoverySelfTestSuite extends TestSuite {
         suite.addTest(new TestSuite(TcpClientDiscoverySpiConfigSelfTest.class));
         suite.addTest(new TestSuite(TcpClientDiscoveryMarshallerCheckSelfTest.class));
 
+        suite.addTest(new TestSuite(TcpDiscoveryConcurrentStartTest.class));
+
         return suite;
     }
 }


Mime
View raw message