IGNITE-10366: MVCC: Create "Cache 1" test suite for MVCC mode. This closes #5500.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2b2f50ca Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2b2f50ca Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2b2f50ca Branch: refs/heads/master Commit: 2b2f50ca00a48ec94b5f760e324e60a0c33e5713 Parents: 90207e9 Author: Igor Seliverstov <gvvinbl...@gmail.com> Authored: Mon Dec 10 14:35:08 2018 +0300 Committer: Igor Seliverstov <gvvinbl...@gmail.com> Committed: Mon Dec 10 14:35:08 2018 +0300 ---------------------------------------------------------------------- ...teCacheEntryProcessorSequentialCallTest.java | 68 +++- ...cheTransactionalStoreReadFromBackupTest.java | 8 + .../GridCacheLoadOnlyStoreAdapterSelfTest.java | 81 ++-- .../CacheJdbcPojoStoreAbstractSelfTest.java | 10 +- ...CacheJdbcBlobStoreMultithreadedSelfTest.java | 8 + .../managers/IgniteDiagnosticMessagesTest.java | 139 +++++-- .../cache/CacheDeferredDeleteQueueTest.java | 12 + .../CacheDeferredDeleteSanitySelfTest.java | 29 ++ .../cache/CacheFutureExceptionSelfTest.java | 6 + .../cache/CacheMvccTxFastFinishTest.java | 67 ++++ .../CacheNamesWithSpecialCharactersTest.java | 9 +- .../CachePutEventListenerErrorSelfTest.java | 3 + .../processors/cache/CacheTxFastFinishTest.java | 8 +- ...ridCacheAbstractByteArrayValuesSelfTest.java | 6 - .../cache/GridCacheClearAllSelfTest.java | 9 + ...idCacheConfigurationConsistencySelfTest.java | 27 ++ .../cache/GridCacheEntryMemorySizeSelfTest.java | 29 +- .../GridCacheLocalTxStoreExceptionSelfTest.java | 8 + ...GridCacheMixedPartitionExchangeSelfTest.java | 9 + ...ridCacheMvccMultiThreadedUpdateSelfTest.java | 203 ++++++++++ .../cache/GridCacheObjectToStringSelfTest.java | 8 + .../cache/GridCacheP2PUndeploySelfTest.java | 3 - .../processors/cache/GridCacheStopSelfTest.java | 78 +++- .../cache/GridCacheStorePutxSelfTest.java | 159 -------- .../GridCacheTtlManagerEvictionSelfTest.java | 9 + .../cache/GridCacheTtlManagerSelfTest.java | 8 + ...ridCacheTxPartitionedLocalStoreSelfTest.java | 8 + .../IgniteCacheEntryListenerAbstractTest.java | 8 + ...eCacheEntryListenerEagerTtlDisabledTest.java | 8 + .../IgniteCacheEntryListenerTxLocalTest.java | 8 + .../IgniteCacheEntryProcessorCallTest.java | 53 ++- .../cache/IgniteCacheInvokeAbstractTest.java | 13 +- .../cache/IgniteCacheMvccTxInvokeTest.java | 57 +++ .../IgniteCacheMvccTxNearEnabledInvokeTest.java | 37 ++ .../cache/IgniteCacheNearLockValueSelfTest.java | 3 + .../cache/IgniteCacheTxLocalInvokeTest.java | 8 + .../cache/IgnitePutAllLargeBatchSelfTest.java | 8 + ...tAllUpdateNonPreloadedPartitionSelfTest.java | 8 + .../cache/IgniteTxConfigCacheSelfTest.java | 8 +- .../IgniteTxExceptionAbstractSelfTest.java | 18 +- .../IgniteTxStoreExceptionAbstractSelfTest.java | 3 + .../CacheKeepBinaryWithInterceptorTest.java | 40 +- ...treamProcessorPersistenceBinarySelfTest.java | 28 ++ .../GridDataStreamerImplSelfTest.java | 2 +- ...iteCachePartitionedExecutionContextTest.java | 44 --- .../CacheTxNearUpdateTopologyChangeTest.java | 8 + ...tractDistributedByteArrayValuesSelfTest.java | 61 ++- ...tractPartitionedByteArrayValuesSelfTest.java | 27 +- .../IgniteCacheConnectionRecoveryTest.java | 15 +- ...eCacheMessageRecoveryIdleConnectionTest.java | 8 + .../IgniteCacheSystemTransactionsSelfTest.java | 45 ++- .../IgniteCrossCacheTxStoreSelfTest.java | 11 +- ...tPartitionedOnlyByteArrayValuesSelfTest.java | 17 +- .../dht/GridCacheGlobalLoadTest.java | 8 + ...tNearPartitionedByteArrayValuesSelfTest.java | 14 + .../near/GridCacheGetStoreErrorSelfTest.java | 11 +- .../near/GridCacheNearTxExceptionSelfTest.java | 8 + .../GridCachePartitionedStorePutSelfTest.java | 58 ++- ...stractReplicatedByteArrayValuesSelfTest.java | 2 +- .../GridCacheLocalByteArrayValuesSelfTest.java | 5 +- .../GridCacheLocalTxExceptionSelfTest.java | 8 + ...eEntryProcessorExternalizableFailedTest.java | 392 ++++++++++++++----- .../CacheEntryProcessorNonSerializableTest.java | 240 +++++++++--- .../TxRollbackOnTopologyChangeTest.java | 4 + .../DataStreamProcessorMvccSelfTest.java | 2 +- .../DataStreamProcessorSelfTest.java | 45 +-- .../ignite/testsuites/IgniteBasicTestSuite.java | 2 + .../testsuites/IgniteBinaryCacheTestSuite.java | 48 +-- .../testsuites/IgniteCacheMvccTestSuite1.java | 247 ++++++++++++ .../IgniteCacheTcpClientDiscoveryTestSuite.java | 41 +- .../ignite/testsuites/IgniteCacheTestSuite.java | 305 +++++++-------- .../testsuites/IgniteCacheTestSuite2.java | 1 - 72 files changed, 2177 insertions(+), 822 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/cache/IgniteCacheEntryProcessorSequentialCallTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/IgniteCacheEntryProcessorSequentialCallTest.java b/modules/core/src/test/java/org/apache/ignite/cache/IgniteCacheEntryProcessorSequentialCallTest.java index 165bca7..f940856 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/IgniteCacheEntryProcessorSequentialCallTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/IgniteCacheEntryProcessorSequentialCallTest.java @@ -19,6 +19,8 @@ package org.apache.ignite.cache; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; +import javax.cache.processor.EntryProcessorException; +import javax.cache.processor.MutableEntry; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; @@ -28,13 +30,20 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; -import javax.cache.processor.EntryProcessorException; -import javax.cache.processor.MutableEntry; import org.apache.ignite.transactions.TransactionOptimisticException; /** */ public class IgniteCacheEntryProcessorSequentialCallTest extends GridCommonAbstractTest { + /** */ + private static final String CACHE = "cache"; + + /** */ + private static final String MVCC_CACHE = "mvccCache"; + + /** */ + private String cacheName; + /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGrids(2); @@ -45,11 +54,33 @@ public class IgniteCacheEntryProcessorSequentialCallTest extends GridCommonAbstr stopAllGrids(); } + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + cacheName = CACHE; + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - CacheConfiguration cacheCfg = new CacheConfiguration("cache"); + CacheConfiguration ccfg = cacheConfiguration(CACHE); + + CacheConfiguration mvccCfg = cacheConfiguration(MVCC_CACHE) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); + + cfg.setCacheConfiguration(ccfg, mvccCfg); + + return cfg; + } + + /** + * + * @return Cache configuration. + * @param name Cache name. + */ + private CacheConfiguration cacheConfiguration(String name) { + CacheConfiguration cacheCfg = new CacheConfiguration(name); cacheCfg.setCacheMode(CacheMode.PARTITIONED); cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); @@ -57,10 +88,7 @@ public class IgniteCacheEntryProcessorSequentialCallTest extends GridCommonAbstr cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cacheCfg.setMaxConcurrentAsyncOperations(0); cacheCfg.setBackups(0); - - cfg.setCacheConfiguration(cacheCfg); - - return cfg; + return cacheCfg; } /** @@ -118,6 +146,17 @@ public class IgniteCacheEntryProcessorSequentialCallTest extends GridCommonAbstr } /** + * + */ + public void testMvccTxInvokeSequentialCall() throws Exception { + cacheName = MVCC_CACHE; + + transactionInvokeSequentialCallOnPrimaryNode(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); + + transactionInvokeSequentialCallOnNearNode(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); + } + + /** * Test for sequential entry processor invoking not null value on primary cache. * In this test entry processor gets value from local node. * @@ -132,12 +171,12 @@ public class IgniteCacheEntryProcessorSequentialCallTest extends GridCommonAbstr Ignite primaryIgnite; - if (ignite(0).affinity("cache").isPrimary(ignite(0).cluster().localNode(), key)) + if (ignite(0).affinity(cacheName).isPrimary(ignite(0).cluster().localNode(), key)) primaryIgnite = ignite(0); else primaryIgnite = ignite(1); - IgniteCache<TestKey, TestValue> cache = primaryIgnite.cache("cache"); + IgniteCache<TestKey, TestValue> cache = primaryIgnite.cache(cacheName); cache.put(key, val); @@ -171,7 +210,7 @@ public class IgniteCacheEntryProcessorSequentialCallTest extends GridCommonAbstr Ignite nearIgnite; Ignite primaryIgnite; - if (ignite(0).affinity("cache").isPrimary(ignite(0).cluster().localNode(), key)) { + if (ignite(0).affinity(cacheName).isPrimary(ignite(0).cluster().localNode(), key)) { primaryIgnite = ignite(0); nearIgnite = ignite(1); @@ -182,9 +221,9 @@ public class IgniteCacheEntryProcessorSequentialCallTest extends GridCommonAbstr nearIgnite = ignite(0); } - primaryIgnite.cache("cache").put(key, val); + primaryIgnite.cache(cacheName).put(key, val); - IgniteCache<TestKey, TestValue> nearCache = nearIgnite.cache("cache"); + IgniteCache<TestKey, TestValue> nearCache = nearIgnite.cache(cacheName); NotNullCacheEntryProcessor cacheEntryProcessor = new NotNullCacheEntryProcessor(); @@ -197,17 +236,18 @@ public class IgniteCacheEntryProcessorSequentialCallTest extends GridCommonAbstr transaction.commit(); } - primaryIgnite.cache("cache").remove(key); + primaryIgnite.cache(cacheName).remove(key); } /** * Test for sequential entry processor invocation. During transaction value is changed externally, which leads to * optimistic conflict exception. */ + @SuppressWarnings("ThrowableNotThrown") public void testTxInvokeSequentialOptimisticConflict() throws Exception { TestKey key = new TestKey(1L); - IgniteCache<TestKey, TestValue> cache = ignite(0).cache("cache"); + IgniteCache<TestKey, TestValue> cache = ignite(0).cache(CACHE); CountDownLatch latch = new CountDownLatch(1); http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/cache/store/CacheTransactionalStoreReadFromBackupTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheTransactionalStoreReadFromBackupTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheTransactionalStoreReadFromBackupTest.java index 4837936..f1b14ab 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheTransactionalStoreReadFromBackupTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheTransactionalStoreReadFromBackupTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.cache.store; import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -26,6 +27,13 @@ import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; */ public class CacheTransactionalStoreReadFromBackupTest extends CacheStoreReadFromBackupTest { /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.beforeTestsStarted(); + } + + /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; } http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java index 2a1e23a..6273d6f 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java @@ -21,16 +21,18 @@ import java.util.Arrays; import java.util.Iterator; import java.util.NoSuchElementException; import javax.cache.integration.CacheLoaderException; +import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.lang.IgniteBiTuple; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; /** * */ -public class GridCacheLoadOnlyStoreAdapterSelfTest extends GridCacheAbstractSelfTest { +public class GridCacheLoadOnlyStoreAdapterSelfTest extends GridCommonAbstractTest { /** Expected loadAll arguments, hardcoded on call site for convenience. */ private static final Integer[] EXP_ARGS = {1, 2, 3}; @@ -38,34 +40,32 @@ public class GridCacheLoadOnlyStoreAdapterSelfTest extends GridCacheAbstractSelf private CacheLoadOnlyStoreAdapter store; /** {@inheritDoc} */ - @Override protected int gridCount() { - return 1; - } - - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { + super.beforeTestsStarted(); + startGrid(0); } /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); } /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { + grid(0).destroyCache(DEFAULT_CACHE_NAME); + super.afterTest(); } - /** {@inheritDoc} */ + /** + * @return Cache configuration. + */ @SuppressWarnings("unchecked") - @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { - CacheConfiguration cfg = super.cacheConfiguration(igniteInstanceName); + private CacheConfiguration<?, ?> cacheConfiguration() { + CacheConfiguration cfg = defaultCacheConfiguration(); assertNotNull(store); @@ -81,58 +81,35 @@ public class GridCacheLoadOnlyStoreAdapterSelfTest extends GridCacheAbstractSelf * @throws Exception If failed. */ public void testStore() throws Exception { - try { - int inputSize = 100; - - store = new TestStore(inputSize); - - startGrids(gridCount()); + int inputSize = 100; - awaitPartitionMapExchange(); + store = new TestStore(inputSize); - jcache().localLoadCache(null, 1, 2, 3); + IgniteCache<?, ?> cache = grid(0).createCache(cacheConfiguration()); - int cnt = 0; + cache.localLoadCache(null, 1, 2, 3); - for (int i = 0; i < gridCount(); i++) - cnt += jcache(i).localSize(); - - assertEquals(inputSize - (inputSize / 10), cnt); - } - finally { - stopAllGrids(); - } + assertEquals(inputSize - (inputSize / 10), cache.localSize()); } /** * @throws Exception If failed. */ public void testStoreSmallQueueSize() throws Exception { - try { - int inputSize = 1500; - - store = new ParallelTestStore(inputSize); - - store.setBatchSize(1); - store.setBatchQueueSize(1); - store.setThreadsCount(2); + int inputSize = 1500; - startGrids(gridCount()); + store = new ParallelTestStore(inputSize); - awaitPartitionMapExchange(); + store.setBatchSize(1); + store.setBatchQueueSize(1); + store.setThreadsCount(2); - jcache().localLoadCache(null, 1, 2, 3); + IgniteCache<?, ?> cache = grid(0).createCache(cacheConfiguration()); - int cnt = 0; + cache.localLoadCache(null, 1, 2, 3); - for (int i = 0; i < gridCount(); i++) - cnt += jcache(i).localSize(); + assertEquals(inputSize, cache.localSize()); - assertEquals(inputSize, cnt); - } - finally { - stopAllGrids(); - } } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java index 703cbe1..2095824 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java @@ -29,8 +29,8 @@ import java.util.Random; import javax.cache.integration.CacheLoaderException; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.store.jdbc.dialect.H2Dialect; -import org.apache.ignite.cache.store.jdbc.model.Person; import org.apache.ignite.cache.store.jdbc.model.Gender; +import org.apache.ignite.cache.store.jdbc.model.Person; import org.apache.ignite.cache.store.jdbc.model.PersonKey; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; @@ -41,6 +41,7 @@ import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; @@ -97,6 +98,13 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr } /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.beforeTestsStarted(); + } + + /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { Connection conn = getConnection(); http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java index 1f68490..9eaedbf 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java @@ -40,6 +40,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; @@ -66,6 +67,13 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstr private boolean client; /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.beforeTestsStarted(); + } + + /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { startGridsMultiThreaded(GRID_CNT - 2); http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java index 69bc6e9..4f6db6a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java @@ -26,6 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; @@ -50,12 +51,13 @@ import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.ListeningTestLogger; import org.apache.ignite.testframework.LogListener; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import static org.apache.ignite.IgniteSystemProperties.IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; @@ -122,7 +124,14 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest { * @throws Exception If failed. */ public void testDiagnosticMessages1() throws Exception { - checkBasicDiagnosticInfo(); + checkBasicDiagnosticInfo(CacheAtomicityMode.TRANSACTIONAL); + } + + /** + * @throws Exception If failed. + */ + public void testDiagnosticMessagesMvcc1() throws Exception { + checkBasicDiagnosticInfo(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); } /** @@ -131,13 +140,37 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest { public void testDiagnosticMessages2() throws Exception { connectionsPerNode = 5; - checkBasicDiagnosticInfo(); + checkBasicDiagnosticInfo(CacheAtomicityMode.TRANSACTIONAL); + } + + /** + * @throws Exception If failed. + */ + public void testDiagnosticMessagesMvcc2() throws Exception { + connectionsPerNode = 5; + + checkBasicDiagnosticInfo(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); } /** * @throws Exception If failed. */ public void testLongRunning() throws Exception { + checkLongRunning(TRANSACTIONAL); + } + + /** + * @throws Exception If failed. + */ + public void testLongRunningMvcc() throws Exception { + checkLongRunning(TRANSACTIONAL_SNAPSHOT); + } + + /** + * @param atomicityMode Cache atomicity mode. + * @throws Exception If failed. + */ + public void checkLongRunning(CacheAtomicityMode atomicityMode) throws Exception { System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, "3500"); try { @@ -151,11 +184,7 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest { awaitPartitionMapExchange(); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - - ccfg.setWriteSynchronizationMode(FULL_SYNC); - ccfg.setCacheMode(PARTITIONED); - ccfg.setAtomicityMode(TRANSACTIONAL); + CacheConfiguration ccfg = cacheConfiguration(atomicityMode); final Ignite node0 = ignite(0); @@ -196,9 +225,38 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest { } /** + * @param atomicityMode Cache atomicity mode. + * @return Cache configuration. + */ + @SuppressWarnings("unchecked") + private CacheConfiguration cacheConfiguration(CacheAtomicityMode atomicityMode) { + return defaultCacheConfiguration() + .setAtomicityMode(atomicityMode) + .setWriteSynchronizationMode(FULL_SYNC) + .setNearConfiguration(null); + } + + /** + * @throws Exception If failed. + */ + public void testSeveralLongRunningMvccTxs() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9322"); // Fix diagnostic message or disable test. + + checkSeveralLongRunningTxs(TRANSACTIONAL_SNAPSHOT); + } + + /** * @throws Exception If failed. */ public void testSeveralLongRunningTxs() throws Exception { + checkSeveralLongRunningTxs(TRANSACTIONAL); + } + + /** + * @param atomicityMode Cache atomicity mode. + * @throws Exception If failed. + */ + public void checkSeveralLongRunningTxs(CacheAtomicityMode atomicityMode) throws Exception { int timeout = 3500; System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, String.valueOf(timeout)); @@ -216,11 +274,7 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest { awaitPartitionMapExchange(); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - - ccfg.setWriteSynchronizationMode(FULL_SYNC); - ccfg.setCacheMode(PARTITIONED); - ccfg.setAtomicityMode(TRANSACTIONAL); + CacheConfiguration ccfg = cacheConfiguration(atomicityMode); final Ignite node0 = ignite(0); final Ignite node1 = ignite(1); @@ -306,7 +360,26 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + public void testLongRunningMvccTx() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9322"); // Fix diagnostic message or disable test. + + checkLongRunningTx(TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ public void testLongRunningTx() throws Exception { + checkLongRunningTx(TRANSACTIONAL); + + } + + /** + * @param atomicityMode Cache atomicity mode. + * @throws Exception If failed. + */ + public void checkLongRunningTx(CacheAtomicityMode atomicityMode) throws Exception { + final int longOpDumpTimeout = 1000; System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, String.valueOf(longOpDumpTimeout)); @@ -314,11 +387,7 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest { try { final Ignite node0 = startGrid(0); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - - ccfg.setWriteSynchronizationMode(FULL_SYNC); - ccfg.setCacheMode(PARTITIONED); - ccfg.setAtomicityMode(TRANSACTIONAL); + CacheConfiguration ccfg = cacheConfiguration(atomicityMode); node0.createCache(ccfg); @@ -404,6 +473,21 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest { * @throws Exception If failed. */ public void testRemoteTx() throws Exception { + checkRemoteTx(TRANSACTIONAL); + } + + /** + * @throws Exception If failed. + */ + public void testRemoteMvccTx() throws Exception { + checkRemoteTx(TRANSACTIONAL_SNAPSHOT); + } + + /** + * @param atomicityMode Cache atomicity mode. + * @throws Exception If failed. + */ + public void checkRemoteTx(CacheAtomicityMode atomicityMode) throws Exception { int timeout = 3500; System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, String.valueOf(timeout)); @@ -421,13 +505,11 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest { awaitPartitionMapExchange(); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + CacheConfiguration ccfg = cacheConfiguration(atomicityMode).setBackups(1); - ccfg.setWriteSynchronizationMode(FULL_SYNC); - ccfg.setCacheMode(PARTITIONED); - ccfg.setAtomicityMode(TRANSACTIONAL); - ccfg.setBackups(1); - ccfg.setNearConfiguration(new NearCacheConfiguration()); + if (atomicityMode != TRANSACTIONAL_SNAPSHOT || + MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.NEAR_CACHE)) + ccfg.setNearConfiguration(new NearCacheConfiguration<>()); final Ignite node0 = ignite(0); final Ignite node1 = ignite(1); @@ -479,9 +561,10 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest { } /** + * @param atomicityMode Cache atomicity mode. * @throws Exception If failed. */ - private void checkBasicDiagnosticInfo() throws Exception { + private void checkBasicDiagnosticInfo(CacheAtomicityMode atomicityMode) throws Exception { startGrids(3); client = true; @@ -490,11 +573,7 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest { startGrid(4); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - - ccfg.setWriteSynchronizationMode(FULL_SYNC); - ccfg.setCacheMode(REPLICATED); - ccfg.setAtomicityMode(TRANSACTIONAL); + CacheConfiguration ccfg = cacheConfiguration(atomicityMode).setCacheMode(REPLICATED); ignite(0).createCache(ccfg); http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteQueueTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteQueueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteQueueTest.java index 871bc33..479ac8e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteQueueTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteQueueTest.java @@ -32,6 +32,7 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import static org.apache.ignite.IgniteSystemProperties.IGNITE_CACHE_REMOVED_ENTRIES_TTL; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -70,12 +71,23 @@ public class CacheDeferredDeleteQueueTest extends GridCommonAbstractTest { testQueue(TRANSACTIONAL, false); + testQueue(TRANSACTIONAL_SNAPSHOT, false); + testQueue(ATOMIC, true); testQueue(TRANSACTIONAL, true); } /** + * @throws Exception If failed. + */ + public void testDeferredDeleteQueueMvcc() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-7187"); + + testQueue(TRANSACTIONAL_SNAPSHOT, true); + } + + /** * @param atomicityMode Cache atomicity mode. * @param nearCache {@code True} if need create near cache. * http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteSanitySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteSanitySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteSanitySelfTest.java index dd75799..6039384 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteSanitySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteSanitySelfTest.java @@ -26,6 +26,7 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -64,6 +65,34 @@ public class CacheDeferredDeleteSanitySelfTest extends GridCommonAbstractTest { } /** + * @throws Exception If fails. + */ + public void testDeferredDeleteMvcc() throws Exception { + testDeferredDelete(PARTITIONED, TRANSACTIONAL_SNAPSHOT, false, true); + testDeferredDelete(REPLICATED, TRANSACTIONAL_SNAPSHOT, false, true); + } + + /** + * @throws Exception If fails. + */ + public void testDeferredDeleteMvccNear() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-7187"); + + testDeferredDelete(PARTITIONED, TRANSACTIONAL_SNAPSHOT, true, false); + testDeferredDelete(REPLICATED, TRANSACTIONAL_SNAPSHOT, true, true); + } + + /** + * @throws Exception If fails. + */ + public void testDeferredDeleteMvccLocal() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9530"); + + testDeferredDelete(LOCAL, TRANSACTIONAL_SNAPSHOT, false, false); + testDeferredDelete(LOCAL, TRANSACTIONAL_SNAPSHOT, true, false); + } + + /** * @param mode Mode. * @param atomicityMode Atomicity mode. * @param near Near cache enabled. http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java index a51765c..78cd568 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java @@ -33,6 +33,7 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import static java.util.concurrent.TimeUnit.SECONDS; @@ -93,6 +94,11 @@ public class CacheFutureExceptionSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ private void testGet(boolean nearCache, boolean cpyOnRead) throws Exception { + if (MvccFeatureChecker.forcedMvcc()) { + if (!MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.NEAR_CACHE)) + return; + } + fail = false; Ignite srv = grid(0); http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMvccTxFastFinishTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMvccTxFastFinishTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMvccTxFastFinishTest.java new file mode 100644 index 0000000..7261d79 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMvccTxFastFinishTest.java @@ -0,0 +1,67 @@ +/* + * 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; + +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteTransactions; +import org.apache.ignite.transactions.Transaction; + +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; + +/** + * + */ +public class CacheMvccTxFastFinishTest extends CacheTxFastFinishTest { + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10444"); + + super.beforeTestsStarted(); + } + + /** {@inheritDoc} */ + @Override protected void fastFinishTx(Ignite ignite) { + IgniteTransactions txs = ignite.transactions(); + + IgniteCache<Integer, Integer> cache = ignite.cache(DEFAULT_CACHE_NAME); + + for (boolean commit : new boolean[] {true, false}) { + try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) { + checkFastTxFinish(tx, commit); + } + + for (int i = 0; i < 100; i++) { + try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) { + cache.get(i); + + checkNormalTxFinish(tx, commit); + } + } + + for (int i = 0; i < 100; i++) { + try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) { + cache.put(i, i); + + checkNormalTxFinish(tx, commit); + } + } + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesWithSpecialCharactersTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesWithSpecialCharactersTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesWithSpecialCharactersTest.java index ecb8227..96b7c0a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesWithSpecialCharactersTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesWithSpecialCharactersTest.java @@ -17,21 +17,22 @@ package org.apache.ignite.internal.processors.cache; +import java.util.Collection; import org.apache.ignite.Ignite; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import java.util.Collection; - /** * Test that validates {@link Ignite#cacheNames()} implementation. */ public class CacheNamesWithSpecialCharactersTest extends GridCommonAbstractTest { + /** */ + private static final String CACHE_NAME_1 = "--â=+:(replicated)"; - public static final String CACHE_NAME_1 = "--â=+:(replicated)"; - public static final String CACHE_NAME_2 = ":_&:: (partitioned)"; + /** */ + private static final String CACHE_NAME_2 = ":_&:: (partitioned)"; /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutEventListenerErrorSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutEventListenerErrorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutEventListenerErrorSelfTest.java index e14f472..cb038f7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutEventListenerErrorSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutEventListenerErrorSelfTest.java @@ -36,6 +36,7 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; /** @@ -62,6 +63,8 @@ public class CachePutEventListenerErrorSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + startGridsMultiThreaded(3); Ignition.setClientMode(true); http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java index 79316bf..b9a41ba 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java @@ -107,7 +107,7 @@ public class CacheTxFastFinishTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ - private void fastFinishTx() throws Exception { + protected void fastFinishTx() throws Exception { startGrid(0); fastFinishTx(ignite(0)); @@ -142,7 +142,7 @@ public class CacheTxFastFinishTest extends GridCommonAbstractTest { /** * @param ignite Node. */ - private void fastFinishTx(Ignite ignite) { + protected void fastFinishTx(Ignite ignite) { IgniteTransactions txs = ignite.transactions(); IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); @@ -202,7 +202,7 @@ public class CacheTxFastFinishTest extends GridCommonAbstractTest { * @param tx Transaction. * @param commit Commit flag. */ - private void checkFastTxFinish(Transaction tx, boolean commit) { + protected void checkFastTxFinish(Transaction tx, boolean commit) { if (commit) tx.commit(); else @@ -218,7 +218,7 @@ public class CacheTxFastFinishTest extends GridCommonAbstractTest { * @param tx Transaction. * @param commit Commit flag. */ - private void checkNormalTxFinish(Transaction tx, boolean commit) { + protected void checkNormalTxFinish(Transaction tx, boolean commit) { IgniteInternalTx tx0 = ((TransactionProxyImpl)tx).tx(); if (commit) { http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractByteArrayValuesSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractByteArrayValuesSelfTest.java index cabe41f..a3f3481 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractByteArrayValuesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractByteArrayValuesSelfTest.java @@ -27,18 +27,12 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; * Base class for various tests for byte array values. */ public abstract class GridCacheAbstractByteArrayValuesSelfTest extends GridCommonAbstractTest { - /** Regular cache name. */ - protected static final String CACHE_REGULAR = "cache"; - /** Key 1. */ protected static final Integer KEY_1 = 1; /** Key 2. */ protected static final Integer KEY_2 = 2; - /** Use special key for swap test, otherwise entry with readers is not evicted. */ - protected static final Integer SWAP_TEST_KEY = 3; - /** Shared IP finder. */ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllSelfTest.java index cae58e1..053345d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllSelfTest.java @@ -28,6 +28,7 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -67,6 +68,14 @@ public class GridCacheClearAllSelfTest extends GridCommonAbstractTest { private String cacheName = CACHE_NAME; /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-7952"); + + super.beforeTestsStarted(); + } + + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java index 3f4efc2..6ca7136 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java @@ -51,6 +51,7 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -519,6 +520,32 @@ public class GridCacheConfigurationConsistencySelfTest extends GridCommonAbstrac /** * @throws Exception If failed. */ + public void testDifferentTxAtomicity() throws Exception { + cacheMode = PARTITIONED; + + checkSecondGridStartFails( + new C1<CacheConfiguration, Void>() { + /** {@inheritDoc} */ + @Override public Void apply(CacheConfiguration cfg) { + cfg.setNearConfiguration(null); + cfg.setAtomicityMode(TRANSACTIONAL); + return null; + } + }, + new C1<CacheConfiguration, Void>() { + /** {@inheritDoc} */ + @Override public Void apply(CacheConfiguration cfg) { + cfg.setNearConfiguration(null); + cfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + return null; + } + } + ); + } + + /** + * @throws Exception If failed. + */ public void testDifferentSynchronization() throws Exception { cacheMode = PARTITIONED; http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java index c45fa89..98928b0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java @@ -38,6 +38,7 @@ import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -115,12 +116,26 @@ public class GridCacheEntryMemorySizeSelfTest extends GridCommonAbstractTest { startGrids(2); } + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + super.afterTestsStopped(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + grid(0).destroyCache(DEFAULT_CACHE_NAME); + + super.afterTest(); + } + /** * @param nearEnabled {@code True} if near cache should be enabled. * @param mode Cache mode. * @return Created cache. */ - private IgniteCache<Integer, Value> testCache(boolean nearEnabled, CacheMode mode) { + private IgniteCache<Integer, Value> createCache(boolean nearEnabled, CacheMode mode) { CacheConfiguration<Integer, Value> cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(mode); @@ -177,7 +192,9 @@ public class GridCacheEntryMemorySizeSelfTest extends GridCommonAbstractTest { /** @throws Exception If failed. */ public void testLocal() throws Exception { - IgniteCache<Integer, Value> cache = testCache(false, LOCAL); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + IgniteCache<Integer, Value> cache = createCache(false, LOCAL); try { cache.put(1, new Value(new byte[1024])); @@ -200,7 +217,7 @@ public class GridCacheEntryMemorySizeSelfTest extends GridCommonAbstractTest { /** @throws Exception If failed. */ public void testReplicated() throws Exception { - IgniteCache<Integer, Value> cache = testCache(false, REPLICATED); + IgniteCache<Integer, Value> cache = createCache(false, REPLICATED); try { cache.put(1, new Value(new byte[1024])); @@ -223,7 +240,9 @@ public class GridCacheEntryMemorySizeSelfTest extends GridCommonAbstractTest { /** @throws Exception If failed. */ public void testPartitionedNearEnabled() throws Exception { - IgniteCache<Integer, Value> cache = testCache(true, PARTITIONED); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + IgniteCache<Integer, Value> cache = createCache(true, PARTITIONED); try { int[] keys = new int[3]; @@ -275,7 +294,7 @@ public class GridCacheEntryMemorySizeSelfTest extends GridCommonAbstractTest { /** @throws Exception If failed. */ public void testPartitionedNearDisabled() throws Exception { - IgniteCache<Integer, Value> cache = testCache(false, PARTITIONED); + IgniteCache<Integer, Value> cache = createCache(false, PARTITIONED); try { int[] keys = new int[3]; http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLocalTxStoreExceptionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLocalTxStoreExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLocalTxStoreExceptionSelfTest.java index 71f1f7f..fccf5ec 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLocalTxStoreExceptionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLocalTxStoreExceptionSelfTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -26,6 +27,13 @@ import static org.apache.ignite.cache.CacheMode.LOCAL; */ public class GridCacheLocalTxStoreExceptionSelfTest extends IgniteTxStoreExceptionAbstractSelfTest { /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.beforeTestsStarted(); + } + + /** {@inheritDoc} */ @Override protected int gridCount() { return 1; } http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMixedPartitionExchangeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMixedPartitionExchangeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMixedPartitionExchangeSelfTest.java index f6f4751..320dacd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMixedPartitionExchangeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMixedPartitionExchangeSelfTest.java @@ -33,6 +33,7 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; @@ -54,6 +55,14 @@ public class GridCacheMixedPartitionExchangeSelfTest extends GridCommonAbstractT private boolean cache; /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-9470"); + + super.beforeTestsStarted(); + } + + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccMultiThreadedUpdateSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccMultiThreadedUpdateSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccMultiThreadedUpdateSelfTest.java new file mode 100644 index 0000000..4d9fb11 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccMultiThreadedUpdateSelfTest.java @@ -0,0 +1,203 @@ +/* + * 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; + +import java.util.concurrent.Callable; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteTransactions; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.transactions.Transaction; + +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; + +/** + * Multithreaded update test. + */ +public class GridCacheMvccMultiThreadedUpdateSelfTest extends GridCacheOffHeapMultiThreadedUpdateAbstractSelfTest { + /** */ + public static final int THREADS = 5; + + /** {@inheritDoc} */ + @Override protected long getTestTimeout() { + return 5 * 60_000; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-9470"); + + super.beforeTestsStarted(); + } + + /** + * @throws Exception If failed. + */ + public void testTransformTx() throws Exception { + testTransformTx(keyForNode(0)); + + if (gridCount() > 1) + testTransformTx(keyForNode(1)); + } + + /** + * @param key Key. + * @throws Exception If failed. + */ + private void testTransformTx(final Integer key) throws Exception { + final IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); + + cache.put(key, 0); + + final int ITERATIONS_PER_THREAD = iterations(); + + GridTestUtils.runMultiThreaded(new Callable<Void>() { + @Override public Void call() throws Exception { + IgniteTransactions txs = ignite(0).transactions(); + + for (int i = 0; i < ITERATIONS_PER_THREAD && !failed; i++) { + if (i % 500 == 0) + log.info("Iteration " + i); + + try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) { + cache.invoke(key, new IncProcessor()); + + tx.commit(); + } + } + + return null; + } + }, THREADS, "transform"); + + for (int i = 0; i < gridCount(); i++) { + Integer val = (Integer)grid(i).cache(DEFAULT_CACHE_NAME).get(key); + + assertEquals("Unexpected value for grid " + i, (Integer)(ITERATIONS_PER_THREAD * THREADS), val); + } + + if (failed) { + for (int g = 0; g < gridCount(); g++) + info("Value for cache [g=" + g + ", val=" + grid(g).cache(DEFAULT_CACHE_NAME).get(key) + ']'); + + assertFalse(failed); + } + } + + /** + * @throws Exception If failed. + */ + public void testPutTxPessimistic() throws Exception { + testPutTx(keyForNode(0)); + + if (gridCount() > 1) + testPutTx(keyForNode(1)); + } + + /** + * @param key Key. + * @throws Exception If failed. + */ + private void testPutTx(final Integer key) throws Exception { + final IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); + + cache.put(key, 0); + + final int ITERATIONS_PER_THREAD = iterations(); + + GridTestUtils.runMultiThreaded(new Callable<Void>() { + @Override public Void call() throws Exception { + for (int i = 0; i < ITERATIONS_PER_THREAD; i++) { + if (i % 500 == 0) + log.info("Iteration " + i); + + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + Integer val = cache.getAndPut(key, i); + + assertNotNull(val); + + tx.commit(); + } + } + + return null; + } + }, THREADS, "put"); + + for (int i = 0; i < gridCount(); i++) { + Integer val = (Integer)grid(i).cache(DEFAULT_CACHE_NAME).get(key); + + assertNotNull("Unexpected value for grid " + i, val); + } + } + + /** + * @throws Exception If failed. + */ + public void testPutxIfAbsentTxPessimistic() throws Exception { + testPutxIfAbsentTx(keyForNode(0)); + + if (gridCount() > 1) + testPutxIfAbsentTx(keyForNode(1)); + } + + /** + * @param key Key. + * @throws Exception If failed. + */ + private void testPutxIfAbsentTx(final Integer key) throws Exception { + final IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); + + cache.put(key, 0); + + final int ITERATIONS_PER_THREAD = iterations(); + + GridTestUtils.runMultiThreaded(new Callable<Void>() { + @Override public Void call() throws Exception { + for (int i = 0; i < ITERATIONS_PER_THREAD && !failed; i++) { + if (i % 500 == 0) + log.info("Iteration " + i); + + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + cache.putIfAbsent(key, 100); + + tx.commit(); + } + } + + return null; + } + }, THREADS, "putxIfAbsent"); + + for (int i = 0; i < gridCount(); i++) { + Integer val = (Integer)grid(i).cache(DEFAULT_CACHE_NAME).get(key); + + assertEquals("Unexpected value for grid " + i, (Integer)0, val); + } + + assertFalse(failed); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheObjectToStringSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheObjectToStringSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheObjectToStringSelfTest.java index 33b7033..bf87035 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheObjectToStringSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheObjectToStringSelfTest.java @@ -30,6 +30,7 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; @@ -57,6 +58,13 @@ public class GridCacheObjectToStringSelfTest extends GridCommonAbstractTest { private boolean nearEnabled; /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EVICTION); + + super.beforeTestsStarted(); + } + + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java index 8de8e04..6566874 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java @@ -53,9 +53,6 @@ public class GridCacheP2PUndeploySelfTest extends GridCommonAbstractTest { private static final String TEST_VALUE = "org.apache.ignite.tests.p2p.GridCacheDeploymentTestValue3"; /** */ - private static final long OFFHEAP = 0;// 4 * 1024 * 1024; - - /** */ private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); /** */ http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java index 7f82d75..eed5fdb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java @@ -27,6 +27,7 @@ import javax.cache.CacheException; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteException; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; @@ -42,6 +43,7 @@ import org.apache.ignite.transactions.TransactionConcurrency; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; @@ -53,13 +55,10 @@ import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_REA */ public class GridCacheStopSelfTest extends GridCommonAbstractTest { /** */ - private static final String EXPECTED_MSG = "Cache has been closed or destroyed"; - - /** */ private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); /** */ - private boolean atomic; + private CacheAtomicityMode atomicityMode = TRANSACTIONAL; /** */ private boolean replicated; @@ -74,15 +73,14 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest { cfg.setDiscoverySpi(disc); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - - ccfg.setCacheMode(replicated ? REPLICATED : PARTITIONED); + CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME) + .setAtomicityMode(atomicityMode); - if (!replicated) + if (replicated) + ccfg.setCacheMode(REPLICATED); + else ccfg.setBackups(1); - ccfg.setAtomicityMode(atomic ? ATOMIC : TRANSACTIONAL); - cfg.setCacheConfiguration(ccfg); return cfg; @@ -97,6 +95,8 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ public void testStopExplicitTransactions() throws Exception { + atomicityMode = TRANSACTIONAL; + testStop(true); } @@ -104,6 +104,8 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ public void testStopImplicitTransactions() throws Exception { + atomicityMode = TRANSACTIONAL; + testStop(false); } @@ -111,6 +113,7 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ public void testStopExplicitTransactionsReplicated() throws Exception { + atomicityMode = TRANSACTIONAL; replicated = true; testStop(true); @@ -120,6 +123,45 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ public void testStopImplicitTransactionsReplicated() throws Exception { + atomicityMode = TRANSACTIONAL; + replicated = true; + + testStop(false); + } + + /** + * @throws Exception If failed. + */ + public void testStopExplicitMvccTransactions() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; + + testStop(true); + } + + /** + * @throws Exception If failed. + */ + public void testStopImplicitMvccTransactions() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; + + testStop(false); + } + + /** + * @throws Exception If failed. + */ + public void testStopExplicitMvccTransactionsReplicated() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; + replicated = true; + + testStop(true); + } + + /** + * @throws Exception If failed. + */ + public void testStopImplicitMvccTransactionsReplicated() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; replicated = true; testStop(false); @@ -129,7 +171,7 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ public void testStopAtomic() throws Exception { - atomic = true; + atomicityMode = ATOMIC; testStop(false); } @@ -218,6 +260,7 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest { * @param node Node. * @param cache Cache. */ + @SuppressWarnings("unchecked") private void cacheOperations(Ignite node, IgniteCache<Integer, Integer> cache) { ThreadLocalRandom rnd = ThreadLocalRandom.current(); @@ -227,10 +270,12 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest { cache.get(key); - try (Transaction tx = node.transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { - cache.put(key, key); + if (cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() != TRANSACTIONAL_SNAPSHOT) { + try (Transaction tx = node.transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + cache.put(key, key); - tx.commit(); + tx.commit(); + } } try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { @@ -260,7 +305,7 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest { CacheConfiguration ccfg = cache.getConfiguration(CacheConfiguration.class); - assertEquals(atomic ? ATOMIC : TRANSACTIONAL, ccfg.getAtomicityMode()); + assertEquals(atomicityMode, ccfg.getAtomicityMode()); assertEquals(replicated ? REPLICATED : PARTITIONED, ccfg.getCacheMode()); Collection<IgniteInternalFuture<?>> putFuts = new ArrayList<>(); @@ -272,7 +317,8 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest { @Override public Void call() throws Exception { try { if (startTx) { - TransactionConcurrency concurrency = key % 2 == 0 ? OPTIMISTIC : PESSIMISTIC; + TransactionConcurrency concurrency = + atomicityMode != TRANSACTIONAL_SNAPSHOT && (key % 2 == 0) ? OPTIMISTIC : PESSIMISTIC; try (Transaction tx = grid(0).transactions().txStart(concurrency, REPEATABLE_READ)) { cache.put(key, key); http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStorePutxSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStorePutxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStorePutxSelfTest.java deleted file mode 100644 index 2175abb..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStorePutxSelfTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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; - -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.store.CacheStore; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.lang.IgniteBiInClosure; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.apache.ignite.transactions.Transaction; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; - -/** - * Tests for reproduce problem with GG-6895: - * putx calls CacheStore.load() when null GridPredicate passed in to avoid IDE warnings - */ -public class GridCacheStorePutxSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static AtomicInteger loads; - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - - ccfg.setCacheMode(PARTITIONED); - ccfg.setAtomicityMode(TRANSACTIONAL); - ccfg.setWriteSynchronizationMode(FULL_SYNC); - ccfg.setCacheStoreFactory(singletonFactory(new TestStore())); - ccfg.setReadThrough(true); - ccfg.setWriteThrough(true); - ccfg.setLoadPreviousValue(true); - - cfg.setCacheConfiguration(ccfg); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - loads = new AtomicInteger(); - - startGrid(); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopGrid(); - } - - /** - * @throws Exception If failed. - */ - public void testPutShouldNotTriggerLoad() throws Exception { - jcache().put(1, 1); - jcache().put(2, 2); - - assertEquals(0, loads.get()); - } - - /** - * @throws Exception If failed. - */ - public void testPutShouldNotTriggerLoadWithTx() throws Exception { - IgniteCache<Integer, Integer> cache = jcache(); - - try (Transaction tx = grid().transactions().txStart()) { - cache.put(1, 1); - cache.put(2, 2); - - tx.commit(); - } - - assertEquals(0, loads.get()); - } - - /** */ - private static class TestStore implements CacheStore<Integer, Integer> { - /** {@inheritDoc} */ - @Nullable @Override public Integer load(Integer key) { - loads.incrementAndGet(); - - return null; - } - - /** {@inheritDoc} */ - @Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo, @Nullable Object... args) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public Map<Integer, Integer> loadAll(Iterable<? extends Integer> keys) { - return Collections.emptyMap(); - } - - /** {@inheritDoc} */ - @Override public void write(javax.cache.Cache.Entry<? extends Integer, ? extends Integer> entry) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void writeAll(Collection<javax.cache.Cache.Entry<? extends Integer, ? extends Integer>> entries) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void delete(Object key) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void deleteAll(Collection<?> keys) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void sessionEnd(boolean commit) { - // No-op. - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java index 66ef47c..e981e2b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java @@ -31,6 +31,7 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; /** @@ -50,6 +51,14 @@ public class GridCacheTtlManagerEvictionSelfTest extends GridCommonAbstractTest private volatile CacheMode cacheMode; /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EXPIRATION); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EVICTION); + + super.beforeTestsStarted(); + } + + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerSelfTest.java index 52f19b7..c48913e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerSelfTest.java @@ -29,6 +29,7 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import static java.util.concurrent.TimeUnit.MILLISECONDS; @@ -47,6 +48,13 @@ public class GridCacheTtlManagerSelfTest extends GridCommonAbstractTest { protected CacheMode cacheMode; /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EXPIRATION); + + super.beforeTestsStarted(); + } + + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); http://git-wip-us.apache.org/repos/asf/ignite/blob/2b2f50ca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTxPartitionedLocalStoreSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTxPartitionedLocalStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTxPartitionedLocalStoreSelfTest.java index 272665b..9000c95 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTxPartitionedLocalStoreSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTxPartitionedLocalStoreSelfTest.java @@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -28,6 +29,13 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED; */ public class GridCacheTxPartitionedLocalStoreSelfTest extends GridCacheAbstractLocalStoreSelfTest { /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.beforeTestsStarted(); + } + + /** {@inheritDoc} */ @Override protected CacheAtomicityMode getAtomicMode() { return TRANSACTIONAL; }