Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5595C200BCE for ; Thu, 17 Nov 2016 11:51:28 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 549A5160AFF; Thu, 17 Nov 2016 10:51:28 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 62324160B2D for ; Thu, 17 Nov 2016 11:51:26 +0100 (CET) Received: (qmail 78262 invoked by uid 500); 17 Nov 2016 10:51:25 -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 77684 invoked by uid 99); 17 Nov 2016 10:51:25 -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 Nov 2016 10:51:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0BF35F1791; Thu, 17 Nov 2016 10:51:25 +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 Nov 2016 10:51:47 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [24/50] [abbrv] ignite git commit: Added new test: IgniteCachePartitionedBackupNodeFailureRecoveryTest. archived-at: Thu, 17 Nov 2016 10:51:28 -0000 Added new test: IgniteCachePartitionedBackupNodeFailureRecoveryTest. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e031498d Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e031498d Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e031498d Branch: refs/heads/ignite-2693 Commit: e031498d872a5f1552b26a859b9ee79d3568ff9b Parents: 45bb1ac Author: sboikov Authored: Tue Nov 8 11:21:37 2016 +0300 Committer: sboikov Committed: Tue Nov 8 11:21:37 2016 +0300 ---------------------------------------------------------------------- ...artitionedBackupNodeFailureRecoveryTest.java | 193 +++++++++++++++++++ .../testsuites/IgniteCacheTestSuite2.java | 2 + 2 files changed, 195 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/e031498d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePartitionedBackupNodeFailureRecoveryTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePartitionedBackupNodeFailureRecoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePartitionedBackupNodeFailureRecoveryTest.java new file mode 100644 index 0000000..6654fd9 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePartitionedBackupNodeFailureRecoveryTest.java @@ -0,0 +1,193 @@ +/* +* 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.dht; + +import java.util.concurrent.Callable; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.locks.ReentrantLock; +import javax.cache.processor.EntryProcessor; +import javax.cache.processor.MutableEntry; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicWriteOrderMode; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.affinity.Affinity; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest; + +import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY; +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC; +import static org.apache.ignite.testframework.GridTestUtils.runAsync; + +/** + */ +public class IgniteCachePartitionedBackupNodeFailureRecoveryTest extends IgniteCacheAbstractTest { + /** {@inheritDoc}*/ + @Override protected int gridCount() { + return 3; + } + + /** {@inheritDoc}*/ + @Override protected CacheMode cacheMode() { + return PARTITIONED; + } + + /** {@inheritDoc}*/ + @Override protected CacheAtomicityMode atomicityMode() { + return ATOMIC; + } + + /** {@inheritDoc}*/ + @Override protected CacheAtomicWriteOrderMode atomicWriteOrderMode() { + return PRIMARY; + } + + /** {@inheritDoc}*/ + @Override protected NearCacheConfiguration nearConfiguration() { + return new NearCacheConfiguration(); + } + + /** {@inheritDoc}*/ + @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration ccfg = super.cacheConfiguration(gridName); + + ccfg.setBackups(1); + ccfg.setWriteSynchronizationMode(PRIMARY_SYNC); + ccfg.setRebalanceMode(SYNC); + + return ccfg; + } + + /** + * Test stops and restarts backup node. + * + * @throws Exception If failed. + */ + public void testBackUpFail() throws Exception { + final IgniteEx node1 = grid(0); + final IgniteEx node2 = grid(1); + final IgniteEx node3 = grid(2); + + awaitPartitionMapExchange(); + + final IgniteCache cache1 = node1.cache(null); + + Affinity aff = node1.affinity(null); + + Integer key0 = null; + + for (int key = 0; key < 10_000; key++) { + if (aff.isPrimary(node2.cluster().localNode(), key) && aff.isBackup(node3.cluster().localNode(), key)) { + key0 = key; + + break; + } + } + + assertNotNull(key0); + + cache1.put(key0, 0); + + final AtomicBoolean finished = new AtomicBoolean(); + + final ReentrantLock lock = new ReentrantLock(); + + final AtomicInteger cntr = new AtomicInteger(); + + final Integer finalKey = key0; + + IgniteInternalFuture primaryFut; + IgniteInternalFuture backupFut; + + try { + primaryFut = runAsync(new Callable() { + @Override public Void call() throws Exception { + while (!finished.get()) { + lock.lock(); + + try { + cache1.invoke(finalKey, new TestEntryProcessor()); + + cntr.getAndIncrement(); + } + finally { + lock.unlock(); + } + } + + return null; + } + }); + + backupFut = runAsync(new Callable() { + @Override public Void call() throws Exception { + while (!finished.get()) { + stopGrid(2); + + IgniteEx backUp = startGrid(2); + + IgniteCache cache3 = backUp.cache(null); + + lock.lock(); + + try { + Integer backUpVal = cache3.localPeek(finalKey); + + Integer exp = cntr.get(); + + assertEquals(exp, backUpVal); + } + finally { + lock.unlock(); + } + } + return null; + } + }); + + Thread.sleep(30_000); + } + finally { + finished.set(true); + } + + primaryFut.get(); + backupFut.get(); + } + + /** + * + */ + static class TestEntryProcessor implements EntryProcessor { + /** {@inheritDoc}*/ + @Override public Void process(MutableEntry entry, Object... args) { + Integer v = entry.getValue() + 1; + + entry.setValue(v); + + return null; + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/e031498d/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java index dc412a9..3fc27de 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java @@ -72,6 +72,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePart import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedPreloadEventsSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedTopologyChangeSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedUnloadEventsSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePartitionedBackupNodeFailureRecoveryTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicNearEvictionEventSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicNearMultiNodeSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicNearReadersSelfTest; @@ -259,6 +260,7 @@ public class IgniteCacheTestSuite2 extends TestSuite { suite.addTest(new TestSuite(CacheEnumOperationsSingleNodeTest.class)); suite.addTest(new TestSuite(CacheEnumOperationsTest.class)); suite.addTest(new TestSuite(IgniteCacheIncrementTxTest.class)); + suite.addTest(new TestSuite(IgniteCachePartitionedBackupNodeFailureRecoveryTest.class)); suite.addTest(new TestSuite(IgniteNoCustomEventsOnNodeStart.class));