ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [05/50] [abbrv] ignite git commit: Added test.
Date Fri, 22 Apr 2016 12:29:47 GMT
Added test.


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

Branch: refs/heads/ignite-db-x-10884
Commit: d09ef6c0f6acace146cf4012dc40b4de33fb6f61
Parents: c173973
Author: sboikov <sboikov@gridgain.com>
Authored: Thu Apr 7 10:26:00 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Thu Apr 7 10:26:00 2016 +0300

----------------------------------------------------------------------
 .../discovery/GridDiscoveryManager.java         |   2 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    |   2 +-
 ...ffinityAssignmentNodeJoinValidationTest.java | 134 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite5.java       |   2 +
 4 files changed, 138 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d09ef6c0/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 7f02498..dc664a8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -1066,7 +1066,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
 
             boolean rmtLateAssign;
 
-            if (n.version().compareTo(CacheAffinitySharedManager.LATE_AFF_ASSIGN_SINCE) >=
0)
+            if (n.version().compareToIgnoreTimestamp(CacheAffinitySharedManager.LATE_AFF_ASSIGN_SINCE)
>= 0)
                 rmtLateAssign = n.attribute(ATTR_LATE_AFFINITY_ASSIGNMENT);
             else
                 rmtLateAssign = false;

http://git-wip-us.apache.org/repos/asf/ignite/blob/d09ef6c0/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 27a31c4..75430c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -3260,7 +3260,7 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                 boolean rmtLateAssignBool;
 
-                if (node.version().compareTo(CacheAffinitySharedManager.LATE_AFF_ASSIGN_SINCE)
>= 0) {
+                if (node.version().compareToIgnoreTimestamp(CacheAffinitySharedManager.LATE_AFF_ASSIGN_SINCE)
>= 0) {
                     Boolean rmtLateAssign = node.attribute(ATTR_LATE_AFFINITY_ASSIGNMENT);
                     // Can be null only in tests.
                     rmtLateAssignBool = rmtLateAssign != null ? rmtLateAssign : false;

http://git-wip-us.apache.org/repos/asf/ignite/blob/d09ef6c0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentNodeJoinValidationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentNodeJoinValidationTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentNodeJoinValidationTest.java
new file mode 100644
index 0000000..247669b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentNodeJoinValidationTest.java
@@ -0,0 +1,134 @@
+/*
+ * 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.cache.distributed;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.spi.IgniteSpiException;
+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;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class CacheLateAffinityAssignmentNodeJoinValidationTest extends GridCommonAbstractTest
{
+    /** */
+    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private boolean lateAff;
+
+    /** */
+    private boolean client;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setLateAffinityAssignment(lateAff);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+        cfg.setClientMode(client);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        super.afterTest();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testJoinValidation1() throws Exception {
+        checkNodeJoinValidation(false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testJoinValidation2() throws Exception {
+        checkNodeJoinValidation(true);
+    }
+
+    /**
+     * @param firstEnabled Flag value for first started node.
+     * @throws Exception If failed.
+     */
+    public void checkNodeJoinValidation(boolean firstEnabled) throws Exception {
+        lateAff = firstEnabled;
+
+        Ignite ignite = startGrid(0);
+
+        assertFalse(ignite.configuration().isClientMode());
+
+        lateAff = !firstEnabled;
+
+        try {
+            startGrid(1);
+
+            fail();
+        }
+        catch (Exception e) {
+            checkError(e);
+        }
+
+        client = true;
+
+        try {
+            startGrid(1);
+
+            fail();
+        }
+        catch (Exception e) {
+            checkError(e);
+        }
+
+        assertEquals(1, ignite.cluster().nodes().size());
+
+        lateAff = firstEnabled;
+
+        client = false;
+
+        startGrid(1);
+
+        client = true;
+
+        Ignite client = startGrid(2);
+
+        assertTrue(client.configuration().isClientMode());
+    }
+
+    /**
+     * @param e Error.
+     */
+    private void checkError(Exception e) {
+        IgniteSpiException err = X.cause(e, IgniteSpiException.class);
+
+        assertNotNull(err);
+        assertTrue(err.getMessage().contains("Local node's cache affinity assignment mode
differs " +
+            "from the same property on remote node"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/d09ef6c0/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
index 0c24425..35c599e 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheSwapSpaceSpiConsiste
 import org.apache.ignite.internal.processors.cache.IgniteCachePutStackOverflowSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheStoreCollectionTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheLateAffinityAssignmentFairAffinityTest;
+import org.apache.ignite.internal.processors.cache.distributed.CacheLateAffinityAssignmentNodeJoinValidationTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheLateAffinityAssignmentTest;
 import org.apache.ignite.internal.processors.cache.store.IgniteCacheWriteBehindNoUpdateSelfTest;
 
@@ -47,6 +48,7 @@ public class IgniteCacheTestSuite5 extends TestSuite {
 
         suite.addTestSuite(CacheLateAffinityAssignmentTest.class);
         suite.addTestSuite(CacheLateAffinityAssignmentFairAffinityTest.class);
+        suite.addTestSuite(CacheLateAffinityAssignmentNodeJoinValidationTest.class);
 
         return suite;
     }


Mime
View raw message