You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by nt...@apache.org on 2016/08/02 11:15:19 UTC
ignite git commit: IGNITE-3601 Added tests for "Read-only optimistic
transaction shouldn't throw an exception if entry version was not changed".
This closes #915.
Repository: ignite
Updated Branches:
refs/heads/master 6433b04dd -> 04eb59e7b
IGNITE-3601 Added tests for "Read-only optimistic transaction shouldn't throw an exception if entry version was not changed". This closes #915.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/04eb59e7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/04eb59e7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/04eb59e7
Branch: refs/heads/master
Commit: 04eb59e7b366f97c1883915ca9fcd6d1dd3477d0
Parents: 6433b04
Author: AndreyVel <an...@gmail.com>
Authored: Tue Aug 2 10:55:38 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Tue Aug 2 14:14:52 2016 +0300
----------------------------------------------------------------------
.../cache/CacheGetEntryAbstractTest.java | 37 ++++++++++++++++++++
1 file changed, 37 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/04eb59e7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java
index 34480a2..b9f4b02 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java
@@ -40,6 +40,7 @@ import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionIsolation;
+import org.apache.ignite.transactions.TransactionOptimisticException;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
@@ -52,6 +53,7 @@ import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
/**
* Test getEntry and getEntries methods.
@@ -247,6 +249,10 @@ public abstract class CacheGetEntryAbstractTest extends GridCacheAbstractSelfTes
testConcurrentTx(cache, PESSIMISTIC, REPEATABLE_READ, oneEntry);
testConcurrentTx(cache, PESSIMISTIC, READ_COMMITTED, oneEntry);
+
+ testConcurrentOptimisticTxGet(cache, REPEATABLE_READ);
+ testConcurrentOptimisticTxGet(cache, READ_COMMITTED);
+ testConcurrentOptimisticTxGet(cache, SERIALIZABLE);
}
}
finally {
@@ -256,6 +262,37 @@ public abstract class CacheGetEntryAbstractTest extends GridCacheAbstractSelfTes
/**
* @param cache Cache.
+ * @param txIsolation Transaction isolation.
+ * @throws Exception If failed.
+ */
+ private void testConcurrentOptimisticTxGet(final IgniteCache<Integer, TestValue> cache,
+ final TransactionIsolation txIsolation) throws Exception {
+ GridTestUtils.runMultiThreaded(new Runnable() {
+ @Override public void run() {
+ final int key = 42;
+
+ IgniteTransactions txs = grid(0).transactions();
+
+ cache.put(key, new TestValue(key));
+
+ long stopTime = System.currentTimeMillis() + 3000;
+
+ while (System.currentTimeMillis() < stopTime) {
+ try (Transaction tx = txs.txStart(OPTIMISTIC, txIsolation)) {
+ cache.get(key);
+
+ tx.commit();
+ }
+ catch (TransactionOptimisticException e) {
+ fail("Should not throw optimistic exception in only read TX. Tx isolation: " + txIsolation);
+ }
+ }
+ }
+ }, 10, "tx-thread");
+ }
+
+ /**
+ * @param cache Cache.
* @param txConcurrency Transaction concurrency.
* @param txIsolation Transaction isolation.
* @param oneEntry If {@code true} then single entry is tested.