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 BC09517345 for ; Tue, 21 Apr 2015 11:07:51 +0000 (UTC) Received: (qmail 54063 invoked by uid 500); 21 Apr 2015 11:07:48 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 53991 invoked by uid 500); 21 Apr 2015 11:07:48 -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 53975 invoked by uid 99); 21 Apr 2015 11:07:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Apr 2015 11:07:48 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of root@apache.org designates 54.164.171.186 as permitted sender) Received: from [54.164.171.186] (HELO mx1-us-east.apache.org) (54.164.171.186) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Apr 2015 11:07:44 +0000 Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id 7CD0B4548D for ; Tue, 21 Apr 2015 11:06:30 +0000 (UTC) Received: (qmail 44203 invoked by uid 99); 21 Apr 2015 11:06:29 -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; Tue, 21 Apr 2015 11:06:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C55BEE04BB; Tue, 21 Apr 2015 11:06:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.incubator.apache.org Date: Tue, 21 Apr 2015 11:07:17 -0000 Message-Id: <0e3c06a218954252ae4f3ce34e927ae2@git.apache.org> In-Reply-To: <753ca04abf8c4615b96b8b586aef0bd7@git.apache.org> References: <753ca04abf8c4615b96b8b586aef0bd7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [50/51] 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/bc025d98 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/bc025d98 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/bc025d98 Branch: refs/heads/ignite-gg-9702 Commit: bc025d986723729034f7433fdec5ed968f8baeac Parents: fddf2a3 Author: sboikov Authored: Tue Apr 21 10:57:44 2015 +0300 Committer: sboikov Committed: Tue Apr 21 10:58:40 2015 +0300 ---------------------------------------------------------------------- .../IgniteCachePutGetRestartAbstractTest.java | 219 +++++++++++++++++++ ...iteCacheTxNearDisabledPutGetRestartTest.java | 30 +++ .../IgniteCacheFailoverTestSuite.java | 2 + 3 files changed, 251 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bc025d98/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePutGetRestartAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePutGetRestartAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePutGetRestartAbstractTest.java new file mode 100644 index 0000000..d2066ed --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePutGetRestartAbstractTest.java @@ -0,0 +1,219 @@ +/* + * 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.cache.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.transactions.*; + +import java.util.concurrent.*; +import java.util.concurrent.atomic.*; + +import static org.apache.ignite.cache.CacheAtomicityMode.*; +import static org.apache.ignite.cache.CacheMode.*; +import static org.apache.ignite.cache.CacheRebalanceMode.*; +import static org.apache.ignite.transactions.TransactionConcurrency.*; +import static org.apache.ignite.transactions.TransactionIsolation.*; + +/** + * Test for specific user scenario. + */ +public abstract class IgniteCachePutGetRestartAbstractTest extends IgniteCacheAbstractTest { + /** */ + private static final int ENTRY_CNT = 1000; + + /** */ + private Integer expVal = 0; + + /** */ + private final Object mux = new Object(); + + /** */ + private CountDownLatch latch = new CountDownLatch(1); + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 4; + } + + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return PARTITIONED; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return TRANSACTIONAL; + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + if (gridName.equals(getTestGridName(0))) + cfg.setClientMode(true); + + cfg.setPeerClassLoadingEnabled(false); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration cfg = super.cacheConfiguration(gridName); + + cfg.setRebalanceMode(SYNC); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected long getTestTimeout() { + return 5 * 60_000; + } + + /** + * @throws Exception If failed. + */ + public void testTxPutGetRestart() throws Exception { + final IgniteTransactions txs = ignite(0).transactions(); + + final IgniteCache cache = jcache(0); + + updateCache(cache, txs); + + final AtomicBoolean stop = new AtomicBoolean(); + + IgniteInternalFuture updateFut = GridTestUtils.runAsync(new Callable() { + @Override public Void call() throws Exception { + assertTrue(latch.await(30_000, TimeUnit.MILLISECONDS)); + + int iter = 0; + + while (!stop.get()) { + log.info("Start update: " + iter); + + synchronized (mux) { + updateCache(cache, txs); + } + + log.info("End update: " + iter++); + } + + log.info("Update iterations: " + iter); + + return null; + } + }); + + IgniteInternalFuture restartFut = GridTestUtils.runAsync(new Callable() { + @Override public Void call() throws Exception { + assertTrue(latch.await(30_000, TimeUnit.MILLISECONDS)); + + while (!stop.get()) { + log.info("Stop node."); + + stopGrid(1); + + U.sleep(100); + + log.info("Start node."); + + startGrid(1); + + U.sleep(100); + } + + return null; + } + }); + + long endTime = System.currentTimeMillis() + 2 * 60_000; + + try { + int iter = 0; + + while (System.currentTimeMillis() < endTime) { + try { + log.info("Start get: " + iter); + + synchronized (mux) { + readCache(cache, txs); + } + + log.info("End get: " + iter++); + } + finally { + if (latch.getCount() > 0) + latch.countDown(); + } + } + + log.info("Get iterations: " + iter); + } + finally { + stop.set(true); + } + + updateFut.get(); + + restartFut.get(); + + readCache(cache, txs); + } + + /** + * @param cache Cache. + * @param txs Transactions. + */ + private void readCache(IgniteCache cache, IgniteTransactions txs) { + try (Transaction tx = txs.txStart(OPTIMISTIC, REPEATABLE_READ)) { + for (int i = 0; i < ENTRY_CNT; i++) + assertEquals(expVal, cache.get(i)); + } + } + + /** + * @param cache Cache. + * @param txs Transactions. + */ + private void updateCache(IgniteCache cache, IgniteTransactions txs) { + int val = expVal + 1; + + try { + try (Transaction tx = txs.txStart(OPTIMISTIC, REPEATABLE_READ)) { + for (int i = 0; i < ENTRY_CNT; i++) + cache.put(i, val); + + tx.commit(); + + expVal = val; + + log.info("Updated cache, new value: " + val); + } + } + catch (IgniteException e) { + log.error("Update failed: " + e, e); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bc025d98/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheTxNearDisabledPutGetRestartTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheTxNearDisabledPutGetRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheTxNearDisabledPutGetRestartTest.java new file mode 100644 index 0000000..dd5fdca --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheTxNearDisabledPutGetRestartTest.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; + +import org.apache.ignite.configuration.*; + +/** + * + */ +public class IgniteCacheTxNearDisabledPutGetRestartTest extends IgniteCachePutGetRestartAbstractTest { + /** {@inheritDoc} */ + @Override protected NearCacheConfiguration nearConfiguration() { + return null; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bc025d98/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java index bd33fd8..9c1c57c 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java @@ -60,6 +60,8 @@ public class IgniteCacheFailoverTestSuite extends TestSuite { suite.addTestSuite(IgniteCacheAtomicNodeJoinTest.class); suite.addTestSuite(IgniteCacheTxNodeJoinTest.class); + suite.addTestSuite(IgniteCacheTxNearDisabledPutGetRestartTest.class); + return suite; } }