ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/6] incubator-ignite git commit: tests are implemented
Date Thu, 09 Apr 2015 14:22:56 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-709 [created] b5a52210c


tests are implemented


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

Branch: refs/heads/ignite-709
Commit: df0e833d4897b652613dd964a22e3ca914575f31
Parents: 5fcb072
Author: Denis Magda <dmagda@gridgain.com>
Authored: Thu Apr 9 15:45:03 2015 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Thu Apr 9 15:45:03 2015 +0300

----------------------------------------------------------------------
 .../cache/GridCacheAbstractSelfTest.java        |  5 ++
 .../GridCacheClientModesAbstractSelfTest.java   | 29 ++++++++-
 ...ientModesTcpClientDiscoveryAbstractTest.java | 63 ++++++++++++++++++++
 ...idCacheClientOnlyTcpClientDiscoveryTest.java | 37 ++++++++++++
 ...GridCacheNearOnlyTcpClientDiscoveryTest.java | 30 ++++++++++
 5 files changed, 161 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/df0e833d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
index aa0b3d4..2b68f34 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
@@ -336,6 +336,11 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest
{
     }
 
     /**
+     * @return {@code TcpDiscoveryIpFinder} that is used and shared among grids.
+     */
+    protected final TcpDiscoveryIpFinder sharedTcpDiscoveryIpFinder() { return ipFinder;
}
+
+    /**
      * @return Default cache instance.
      */
     @SuppressWarnings({"unchecked"})

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/df0e833d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
index 85256b4..ad8ba5d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
@@ -21,7 +21,6 @@ import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.affinity.rendezvous.*;
 import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.util.typedef.*;
 
@@ -33,15 +32,22 @@ import static org.apache.ignite.cache.CacheMode.*;
  * Tests near-only cache.
  */
 public abstract class GridCacheClientModesAbstractSelfTest extends GridCacheAbstractSelfTest
{
+
+    /** Grids count to start. */
+    private final static int GRIDS_COUNT = 4;
+
     /** Grid cnt. */
     private static AtomicInteger gridCnt;
 
     /** Near-only cache grid name. */
     private static String nearOnlyGridName;
 
+    /** Client's grid start order, i.e. first or last. First by default. */
+    private static boolean startClientLast;
+
     /** {@inheritDoc} */
     @Override protected int gridCount() {
-        return 4;
+        return GRIDS_COUNT;
     }
 
     /** {@inheritDoc} */
@@ -57,8 +63,9 @@ public abstract class GridCacheClientModesAbstractSelfTest extends GridCacheAbst
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
+        int count = gridCnt.incrementAndGet();
 
-        if (gridCnt.getAndIncrement() == 0) {
+        if ((startClientLast && count == GRIDS_COUNT) || (!startClientLast &&
count == 1)) {
             cfg.setClientMode(true);
 
             nearOnlyGridName = gridName;
@@ -99,6 +106,22 @@ public abstract class GridCacheClientModesAbstractSelfTest extends GridCacheAbst
     protected abstract boolean clientOnly();
 
     /**
+     * @return boolean {@code true} if client's grid is started last, {@code false} if it's
started first.
+     */
+    public static boolean isClientStartedLast() {
+        return startClientLast;
+    }
+
+    /**
+     * Sets client's grid start order.
+     *
+     * @param startClientLast {@code true} to start the grid last, {@code false} to start
it first.
+     */
+    public static void startClientLast(boolean startClientLast) {
+        GridCacheClientModesAbstractSelfTest.startClientLast = startClientLast;
+    }
+
+    /**
      * @throws Exception If failed.
      */
     public void testPutFromClientNode() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/df0e833d/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
new file mode 100644
index 0000000..cc80d2e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesTcpClientDiscoveryAbstractTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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 java.net.InetSocketAddress;
+import java.util.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+
+
+/**
+ * Tests TcpClientDiscovery SPI in client modes.
+ */
+public abstract class GridCacheClientModesTcpClientDiscoveryAbstractTest extends GridCacheClientModesAbstractSelfTest
{
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startClientLast(true);
+
+        super.beforeTestsStarted();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        if (cfg.isClientMode() != null && cfg.isClientMode()) {
+            TcpDiscoveryVmIpFinder clientIpFinder = new TcpDiscoveryVmIpFinder();
+
+            ArrayList<String> addrList = new ArrayList<>(sharedTcpDiscoveryIpFinder().getRegisteredAddresses().size());
+
+            for (InetSocketAddress addr : sharedTcpDiscoveryIpFinder().getRegisteredAddresses())
{
+                addrList.add(addr.getHostString() + ":" + addr.getPort());
+            }
+
+            clientIpFinder.setAddresses(addrList);
+
+            TcpClientDiscoverySpi discoverySpi = new TcpClientDiscoverySpi();
+            discoverySpi.setIpFinder(clientIpFinder);
+
+            cfg.setDiscoverySpi(discoverySpi);
+        }
+
+        return cfg;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/df0e833d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientOnlyTcpClientDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientOnlyTcpClientDiscoveryTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientOnlyTcpClientDiscoveryTest.java
new file mode 100644
index 0000000..9de8c3a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientOnlyTcpClientDiscoveryTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.configuration.*;
+
+/**
+ * Tests TcpClientDiscovery SPI in the client mode only.
+ */
+public class GridCacheClientOnlyTcpClientDiscoveryTest extends GridCacheClientModesTcpClientDiscoveryAbstractTest
{
+
+    /** {@inheritDoc} */
+    @Override protected NearCacheConfiguration nearConfiguration() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected boolean clientOnly() {
+        return true;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/df0e833d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNearOnlyTcpClientDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNearOnlyTcpClientDiscoveryTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNearOnlyTcpClientDiscoveryTest.java
new file mode 100644
index 0000000..d53358e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNearOnlyTcpClientDiscoveryTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/**
+ * Tests TcpClientDiscovery SPI in the client mode with the near cache enabled.
+ */
+public class GridCacheNearOnlyTcpClientDiscoveryTest extends GridCacheClientModesTcpClientDiscoveryAbstractTest
{
+
+    /** {@inheritDoc} */
+    @Override protected boolean clientOnly() {
+        return false;
+    }
+
+}


Mime
View raw message