Repository: ignite
Updated Branches:
  refs/heads/ignite-627 0ed37afb3 -> f9c06b853


ignite-627


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

Branch: refs/heads/ignite-627
Commit: f9c06b853038a76c392ace3a6b4ac200dcd7fbe7
Parents: 0ed37af
Author: sboikov <sboi...@apache.org>
Authored: Tue Oct 30 09:23:59 2018 +0300
Committer: sboikov <sboi...@apache.org>
Committed: Tue Oct 30 09:23:59 2018 +0300

----------------------------------------------------------------------
 .../atomic/IgniteCacheAtomicProtocolTest.java   | 101 ++++++++++++++++++-
 1 file changed, 96 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f9c06b85/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
index 1c6b8cb..d54143b 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
@@ -879,14 +879,36 @@ public class IgniteCacheAtomicProtocolTest extends 
GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
-    public void testNearEntryUpdateRace() throws Exception {
+    public void testNearEntryUpdateRace_Put() throws Exception {
+        nearEntryUpdateRace("put");
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNearEntryUpdateRace_PutIfAbsent() throws Exception {
+        nearEntryUpdateRace("putIfAbsent");
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNearEntryUpdateRace_Invoke() throws Exception {
+        nearEntryUpdateRace("invoke");
+    }
+
+    /**
+     * @param cacheOp Cache operation.
+     * @throws Exception If failed.
+     */
+    private void nearEntryUpdateRace(String cacheOp) throws Exception {
         ccfg = cacheConfiguration(1, FULL_SYNC);
 
         client = false;
 
         Ignite srv0 = startGrid(0);
 
-        IgniteCache<Object, Object> srvCache = srv0.cache(TEST_CACHE);
+        IgniteCache<Integer, Integer> srvCache = srv0.cache(TEST_CACHE);
 
         int key = 0;
 
@@ -896,13 +918,28 @@ public class IgniteCacheAtomicProtocolTest extends 
GridCommonAbstractTest {
 
         Ignite client1 = startGrid(1);
 
-        IgniteCache<Object, Object> nearCache = 
client1.createNearCache(TEST_CACHE, new NearCacheConfiguration<>());
+        IgniteCache<Integer, Integer> nearCache = 
client1.createNearCache(TEST_CACHE, new NearCacheConfiguration<>());
 
         testSpi(srv0).blockMessages(GridNearAtomicUpdateResponse.class, 
client1.name());
 
         IgniteInternalFuture<?> nearPutFut = GridTestUtils.runAsync(new 
Runnable() {
             @Override public void run() {
-                nearCache.put(key, 1);
+                switch (cacheOp) {
+                    case "put":
+                        nearCache.put(key, 1);
+                        break;
+
+                    case "putIfAbsent":
+                        assertTrue(nearCache.putIfAbsent(key, 1));
+                        break;
+
+                    case "invoke":
+                        nearCache.invoke(key, new SetValueEntryProcessor(1));
+                        break;
+
+                    default:
+                        fail("Invalid operation: " + cacheOp);
+                }
             }
         });
 
@@ -916,7 +953,61 @@ public class IgniteCacheAtomicProtocolTest extends 
GridCommonAbstractTest {
 
         nearPutFut.get();
 
-        assertEquals(2, nearCache.get(key));
+        assertEquals((Integer)2, nearCache.get(key));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNearEntryUpdateRace_PutAll() throws Exception {
+        ccfg = cacheConfiguration(1, FULL_SYNC);
+
+        client = false;
+
+        Ignite srv0 = startGrid(0);
+
+        IgniteCache<Integer, Integer> srvCache = srv0.cache(TEST_CACHE);
+
+        final int keys = 100;
+
+        ccfg = null;
+
+        client = true;
+
+        Ignite client1 = startGrid(1);
+
+        IgniteCache<Integer, Integer> nearCache = 
client1.createNearCache(TEST_CACHE, new NearCacheConfiguration<>());
+
+        testSpi(srv0).blockMessages(GridNearAtomicUpdateResponse.class, 
client1.name());
+
+        IgniteInternalFuture<?> nearPutFut = GridTestUtils.runAsync(new 
Runnable() {
+            @Override public void run() {
+                Map<Integer, Integer> map = new HashMap<>();
+
+                for (int i = 0; i < keys; i++)
+                    map.put(i, i);
+
+                nearCache.putAll(map);
+            }
+        });
+
+        testSpi(srv0).waitForBlocked();
+
+        Map<Integer, Integer> map = new HashMap<>();
+
+        for (int i = 0; i < keys; i++)
+            map.put(i, i + 10_000);
+
+        srvCache.putAll(map);
+
+        assertFalse(nearPutFut.isDone());
+
+        testSpi(srv0).stopBlock();
+
+        nearPutFut.get();
+
+        for (int i = 0; i < keys; i++)
+            assertEquals((Integer)(i + 10_000), nearCache.get(i));
     }
 
     /**

Reply via email to