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 780A418682 for ; Wed, 10 Feb 2016 11:55:49 +0000 (UTC) Received: (qmail 69483 invoked by uid 500); 10 Feb 2016 11:55:49 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 69402 invoked by uid 500); 10 Feb 2016 11:55:49 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 68028 invoked by uid 99); 10 Feb 2016 11:55:48 -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; Wed, 10 Feb 2016 11:55:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BA99CE56E3; Wed, 10 Feb 2016 11:55:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.apache.org Date: Wed, 10 Feb 2016 11:56:25 -0000 Message-Id: <9950d342ff284897b48ae08379a8e420@git.apache.org> In-Reply-To: <7d5fd251648d493fb75744e22b1bf108@git.apache.org> References: <7d5fd251648d493fb75744e22b1bf108@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [38/50] [abbrv] ignite git commit: Improved CacheStore + external class loader tests Improved CacheStore + external class loader tests Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bf3a5ea6 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bf3a5ea6 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bf3a5ea6 Branch: refs/heads/ignite-1786 Commit: bf3a5ea652a9c36e5ce8dd87dba72b5fafc3ce86 Parents: bad0420 Author: Denis Magda Authored: Mon Feb 8 13:41:38 2016 +0300 Committer: Denis Magda Committed: Mon Feb 8 13:41:38 2016 +0300 ---------------------------------------------------------------------- .../GridCacheReplicatedPreloadSelfTest.java | 120 +++++++++++++------ 1 file changed, 82 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/bf3a5ea6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java index 523f641..887fea4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java @@ -77,6 +77,9 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { private volatile boolean isClient = false; /** */ + private volatile boolean useExtClassLoader = false; + + /** */ private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); /** {@inheritDoc} */ @@ -108,7 +111,8 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { cfg.setEventStorageSpi(spi); - if (getTestGridName(1).equals(gridName) || cfg.getMarshaller() instanceof BinaryMarshaller) + if (getTestGridName(1).equals(gridName) || useExtClassLoader || + cfg.getMarshaller() instanceof BinaryMarshaller) cfg.setClassLoader(getExternalClassLoader()); if (isClient) @@ -187,7 +191,7 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { for (int i = 0; i < 3; i++) { evts = g2.events().localQuery(F.alwaysTrue(), - EVT_CACHE_REBALANCE_STARTED, EVT_CACHE_REBALANCE_STOPPED); + EVT_CACHE_REBALANCE_STARTED, EVT_CACHE_REBALANCE_STOPPED); if (evts.size() != 2) { info("Wrong events collection size (will retry in 1000 ms): " + evts.size()); @@ -284,7 +288,7 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { assert v3 != null; assert v3.toString().equals(v1.toString()); assert !v3.getClass().getClassLoader().equals(getClass().getClassLoader()); - assert v3.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader")|| + assert v3.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader") || grid(3).configuration().getMarshaller() instanceof BinaryMarshaller; } finally { @@ -297,70 +301,110 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { */ public void testStore() throws Exception { try { + needStore = true; + useExtClassLoader = true; + Ignite g1 = startGrid(1); - if (g1.configuration().getMarshaller() instanceof BinaryMarshaller) { - stopAllGrids(); + Ignite g2 = startGrid(2); // Checks deserialization at node join. - needStore = true; + isClient = true; - g1 = startGrid(1); + Ignite g3 = startGrid(3); + + IgniteCache cache1 = g1.cache(null); + IgniteCache cache2 = g2.cache(null); + IgniteCache cache3 = g3.cache(null); + + cache1.put(1, 1); + + assertEquals(1, cache2.get(1)); + assertEquals(1, cache3.get(1)); + } + finally { + needStore = false; + isClient = false; + useExtClassLoader = false; + } + } + + /** + * @throws Exception If test failed. + */ + public void testStoreDynamicStart() throws Exception { + try { + needStore = false; + useExtClassLoader = true; - ClassLoader ldr = grid(1).configuration().getClassLoader(); + Ignite g1 = startGrid(1); + Ignite g2 = startGrid(2); - CacheConfiguration cfg = defaultCacheConfiguration(); + isClient = true; - Ignite g2 = startGrid(2); // Checks deserialization at node join. + Ignite g3 = startGrid(3); - isClient = true; + Object sf = getExternalClassLoader().loadClass( + "org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance(); - Ignite g3 = startGrid(3); + CacheConfiguration cfg = defaultCacheConfiguration(); - isClient = false; + cfg.setCacheStoreFactory((Factory)sf); + cfg.setName("customStore"); - IgniteCache cache1 = g1.cache(null); - IgniteCache cache2 = g2.cache(null); - IgniteCache cache3 = g3.cache(null); + IgniteCache cache1 = g1.createCache(cfg); - cache1.put(1, 1); + IgniteCache cache2 = g2.getOrCreateCache(cfg); // Checks deserialization at cache creation. + IgniteCache cache3 = g3.getOrCreateCache(cfg); // Checks deserialization at cache creation. - assertEquals(1, cache2.get(1)); - assertEquals(1, cache3.get(1)); + cache1.put(1, 1); - needStore = false; + assertEquals(1, cache2.get(1)); + assertEquals(1, cache3.get(1)); + } + finally { + needStore = false; + isClient = false; + useExtClassLoader = false; + } + } - stopAllGrids(); + /** + * @throws Exception If test failed. + */ + public void testStoreDynamicStart2() throws Exception { + try { + needStore = false; + useExtClassLoader = true; - g1 = startGrid(1); - g2 = startGrid(2); + Ignite g1 = startGrid(1); + Ignite g2 = startGrid(2); - isClient = true; + isClient = true; - g3 = startGrid(3); + Ignite g3 = startGrid(3); - isClient = false; + Object sf = getExternalClassLoader().loadClass( + "org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance(); - Object sf = ldr.loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance(); + CacheConfiguration cfg = defaultCacheConfiguration(); - cfg.setCacheStoreFactory((Factory)sf); - cfg.setName("customStore"); + cfg.setCacheStoreFactory((Factory)sf); + cfg.setName("customStore"); - cache1 = g1.createCache(cfg); + IgniteCache cache1 = g1.getOrCreateCache(cfg); - cache2 = g2.getOrCreateCache(cfg); // Checks deserialization at cache creation. - cache3 = g3.getOrCreateCache(cfg); // Checks deserialization at cache creation. + IgniteCache cache2 = g2.getOrCreateCache("customStore"); // Checks deserialization at cache creation. + IgniteCache cache3 = g3.getOrCreateCache("customStore"); // Checks deserialization at cache creation. - cache1.put(1, 1); + cache1.put(1, 1); - assertEquals(1, cache2.get(1)); - assertEquals(1, cache3.get(1)); - } + assertEquals(1, cache2.get(1)); + assertEquals(1, cache3.get(1)); } finally { needStore = false; isClient = false; - - stopAllGrids(); + useExtClassLoader = false; } }