# sprint-3 More simple test reproducing issue
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/71ecef20 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/71ecef20 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/71ecef20 Branch: refs/heads/ignite-443 Commit: 71ecef20400824a699b16742c13f22e445fe2189 Parents: 2aec8da Author: sboikov <sboi...@gridgain.com> Authored: Fri Mar 27 13:17:50 2015 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Fri Mar 27 13:17:50 2015 +0300 ---------------------------------------------------------------------- ...idCacheValueConsistencyAbstractSelfTest.java | 57 ++++++++++++++++++++ 1 file changed, 57 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/71ecef20/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java index ba38496..f6e3ec0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java @@ -227,6 +227,56 @@ public abstract class GridCacheValueConsistencyAbstractSelfTest extends GridCach /** * @throws Exception If failed. */ + public void testPutConsistencyMultithreaded() throws Exception { + for (int i = 0; i < 20; i++) { + log.info("Iteration: " + i); + + final int range = 100; + + final int iterCnt = 100; + + final AtomicInteger threadId = new AtomicInteger(); + + final AtomicInteger iters = new AtomicInteger(); + + multithreadedAsync(new Callable<Object>() { + @Override public Object call() throws Exception { + Random rnd = new Random(); + + int g = threadId.getAndIncrement(); + + Ignite ignite = grid(g); + + IgniteCache<Object, Object> cache = ignite.cache(null); + + log.info("Update thread: " + ignite.name()); + + Thread.currentThread().setName("UpdateThread-" + ignite.name()); + + Long val = (long)g; + + while (true) { + int i = iters.getAndIncrement(); + + if (i >= iterCnt) + break; + + int k = rnd.nextInt(range); + + cache.put(k, val); + } + + return null; + } + }, gridCount()).get(); + + checkConsistency(range); + } + } + + /** + * @throws Exception If failed. + */ public void testPutRemoveConsistencyMultithreaded() throws Exception { for (int i = 0; i < 10; i++) { log.info("Iteration: " + i); @@ -278,6 +328,13 @@ public abstract class GridCacheValueConsistencyAbstractSelfTest extends GridCach } }, THREAD_CNT).get(); + checkConsistency(range); + } + + /** + * @param range Key range. + */ + private void checkConsistency(int range) { int present = 0; int absent = 0;