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 A9A6B17242 for ; Thu, 17 Sep 2015 07:44:21 +0000 (UTC) Received: (qmail 79645 invoked by uid 500); 17 Sep 2015 07:44:21 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 79544 invoked by uid 500); 17 Sep 2015 07:44:21 -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 79424 invoked by uid 99); 17 Sep 2015 07:44:21 -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; Thu, 17 Sep 2015 07:44:21 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5AE8FE076F; Thu, 17 Sep 2015 07:44:21 +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: Thu, 17 Sep 2015 07:44:31 -0000 Message-Id: <85ce70538d554107af4eaca78952db04@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [11/14] ignite git commit: ignite-1171 Test for reproducing added ignite-1171 Test for reproducing added Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e75917d4 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e75917d4 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e75917d4 Branch: refs/heads/master Commit: e75917d47aaa34d8ff6219245668959fb68f0227 Parents: 5f5220a Author: agura Authored: Wed Sep 16 18:23:16 2015 +0300 Committer: agura Committed: Wed Sep 16 18:23:16 2015 +0300 ---------------------------------------------------------------------- .../distributed/CacheAffEarlySelfTest.java | 245 +++++++++++++++++++ .../ignite/testsuites/IgniteBasicTestSuite.java | 5 + 2 files changed, 250 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/e75917d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffEarlySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffEarlySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffEarlySelfTest.java new file mode 100644 index 0000000..7f0ca11 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffEarlySelfTest.java @@ -0,0 +1,245 @@ +/* + * 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.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Random; +import java.util.UUID; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.IgniteKernal; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteFuture; +import org.apache.ignite.lang.IgniteFutureTimeoutException; +import org.apache.ignite.lang.IgniteInClosure; +import org.apache.ignite.marshaller.optimized.OptimizedMarshaller; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +/** + * + */ +public class CacheAffEarlySelfTest extends GridCommonAbstractTest { + /** Grid count. */ + private static int GRID_CNT = 8; + + /** Operation timeout. */ + private static long OP_TIMEOUT = 5000; + + /** Always dump threads or only once per operation. */ + private static boolean ALWAYS_DUMP_THREADS = false; + + /** Stopped. */ + private volatile boolean stopped; + + /** Iteration. */ + private int iters = 10; + + /** Concurrent. */ + private boolean concurrent = true; + + /** Futs. */ + private Collection> futs = new ArrayList<>(GRID_CNT); + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder(true); + finder.setAddresses(Collections.singletonList("127.0.0.1:47500..47510")); + + TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); + discoSpi.setIpFinder(finder); + + cfg.setDiscoverySpi(discoSpi); + + OptimizedMarshaller marsh = new OptimizedMarshaller(); + marsh.setRequireSerializable(false); + + cfg.setMarshaller(marsh); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected long getTestTimeout() { + return 6 * 60 * 1000L; + } + + /** + * + */ + public void testStartNodes() throws Exception { + for (int i = 0; i < iters; i++) { + try { + System.out.println("*** Iteration " + (i + 1) + '/' + iters); + + IgniteInternalFuture fut = multithreadedAsync(new Runnable() { + @Override public void run() { + try { + doTest(); + } + catch (Exception e) { + e.printStackTrace(); + } + } + }, 1); + + fut.get(30000); + } + catch (IgniteFutureTimeoutCheckedException e) { + // No-op. + } + finally { + stopAllGrids(true); + } + } + } + + /** + * + */ + public void doTest() throws Exception { + for (int i = 0; i < GRID_CNT; i++) { + final int idx = i; + + final Ignite grid = concurrent ? null : startGrid(idx); + + IgniteInternalFuture fut = multithreadedAsync(new Runnable() { + @Override public void run() { + Random rnd = new Random(); + + try { + final Ignite ignite = grid == null ? startGrid(idx) : grid; + + final IgniteCache cache = getCache(ignite).withAsync(); + + CacheAffEarlySelfTest.this.execute(cache, new IgniteInClosure>() { + @Override public void apply(IgniteCache entries) { + cache.put(ignite.cluster().localNode().id(), UUID.randomUUID()); + } + }); + + while (!stopped) { + int val = Math.abs(rnd.nextInt(100)); + if (val >= 0 && val < 40) + execute(cache, new IgniteInClosure>() { + @Override public void apply(IgniteCache entries) { + cache.containsKey(ignite.cluster().localNode().id()); + } + }); + else if (val >= 40 && val < 80) + execute(cache, new IgniteInClosure>() { + @Override public void apply(IgniteCache entries) { + cache.get(ignite.cluster().localNode().id()); + } + }); + else + execute(cache, new IgniteInClosure>() { + @Override public void apply(IgniteCache entries) { + cache.put(ignite.cluster().localNode().id(), UUID.randomUUID()); + } + }); + + Thread.sleep(50); + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + }, 1); + + futs.add(fut); + } + + Thread.sleep(10000); + + stopped = true; + + for (IgniteInternalFuture fut : futs) + fut.get(); + } + + /** + * @param cache Cache. + * @param c Closure. + */ + private void execute(IgniteCache cache, IgniteInClosure> c) { + c.apply(cache); + + IgniteFuture fut = cache.future(); + + boolean success = false; + + int iter = 0; + + while (!success) { + try { + fut.get(OP_TIMEOUT); + + success = true; + } + catch (IgniteFutureTimeoutException e) { + debug(iter == 0 || ALWAYS_DUMP_THREADS); + } + + iter++; + } + } + + /** + * + */ + private void debug(boolean dumpThreads) { + log.info("DUMPING DEBUG INFO:"); + + for (Ignite ignite : G.allGrids()) + ((IgniteKernal)ignite).dumpDebugInfo(); + + if (dumpThreads) { + U.dumpThreads(null); + + U.dumpThreads(log); + } + } + + /** + * @param grid Grid. + */ + private IgniteCache getCache(Ignite grid) { + CacheConfiguration ccfg = defaultCacheConfiguration(); + + ccfg.setCacheMode(CacheMode.PARTITIONED); + ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); + ccfg.setBackups(1); + ccfg.setNearConfiguration(null); + + return grid.getOrCreateCache(ccfg); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/e75917d4/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java index 1a9913f..390807c 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java @@ -36,6 +36,7 @@ import org.apache.ignite.internal.processors.affinity.GridAffinityProcessorRende import org.apache.ignite.internal.processors.cache.GridProjectionForCachesOnDaemonNodeSelfTest; import org.apache.ignite.internal.processors.cache.IgniteDaemonNodeMarshallerCacheTest; import org.apache.ignite.internal.processors.cache.OffHeapTieredTransactionSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheAffEarlySelfTest; import org.apache.ignite.internal.processors.closure.GridClosureProcessorSelfTest; import org.apache.ignite.internal.processors.continuous.GridEventConsumeSelfTest; import org.apache.ignite.internal.processors.continuous.GridMessageListenSelfTest; @@ -68,6 +69,9 @@ public class IgniteBasicTestSuite extends TestSuite { public static TestSuite suite(Set ignoredTests) throws Exception { TestSuite suite = new TestSuite("Ignite Basic Test Suite"); + suite.addTest(new TestSuite(CacheAffEarlySelfTest.class)); + +/* suite.addTest(IgniteLangSelfTestSuite.suite()); suite.addTest(IgniteUtilSelfTestSuite.suite(ignoredTests)); suite.addTest(IgniteMarshallerSelfTestSuite.suite(ignoredTests)); @@ -110,6 +114,7 @@ public class IgniteBasicTestSuite extends TestSuite { suite.addTestSuite(OffHeapTieredTransactionSelfTest.class); suite.addTestSuite(IgniteSlowClientDetectionSelfTest.class); suite.addTestSuite(IgniteDaemonNodeMarshallerCacheTest.class); +*/ return suite; }