Ignite-1.5 - Fixing tests.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/aee20d9d Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/aee20d9d Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/aee20d9d Branch: refs/heads/ignite-1537 Commit: aee20d9d6822fd13fd437420b439ea18e99d0223 Parents: eed4b1c Author: Alexey Goncharuk <alexey.goncha...@gmail.com> Authored: Mon Nov 30 17:27:41 2015 +0300 Committer: Alexey Goncharuk <alexey.goncha...@gmail.com> Committed: Mon Nov 30 17:27:41 2015 +0300 ---------------------------------------------------------------------- .../GridDeploymentPerVersionStore.java | 12 +- .../distributed/dht/GridDhtLockFuture.java | 17 ++- .../communication/tcp/TcpCommunicationSpi.java | 12 +- .../IgniteCacheStoreValueAbstractTest.java | 111 +++++++++++-------- .../cache/IgniteCacheTxPreloadNoWriteTest.java | 2 +- ...eRebalancingUnmarshallingFailedSelfTest.java | 13 ++- 6 files changed, 104 insertions(+), 63 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/aee20d9d/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerVersionStore.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerVersionStore.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerVersionStore.java index fabbcb2..5e30bf6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerVersionStore.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerVersionStore.java @@ -145,11 +145,15 @@ public class GridDeploymentPerVersionStore extends GridDeploymentStoreAdapter { "nodes: " + dep); } } - else if (log.isDebugEnabled()) - log.debug("Preserving deployment without node participants: " + dep); + else { + if (log.isDebugEnabled()) + log.debug("Preserving deployment without node participants: " + dep); + } + } + else { + if (log.isDebugEnabled()) + log.debug("Keeping deployment as it still has participants: " + dep); } - else if (log.isDebugEnabled()) - log.debug("Keeping deployment as it still has participants: " + dep); } if (deps.isEmpty()) http://git-wip-us.apache.org/repos/asf/ignite/blob/aee20d9d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java index 2b5d5a4..f0d2e15 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java @@ -738,11 +738,22 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean> if (!success && !stopping) undoLocks(true); - if (tx != null) + boolean set = false; + + if (tx != null) { cctx.tm().txContext(tx); - if (err == null && !stopping) - loadMissingFromStore(); + set = cctx.tm().setTxTopologyHint(tx); + } + + try { + if (err == null && !stopping) + loadMissingFromStore(); + } + finally { + if (set) + cctx.tm().setTxTopologyHint(null); + } if (super.onDone(success, err)) { if (log.isDebugEnabled()) http://git-wip-us.apache.org/repos/asf/ignite/blob/aee20d9d/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java index b2f0f65..9f8bae3 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java @@ -2305,12 +2305,6 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter GridNioRecoveryDescriptor recoveryDesc = recoveryDescriptor(node); - if (!recoveryDesc.reserve()) { - U.closeQuiet(ch); - - return null; - } - if (getSpiContext().node(node.id()) == null) { recoveryDesc.release(); @@ -2320,6 +2314,12 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter "(node left topology): " + node); } + if (!recoveryDesc.reserve()) { + U.closeQuiet(ch); + + return null; + } + long rcvCnt = -1; SSLEngine sslEngine = null; http://git-wip-us.apache.org/repos/asf/ignite/blob/aee20d9d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java index 98579fc..95527c3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java @@ -27,6 +27,7 @@ import javax.cache.Cache; import javax.cache.integration.CacheLoaderException; import javax.cache.integration.CacheWriterException; import javax.cache.processor.MutableEntry; +import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.cache.CacheEntryProcessor; @@ -37,6 +38,9 @@ import org.apache.ignite.cache.affinity.Affinity; import org.apache.ignite.cache.store.CacheStoreAdapter; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.portable.BinaryMarshaller; +import org.apache.ignite.internal.portable.BinaryObjectImpl; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.lang.IgniteBiInClosure; @@ -242,7 +246,9 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr */ private void checkNoValue(Affinity<Object> aff, Object key) { for (int g = 0; g < gridCount(); g++) { - GridCacheAdapter cache0 = internalCache(grid(g), null); + IgniteEx ig = grid(g); + + GridCacheAdapter cache0 = internalCache(ig, null); GridCacheEntryEx e = cache0.peekEx(key); @@ -254,43 +260,38 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr assertNotNull(keyObj); - assertEquals(KeyCacheObjectImpl.class, keyObj.getClass()); - - assertNotNull("Unexpected value, node: " + g, - GridTestUtils.getFieldValue(keyObj, CacheObjectAdapter.class, "val")); + if (!isBinaryMarshallerUsed(ig)) { + assertNotNull("Unexpected value, node: " + g, + GridTestUtils.getFieldValue(keyObj, CacheObjectAdapter.class, "val")); - Object key0 = keyObj.value(cache0.context().cacheObjectContext(), true); - Object key1 = keyObj.value(cache0.context().cacheObjectContext(), false); - Object key2 = keyObj.value(cache0.context().cacheObjectContext(), true); - Object key3 = keyObj.value(cache0.context().cacheObjectContext(), false); + Object key0 = keyObj.value(cache0.context().cacheObjectContext(), true); + Object key1 = keyObj.value(cache0.context().cacheObjectContext(), false); + Object key2 = keyObj.value(cache0.context().cacheObjectContext(), true); + Object key3 = keyObj.value(cache0.context().cacheObjectContext(), false); - assertSame(key0, key1); - assertSame(key1, key2); - assertSame(key2, key3); + assertSame(key0, key1); + assertSame(key1, key2); + assertSame(key2, key3); + } CacheObject obj = e.rawGet(); if (obj != null) { - assertEquals(CacheObjectImpl.class, obj.getClass()); - - assertNull("Unexpected value, node: " + g, - GridTestUtils.getFieldValue(obj, CacheObjectAdapter.class, "val")); + assertNull("Unexpected value, node: " + g, reflectiveValue(obj)); assertNotNull(obj.value(cache0.context().cacheObjectContext(), true)); - assertNull("Unexpected value after value() requested1: " + g, - GridTestUtils.getFieldValue(obj, CacheObjectAdapter.class, "val")); + assertNull("Unexpected value after value() requested1: " + g, reflectiveValue(obj)); assertNotNull(obj.value(cache0.context().cacheObjectContext(), false)); - assertNull("Unexpected value after value() requested2: " + g, - GridTestUtils.getFieldValue(obj, CacheObjectAdapter.class, "val")); + assertNull("Unexpected value after value() requested2: " + g, reflectiveValue(obj)); } else - assertFalse(aff.isPrimaryOrBackup(grid(g).localNode(), key)); + assertFalse(aff.isPrimaryOrBackup(ig.localNode(), key)); } else - assertFalse("Entry not found, node: " + g, aff.isPrimaryOrBackup(grid(g).localNode(), key)); + assertFalse("Entry not found, node: " + g, aff.isPrimaryOrBackup(ig.localNode(), key)); } } @@ -379,7 +380,9 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr */ private void checkHasValue(Affinity<Object> aff, Object key) { for (int g = 0; g < gridCount(); g++) { - GridCacheAdapter cache0 = internalCache(grid(g), null); + IgniteEx ig = grid(g); + + GridCacheAdapter cache0 = internalCache(ig, null); GridCacheEntryEx e = cache0.peekEx(key); @@ -391,56 +394,72 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr assertNotNull(keyObj); - assertEquals(KeyCacheObjectImpl.class, keyObj.getClass()); - - assertNotNull("Unexpected value, node: " + g, - GridTestUtils.getFieldValue(keyObj, CacheObjectAdapter.class, "val")); + if (!isBinaryMarshallerUsed(ig)) { + assertNotNull("Unexpected value, node: " + g, + GridTestUtils.getFieldValue(keyObj, CacheObjectAdapter.class, "val")); - Object key0 = keyObj.value(cache0.context().cacheObjectContext(), true); - Object key1 = keyObj.value(cache0.context().cacheObjectContext(), false); - Object key2 = keyObj.value(cache0.context().cacheObjectContext(), true); - Object key3 = keyObj.value(cache0.context().cacheObjectContext(), false); + Object key0 = keyObj.value(cache0.context().cacheObjectContext(), true); + Object key1 = keyObj.value(cache0.context().cacheObjectContext(), false); + Object key2 = keyObj.value(cache0.context().cacheObjectContext(), true); + Object key3 = keyObj.value(cache0.context().cacheObjectContext(), false); - assertSame(key0, key1); - assertSame(key1, key2); - assertSame(key2, key3); + assertSame(key0, key1); + assertSame(key1, key2); + assertSame(key2, key3); + } CacheObject obj = e.rawGet(); if (obj != null) { - assertEquals(CacheObjectImpl.class, obj.getClass()); - - assertNotNull("Unexpected value, node: " + g, - GridTestUtils.getFieldValue(obj, CacheObjectAdapter.class, "val")); + if (!isBinaryMarshallerUsed(ig)) + assertNotNull("Unexpected value, node: " + g, reflectiveValue(obj)); Object val0 = obj.value(cache0.context().cacheObjectContext(), true); - assertNotNull("Unexpected value after value() requested1: " + g, - GridTestUtils.getFieldValue(obj, CacheObjectAdapter.class, "val")); + assertNotNull("Unexpected value after value() requested1: " + g, reflectiveValue(obj)); Object val1 = obj.value(cache0.context().cacheObjectContext(), true); - assertNotNull("Unexpected value after value() requested2: " + g, - GridTestUtils.getFieldValue(obj, CacheObjectAdapter.class, "val")); + assertNotNull("Unexpected value after value() requested2: " + g, reflectiveValue(obj)); assertSame(val0, val1); Object val2 = obj.value(cache0.context().cacheObjectContext(), false); - assertNotNull("Unexpected value after value() requested3: " + g, - GridTestUtils.getFieldValue(obj, CacheObjectAdapter.class, "val")); + assertNotNull("Unexpected value after value() requested3: " + g, reflectiveValue(obj)); assertSame(val1, val2); } else - assertFalse(aff.isPrimaryOrBackup(grid(g).localNode(), key)); + assertFalse(aff.isPrimaryOrBackup(ig.localNode(), key)); } else - assertFalse("Entry not found, node: " + g, aff.isPrimaryOrBackup(grid(g).localNode(), key)); + assertFalse("Entry not found, node: " + g, aff.isPrimaryOrBackup(ig.localNode(), key)); } } /** + * @param ig Ignite. + * @return If binary marshaller is used. + */ + private boolean isBinaryMarshallerUsed(Ignite ig) { + return ig.configuration().getMarshaller() == null || + ig.configuration().getMarshaller() instanceof BinaryMarshaller; + } + + /** + * @param obj Object to extract value from. + * @return Cache object. + */ + @SuppressWarnings("IfMayBeConditional") + private Object reflectiveValue(CacheObject obj) { + if (obj instanceof BinaryObjectImpl) + return GridTestUtils.getFieldValue(obj, BinaryObjectImpl.class, "obj"); + else + return GridTestUtils.getFieldValue(obj, CacheObjectAdapter.class, "val"); + } + + /** * */ static class TestKey implements Serializable { http://git-wip-us.apache.org/repos/asf/ignite/blob/aee20d9d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPreloadNoWriteTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPreloadNoWriteTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPreloadNoWriteTest.java index 2a85b57..a68931b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPreloadNoWriteTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPreloadNoWriteTest.java @@ -109,7 +109,7 @@ public class IgniteCacheTxPreloadNoWriteTest extends GridCommonAbstractTest { Ignite ignite1 = startGrid(1); - Integer key = 70; + Integer key = primaryKey(ignite1.cache(null)); // Want test scenario when ignite1 is new primary node, but ignite0 is still partition owner. assertTrue(aff.isPrimary(ignite1.cluster().localNode(), key)); http://git-wip-us.apache.org/repos/asf/ignite/blob/aee20d9d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingUnmarshallingFailedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingUnmarshallingFailedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingUnmarshallingFailedSelfTest.java index 831e82d..506f1c2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingUnmarshallingFailedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingUnmarshallingFailedSelfTest.java @@ -27,8 +27,10 @@ import org.apache.ignite.cache.CacheRebalanceMode; import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.portable.BinaryMarshaller; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; /** @@ -113,6 +115,12 @@ public class GridCacheRebalancingUnmarshallingFailedSelfTest extends GridCommonA * @throws Exception e. */ public void test() throws Exception { + String marshClsName = GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME); + + // This test passes with binary marshaller because we do not unmarshall keys. + if (marshClsName != null && marshClsName.contains(BinaryMarshaller.class.getSimpleName())) + return; + readCnt.set(Integer.MAX_VALUE); startGrid(0); @@ -133,9 +141,8 @@ public class GridCacheRebalancingUnmarshallingFailedSelfTest extends GridCommonA stopGrid(0); - for (int i = 50; i < 100; i++) { - assert grid(1).cache(CACHE).get(new TestKey(String.valueOf(i))) == null; - } + for (int i = 50; i < 100; i++) + assertNull(grid(1).cache(CACHE).get(new TestKey(String.valueOf(i)))); } /** {@inheritDoc} */