You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/04/26 13:25:39 UTC
[28/50] [abbrv] ignite git commit: ignite-2.0 - Fixing tests
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 <al...@gmail.com>
Authored: Wed Apr 26 12:46:29 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
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<Ignite, Object>() {
- @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<Ignite, Void>() {
+ @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;
}
}