You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/10/24 08:47:46 UTC
[39/50] [abbrv] ignite git commit: IGNITE-6713 Ignite Cache 5 flaky
test CacheRebalancingSelfTest.testDisableRebalancing fixed - Fixes #2907.
IGNITE-6713 Ignite Cache 5 flaky test CacheRebalancingSelfTest.testDisableRebalancing fixed - Fixes #2907.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0e77ea12
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0e77ea12
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0e77ea12
Branch: refs/heads/ignite-3478-tree
Commit: 0e77ea1226c8550efdeaf031de8c47ef3153ab31
Parents: 1294bef
Author: dpavlov <dp...@gridgain.com>
Authored: Mon Oct 23 17:16:31 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Oct 23 17:16:31 2017 +0300
----------------------------------------------------------------------
.../cache/CacheRebalancingSelfTest.java | 41 ++++++++++----------
1 file changed, 21 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0e77ea12/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalancingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalancingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalancingSelfTest.java
index 421ff08..e5a836a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalancingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalancingSelfTest.java
@@ -18,7 +18,8 @@
package org.apache.ignite.internal.processors.cache;
-import com.sun.org.apache.regexp.internal.RE;
+import java.util.HashSet;
+import java.util.Set;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CachePeekMode;
@@ -31,11 +32,8 @@ import org.apache.ignite.internal.util.future.IgniteFutureImpl;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.testframework.GridTestUtils;
-import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Random;
/**
@@ -113,39 +111,42 @@ public class CacheRebalancingSelfTest extends GridCommonAbstractTest {
Random r = new Random();
- int totalKeysCount = 10240;
+ int totalKeysCnt = 10240;
- IgniteCache<Integer, Integer> cache = ig0.getOrCreateCache(REBALANCE_TEST_CACHE_NAME);
+ final Set<Integer> keys = new HashSet<>();
+ while (keys.size() < totalKeysCnt)
+ keys.add(r.nextInt());
- for (int i = 0;i < totalKeysCount;i++)
- cache.put(r.nextInt(), 1);
+ IgniteCache<Integer, Integer> cache = ig0.getOrCreateCache(REBALANCE_TEST_CACHE_NAME);
+ for (Integer next : keys)
+ cache.put(next, 1);
- testLocalCacheSize(ig0, 0, totalKeysCount);
- int before_ig1 = testLocalCacheSize(ig1, 0, totalKeysCount);
+ testLocalCacheSize(ig0, 0, totalKeysCnt);
+ int before_ig1 = testLocalCacheSize(ig1, 0, totalKeysCnt);
stopGrid(2);
- testLocalCacheSize(ig0, totalKeysCount, null);
+ testLocalCacheSize(ig0, totalKeysCnt, null);
testLocalCacheSize(ig1, before_ig1, null);
ig1.rebalanceEnabled(true);
- testLocalCacheSize(ig0, totalKeysCount, null);
- testLocalCacheSize(ig1, totalKeysCount, null);
+ testLocalCacheSize(ig0, totalKeysCnt, null);
+ testLocalCacheSize(ig1, totalKeysCnt, null);
}
/**
- * Test if test cache in specified node have correct local size.
+ * Test if test cache in specified node have correct local size. Waits size to became correct for some time.
*
- * @param ignite node to test
- * @param expFrom left bound
- * @param expTo right bound (or {@code null})
- * @return actual local cache size
- * @throws IgniteInterruptedCheckedException
+ * @param ignite node to test.
+ * @param expFrom left bound, or exact value if {@code expTo} is {@code null}.
+ * @param expTo right bound (or {@code null}).
+ * @return actual local cache size.
+ * @throws IgniteInterruptedCheckedException if interrupted.
*/
- private int testLocalCacheSize(IgniteEx ignite, final Integer expFrom, final Integer expTo) throws IgniteInterruptedCheckedException {
+ private int testLocalCacheSize(Ignite ignite, final Integer expFrom, final Integer expTo) throws IgniteInterruptedCheckedException {
final IgniteCache cache = ignite.cache(REBALANCE_TEST_CACHE_NAME);
boolean isOk = GridTestUtils.waitForCondition(new GridAbsPredicate() {