Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DD09A17896 for ; Fri, 24 Apr 2015 17:53:53 +0000 (UTC) Received: (qmail 31730 invoked by uid 500); 24 Apr 2015 17:53:53 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 31701 invoked by uid 500); 24 Apr 2015 17:53:53 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 31692 invoked by uid 99); 24 Apr 2015 17:53:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Apr 2015 17:53:53 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of root@apache.org designates 54.76.25.247 as permitted sender) Received: from [54.76.25.247] (HELO mx1-eu-west.apache.org) (54.76.25.247) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Apr 2015 17:53:27 +0000 Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id 0EB6F26201 for ; Fri, 24 Apr 2015 17:52:37 +0000 (UTC) Received: (qmail 25251 invoked by uid 99); 24 Apr 2015 17:52:33 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Apr 2015 17:52:33 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C8566E0911; Fri, 24 Apr 2015 17:52:33 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: akuznetsov@apache.org To: commits@ignite.incubator.apache.org Date: Fri, 24 Apr 2015 17:53:20 -0000 Message-Id: <84f8e40337ab4a6ebc4ef47f64a67804@git.apache.org> In-Reply-To: <90d796ee11af4a5d803d3081b1a3eff3@git.apache.org> References: <90d796ee11af4a5d803d3081b1a3eff3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [48/50] incubator-ignite git commit: # ignite-sprint-4 added test X-Virus-Checked: Checked by ClamAV on apache.org # 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 Authored: Fri Apr 24 12:42:30 2015 +0300 Committer: sboikov 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 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() { + @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 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(); } } - }