You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2018/05/15 11:52:55 UTC
ignite git commit: IGNITE-6430 Fix for
CacheGroupsMetricsRebalanceTest.testRebalanceEstimateFinishTime test fails
periodically. - Fixes #3914.
Repository: ignite
Updated Branches:
refs/heads/master 0bb56a64e -> d9c482137
IGNITE-6430 Fix for CacheGroupsMetricsRebalanceTest.testRebalanceEstimateFinishTime test fails periodically. - Fixes #3914.
Signed-off-by: dpavlov <dp...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d9c48213
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d9c48213
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d9c48213
Branch: refs/heads/master
Commit: d9c4821373d4282483d32be0a3a17412445bf855
Parents: 0bb56a6
Author: Alexander Menshikov <sh...@gmail.com>
Authored: Tue May 15 14:52:41 2018 +0300
Committer: dpavlov <dp...@apache.org>
Committed: Tue May 15 14:52:41 2018 +0300
----------------------------------------------------------------------
.../cache/CacheGroupsMetricsRebalanceTest.java | 53 +++++++++++---------
1 file changed, 30 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d9c48213/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java
index ceb9852..a055909 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java
@@ -177,8 +177,6 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest {
final int KEYS = 4_000_000;
- IgniteCache<Object, Object> cache1 = ig1.cache(CACHE1);
-
try (IgniteDataStreamer<Integer, String> st = ig1.dataStreamer(CACHE1)) {
for (int i = 0; i < KEYS; i++)
st.addData(i, CACHE1 + "-" + i);
@@ -193,7 +191,7 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest {
CacheRebalancingEvent rebEvent = (CacheRebalancingEvent)evt;
if (rebEvent.cacheName().equals(CACHE1)) {
- System.out.println("CountDown rebalance stop latch:" + rebEvent.cacheName());
+ log.info("CountDown rebalance stop latch: " + rebEvent.cacheName());
finishRebalanceLatch.countDown();
}
@@ -211,10 +209,10 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest {
CacheMetrics metrics = ig2.cache(CACHE1).localMetrics();
long startTime = metrics.getRebalancingStartTime();
+ long currTime = U.currentTimeMillis();
- assertTrue(startTime > 0);
- assertTrue((U.currentTimeMillis() - startTime) < 5000);
- assertTrue((U.currentTimeMillis() - startTime) > 0);
+ assertTrue("Invalid start time [startTime=" + startTime + ", currTime=" + currTime + ']',
+ startTime > 0L && (currTime - startTime) >= 0L && (currTime - startTime) <= 5000L);
final CountDownLatch latch = new CountDownLatch(1);
@@ -223,9 +221,9 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest {
// Waiting 25% keys will be rebalanced.
int partKeys = KEYS / 2;
- final long keysLine = (long)(partKeys - (partKeys * 0.25));
+ final long keysLine = partKeys * 3L / 4L;
- System.out.println("Wait until keys left will be less " + keysLine);
+ log.info("Wait until keys left will be less than: " + keysLine);
try {
while (finishRebalanceLatch.getCount() != 0) {
@@ -236,13 +234,13 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest {
if (keyLeft > 0 && keyLeft < keysLine)
latch.countDown();
- System.out.println("Keys left: " + m.getKeysToRebalanceLeft());
+ log.info("Keys left: " + m.getKeysToRebalanceLeft());
try {
Thread.sleep(1_000);
}
catch (InterruptedException e) {
- System.out.println("Interrupt thread: " + e.getMessage());
+ log.warning("Interrupt thread", e);
Thread.currentThread().interrupt();
}
@@ -256,30 +254,39 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest {
assertTrue(latch.await(getTestTimeout(), TimeUnit.MILLISECONDS));
+ waitForCondition(new PA() {
+ @Override public boolean apply() {
+ return ig2.cache(CACHE1).localMetrics().getEstimatedRebalancingFinishTime() != -1L;
+ }
+ }, 5_000L);
+
long finishTime = ig2.cache(CACHE1).localMetrics().getEstimatedRebalancingFinishTime();
- assertTrue(finishTime > 0);
+ assertTrue("Not a positive estimation of rebalancing finish time: " + finishTime,
+ finishTime > 0L);
+
+ currTime = U.currentTimeMillis();
- long timePassed = U.currentTimeMillis() - startTime;
- long timeLeft = finishTime - System.currentTimeMillis();
+ long timePassed = currTime - startTime;
+ long timeLeft = finishTime - currTime;
- assertTrue(finishRebalanceLatch.await(timeLeft + 2_000, TimeUnit.SECONDS));
+ assertTrue("Got timeout while waiting for rebalancing. Estimated left time: " + timeLeft,
+ finishRebalanceLatch.await(timeLeft + 2_000L, TimeUnit.MILLISECONDS));
- System.out.println(
- "TimePassed:" + timePassed +
- "\nTimeLeft:" + timeLeft +
- "\nTime to rebalance: " + (finishTime - startTime) +
- "\nStartTime: " + startTime +
- "\nFinishTime: " + finishTime
+ log.info("[timePassed=" + timePassed + ", timeLeft=" + timeLeft +
+ ", Time to rebalance=" + (finishTime - startTime) +
+ ", startTime=" + startTime + ", finishTime=" + finishTime + ']'
);
System.clearProperty(IGNITE_REBALANCE_STATISTICS_TIME_INTERVAL);
- System.out.println("Rebalance time:" + (U.currentTimeMillis() - startTime));
+ currTime = U.currentTimeMillis();
+
+ log.info("Rebalance time: " + (currTime - startTime));
- long diff = finishTime - U.currentTimeMillis();
+ long diff = finishTime - currTime;
- assertTrue("Expected less 5000, Actual:" + diff, Math.abs(diff) < 10_000);
+ assertTrue("Expected less than 10000, but actual: " + diff, Math.abs(diff) < 10_000L);
}
/**