ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [48/50] incubator-ignite git commit: # ignite-sprint-4 added test
Date Fri, 24 Apr 2015 17:53:20 GMT
# ignite-sprint-4 added test


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

Branch: refs/heads/ignite-789
Commit: b4b28fd62d2ff7015de8d732cceff48acb89ee19
Parents: 0005e1b
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Apr 24 12:42:30 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Apr 24 12:42:30 2015 +0300

----------------------------------------------------------------------
 .../CacheNoValueClassOnServerNodeTest.java      | 129 +++++++++++++++++++
 .../ignite/testsuites/IgniteCacheTestSuite.java |   2 +
 .../CacheNoValueClassOnServerTestClient.java    |  88 +++++++++++++
 .../apache/ignite/tests/p2p/cache/Person.java   |  42 ++++++
 .../CacheConfigurationP2PTestClient.java        |   1 -
 5 files changed, 261 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4b28fd6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
new file mode 100644
index 0000000..876fbb4
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
@@ -0,0 +1,129 @@
+/*
+ * 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.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.util.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.util.*;
+import java.util.concurrent.*;
+
+import static java.util.concurrent.TimeUnit.*;
+
+/**
+ *
+ */
+public class CacheNoValueClassOnServerNodeTest extends GridCommonAbstractTest {
+    /** */
+    public static final String NODE_START_MSG = "Test external node started";
+
+    /** */
+    private static final String CLIENT_CLS_NAME =
+        "org.apache.ignite.tests.p2p.cache.CacheNoValueClassOnServerTestClient";
+
+    /**
+     * @return Configuration.
+     */
+    private IgniteConfiguration createConfiguration() {
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        cfg.setPeerClassLoadingEnabled(false);
+
+        cfg.setLocalHost("127.0.0.1");
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinderCleanFrequency(1000);
+
+        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
+
+        ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));
+
+        disco.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(disco);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNoValueClassOnServerNode() throws Exception {
+        // Check class is really not available.
+        try {
+            Class.forName("org.apache.ignite.tests.p2p.cache.Person");
+
+            fail();
+        }
+        catch (ClassNotFoundException ignore) {
+            // Expected exception.
+        }
+
+        try (Ignite ignite = Ignition.start(createConfiguration())) {
+            CacheConfiguration cfg = new CacheConfiguration();
+
+            cfg.setCopyOnRead(true); // To store only value bytes.
+
+            ignite.createCache(cfg);
+
+            final CountDownLatch clientReadyLatch = new CountDownLatch(1);
+
+            Collection<String> jvmArgs = Arrays.asList("-ea", "-DIGNITE_QUIET=false");
+
+            GridJavaProcess clientNode = null;
+
+            try {
+                String cp = U.getIgniteHome() + "/modules/extdata/p2p/target/classes/";
+
+                clientNode = GridJavaProcess.exec(
+                    CLIENT_CLS_NAME, null,
+                    log,
+                    new CI1<String>() {
+                        @Override public void apply(String s) {
+                            info("Client node: " + s);
+
+                            if (s.contains(NODE_START_MSG))
+                                clientReadyLatch.countDown();
+                        }
+                    },
+                    null,
+                    jvmArgs,
+                    cp
+                );
+
+                assertTrue(clientReadyLatch.await(60, SECONDS));
+
+                int exitCode = clientNode.getProcess().waitFor();
+
+                assertEquals("Unexpected exit code", 0, exitCode);
+            }
+            finally {
+                if (clientNode != null)
+                    clientNode.killProcess();
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4b28fd6/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 7fbe564..6e70052 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -447,6 +447,8 @@ public class IgniteCacheTestSuite extends TestSuite {
 
         suite.addTestSuite(IgniteExchangeFutureHistoryTest.class);
 
+        suite.addTestSuite(CacheNoValueClassOnServerNodeTest.class);
+
         return suite;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4b28fd6/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
new file mode 100644
index 0000000..3142198
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
@@ -0,0 +1,88 @@
+/*
+ * 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.tests.p2p.cache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+
+import java.util.*;
+
+/**
+ *
+ */
+public class CacheNoValueClassOnServerTestClient {
+    /**
+     * @param args Arguments.
+     * @throws Exception If failed.
+     */
+    public static void main(String[] args) throws Exception {
+        System.out.println("Starting test client node.");
+
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        cfg.setPeerClassLoadingEnabled(false);
+
+        cfg.setClientMode(true);
+
+        cfg.setLocalHost("127.0.0.1");
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
+
+        ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));
+
+        disco.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(disco);
+
+        U.setWorkDirectory(null, U.getIgniteHome());
+
+        try (Ignite ignite = Ignition.start(cfg)) {
+            System.out.println("Test external node started");
+
+            int nodes = ignite.cluster().nodes().size();
+
+            if (nodes != 2)
+                throw new Exception("Unexpected nodes number: " + nodes);
+
+            IgniteCache<Integer, Person> cache = ignite.cache(null);
+
+            for (int i = 0; i < 100; i++)
+                cache.put(i, new Person("name-" + i));
+
+            for (int i = 0; i < 100; i++) {
+                Person p = cache.get(i);
+
+                if (p == null)
+                    throw new Exception("Null result key: " + i);
+
+                String expName = "name-" + i;
+
+                if (!expName.equals(p.name()))
+                    throw new Exception("Unexpected data: " + p.name());
+
+                if (i % 10 == 0)
+                    System.out.println("Get expected value: " + p.name());
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4b28fd6/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/Person.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/Person.java
b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/Person.java
new file mode 100644
index 0000000..6bfe1fd
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/Person.java
@@ -0,0 +1,42 @@
+/*
+ * 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.tests.p2p.cache;
+
+import java.io.*;
+
+/**
+ *
+ */
+public class Person implements Serializable {
+    /** */
+    private String name;
+
+    /**
+     * @param name Name.
+     */
+    public Person(String name) {
+        this.name = name;
+    }
+
+    /**
+     * @return Name.
+     */
+    public String name() {
+        return name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4b28fd6/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java
b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java
index 4550e21..eea3a9b 100644
--- a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java
@@ -114,5 +114,4 @@ public class CacheConfigurationP2PTestClient {
             cache2.close();
         }
     }
-
 }


Mime
View raw message