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 3ED48200C87 for ; Wed, 26 Apr 2017 15:25:16 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3D740160BBD; Wed, 26 Apr 2017 13:25:16 +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 09F4F160BD2 for ; Wed, 26 Apr 2017 15:25:13 +0200 (CEST) Received: (qmail 98432 invoked by uid 500); 26 Apr 2017 13:25:13 -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 98153 invoked by uid 99); 26 Apr 2017 13:25:13 -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, 26 Apr 2017 13:25:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EAE9AE1892; Wed, 26 Apr 2017 13:25:12 +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, 26 Apr 2017 13:25:39 -0000 Message-Id: In-Reply-To: <74ede65a043548339e50a758c6cba90c@git.apache.org> References: <74ede65a043548339e50a758c6cba90c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [28/50] [abbrv] ignite git commit: ignite-2.0 - Fixing tests archived-at: Wed, 26 Apr 2017 13:25:16 -0000 ignite-2.0 - Fixing tests Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c9cd761e Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c9cd761e Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c9cd761e Branch: refs/heads/master Commit: c9cd761e05ffcd4310e8df60ca62337e30507829 Parents: 4be320a Author: Alexey Goncharuk Authored: Wed Apr 26 12:46:29 2017 +0300 Committer: Alexey Goncharuk Committed: Wed Apr 26 12:46:29 2017 +0300 ---------------------------------------------------------------------- .../datastructures/GridCacheLockImpl.java | 6 ++ .../handlers/cache/GridCacheCommandHandler.java | 4 +- ...eAbstractDataStructuresFailoverSelfTest.java | 64 ++++++++++++-------- .../tcp/ipfinder/zk/ZookeeperIpFinderTest.java | 5 +- 4 files changed, 51 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/c9cd761e/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java index 3f1a0dd..0192354 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java @@ -197,6 +197,9 @@ public final class GridCacheLockImpl implements GridCacheLockEx, IgniteChangeGlo outgoingSignals.put(condition, cnt + 1); } + /** + * @param condition Condition. + */ protected void addOutgoingSignalAll(String condition) { outgoingSignals.put(condition, 0); } @@ -329,6 +332,9 @@ public final class GridCacheLockImpl implements GridCacheLockEx, IgniteChangeGlo return thisNode.equals(getOwnerNode()) || thisNode.equals(newOwnerID); } + /** + * @param newOwnerThreadId New owner thread id. + */ protected void setCurrentOwnerThread(long newOwnerThreadId) { currentOwnerThreadId = newOwnerThreadId; } http://git-wip-us.apache.org/repos/asf/ignite/blob/c9cd761e/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java index 79b395d..18cd6af 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java @@ -299,7 +299,9 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter { return col; } - throw new IgniteCheckedException("Incompatible types [appendVal=" + appendVal + ", old=" + origVal + ']'); + throw new IgniteCheckedException("Incompatible types [appendVal=" + appendVal + + ",type=" + (appendVal != null ? appendVal.getClass().getSimpleName() : "NULL") + ", old=" + origVal + + ",type= " + (origVal != null ? origVal.getClass().getSimpleName() : "NULL") + ']'); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/c9cd761e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java index cb4f6fc..b38f07e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java @@ -33,7 +33,6 @@ import org.apache.ignite.IgniteAtomicLong; import org.apache.ignite.IgniteAtomicReference; import org.apache.ignite.IgniteAtomicSequence; import org.apache.ignite.IgniteAtomicStamped; -import org.apache.ignite.IgniteCompute; import org.apache.ignite.IgniteCountDownLatch; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteInterruptedException; @@ -44,11 +43,13 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.AtomicConfiguration; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.GridLeanSet; import org.apache.ignite.internal.util.typedef.CA; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.PA; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteCallable; @@ -60,6 +61,7 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.GridTestUtils; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; /** * Failover tests for cache data structures. @@ -408,7 +410,7 @@ public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends Ig * @throws Exception If failed. */ public void testSemaphoreFailoverSafe() throws Exception { - try (IgniteSemaphore semaphore = grid(0).semaphore(STRUCTURE_NAME, 20, true, true)) { + try (final IgniteSemaphore semaphore = grid(0).semaphore(STRUCTURE_NAME, 20, true, true)) { Ignite g = startGrid(NEW_IGNITE_INSTANCE_NAME); IgniteSemaphore semaphore2 = g.semaphore(STRUCTURE_NAME, 20, true, false); @@ -419,7 +421,11 @@ public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends Ig stopGrid(NEW_IGNITE_INSTANCE_NAME); - assertEquals(20, semaphore.availablePermits()); + waitForCondition(new PA() { + @Override public boolean apply() { + return semaphore.availablePermits() == 20; + } + }, 2000); } } @@ -736,10 +742,16 @@ public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends Ig /** * @throws Exception If failed. */ - private void doTestReentrantLock(ConstantTopologyChangeWorker topWorker, final boolean failoverSafe, final boolean fair) throws Exception { - try (IgniteLock lock = grid(0).reentrantLock(STRUCTURE_NAME, failoverSafe, fair, true)) { - IgniteInternalFuture fut = topWorker.startChangingTopology(new IgniteClosure() { - @Override public Object apply(Ignite ignite) { + private void doTestReentrantLock( + final ConstantTopologyChangeWorker topWorker, + final boolean failoverSafe, + final boolean fair + ) throws Exception { + IgniteEx ig = grid(0); + + try (IgniteLock lock = ig.reentrantLock(STRUCTURE_NAME, failoverSafe, fair, true)) { + IgniteInternalFuture fut = topWorker.startChangingTopology(new IgniteClosure() { + @Override public Void apply(Ignite ignite) { final IgniteLock l = ignite.reentrantLock(STRUCTURE_NAME, failoverSafe, fair, false); final AtomicBoolean done = new AtomicBoolean(false); @@ -767,33 +779,33 @@ public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends Ig }); while (!fut.isDone()) { - while (true) { - try { - lock.lock(); - } - catch (IgniteException e) { - // Exception may happen in non-failoversafe mode. - if (failoverSafe) - throw e; - } - finally { - // Broken lock cannot be used in non-failoversafe mode. - if(!lock.isBroken() || failoverSafe) { - assertTrue(lock.isHeldByCurrentThread()); + try { + lock.lock(); + } + catch (IgniteException e) { + // Exception may happen in non-failoversafe mode. + if (failoverSafe) + throw e; + } + finally { + // Broken lock cannot be used in non-failoversafe mode. + if(!lock.isBroken() || failoverSafe) { + assertTrue(lock.isHeldByCurrentThread()); - lock.unlock(); + lock.unlock(); - assertFalse(lock.isHeldByCurrentThread()); - } - break; + assertFalse(lock.isHeldByCurrentThread()); } } } fut.get(); - for (Ignite g : G.allGrids()) - assertFalse(g.reentrantLock(STRUCTURE_NAME, failoverSafe, fair, false).isHeldByCurrentThread()); + for (Ignite g : G.allGrids()){ + IgniteLock l = g.reentrantLock(STRUCTURE_NAME, failoverSafe, fair, false); + + assertTrue(g.name(), !l.isHeldByCurrentThread() || lock.isBroken()); + } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/c9cd761e/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java ---------------------------------------------------------------------- diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java index 3aa3ce8..20947c4 100644 --- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java +++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java @@ -33,6 +33,7 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.events.Event; import org.apache.ignite.events.EventType; import org.apache.ignite.internal.util.lang.GridAbsPredicate; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.GridTestUtils; @@ -366,7 +367,9 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest { try { return 0 == zkCurator.getChildren().forPath(SERVICES_IGNITE_ZK_PATH).size(); } - catch (Exception ignored) { + catch (Exception e) { + U.error(log, "Failed to wait for zk condition", e); + return false; } }