ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [40/50] [abbrv] incubator-ignite git commit: # added test
Date Tue, 19 May 2015 17:55:54 GMT
# added test


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/2149639d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/2149639d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/2149639d

Branch: refs/heads/ignite-648
Commit: 2149639dd360ad6f180e16d23dbe878b05cc730a
Parents: a27a35d
Author: sboikov <semen.boikov@inria.fr>
Authored: Sat May 16 06:59:51 2015 +0300
Committer: sboikov <semen.boikov@inria.fr>
Committed: Sat May 16 06:59:51 2015 +0300

----------------------------------------------------------------------
 .../near/IgniteCacheNearOnlyTxTest.java         | 52 +++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2149639d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java
index 06a4bfc..88e7f03 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache.distributed.near;
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.testframework.*;
 import org.apache.ignite.transactions.*;
@@ -77,7 +78,7 @@ public class IgniteCacheNearOnlyTxTest extends IgniteCacheAbstractTest {
 
         ignite1.createNearCache(null, new NearCacheConfiguration<>());
 
-        GridTestUtils.runMultiThreaded(new Callable<Object>() {
+        GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
             @Override public Object call() throws Exception {
                 IgniteCache cache = ignite1.cache(null);
 
@@ -137,4 +138,53 @@ public class IgniteCacheNearOnlyTxTest extends IgniteCacheAbstractTest
{
             }
         }, 5, "put-thread");
     }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testConcurrentTx() throws Exception {
+        final Ignite ignite1 = ignite(1);
+
+        assertTrue(ignite1.configuration().isClientMode());
+
+        ignite1.createNearCache(null, new NearCacheConfiguration<>());
+
+        IgniteInternalFuture<?> fut1 = GridTestUtils.runMultiThreadedAsync(new Callable<Object>()
{
+            @Override public Object call() throws Exception {
+                IgniteCache cache = ignite1.cache(null);
+
+                int key = 1;
+
+                for (int i = 0; i < 100; i++)
+                    cache.put(key, 1);
+
+                return null;
+            }
+        }, 5, "put1-thread");
+
+        IgniteInternalFuture<?> fut2 = GridTestUtils.runMultiThreadedAsync(new Callable<Object>()
{
+            @Override public Object call() throws Exception {
+                IgniteCache cache = ignite1.cache(null);
+
+                int key = 1;
+
+                IgniteTransactions txs = ignite1.transactions();
+
+                for (int i = 0; i < 100; i++) {
+                    try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
+                        cache.get(key);
+
+                        cache.put(key, 1);
+
+                        tx.commit();
+                    }
+                }
+
+                return null;
+            }
+        }, 5, "put2-thread");
+
+        fut1.get();
+        fut2.get();
+    }
 }


Mime
View raw message