-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignite-6430: CacheGroupsMetricsRebalanceTest.testRebalanceEstimateFinishTime test fails periodically #3914
Ignite-6430: CacheGroupsMetricsRebalanceTest.testRebalanceEstimateFinishTime test fails periodically #3914
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,7 +193,7 @@ public void testRebalanceEstimateFinishTime() throws Exception { | |
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(); | ||
} | ||
|
@@ -206,15 +206,15 @@ public void testRebalanceEstimateFinishTime() throws Exception { | |
@Override public boolean apply() { | ||
return ig2.cache(CACHE1).localMetrics().getRebalancingStartTime() != -1L; | ||
} | ||
}, 5_000); | ||
}, 5_000L); | ||
|
||
CacheMetrics metrics = ig2.cache(CACHE1).localMetrics(); | ||
|
||
long startTime = metrics.getRebalancingStartTime(); | ||
long currentTime = System.currentTimeMillis(); | ||
|
||
assertTrue(startTime > 0); | ||
assertTrue((U.currentTimeMillis() - startTime) < 5000); | ||
assertTrue((U.currentTimeMillis() - startTime) > 0); | ||
assertTrue("Invalid start time: " + startTime + ", but the current time: " + currentTime + '.', | ||
startTime > 0L && (currentTime - startTime) >= 0L && (currentTime - startTime) <= 5000L); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should take rebalancing delay into consideration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @1vanan There is no delay in |
||
|
||
final CountDownLatch latch = new CountDownLatch(1); | ||
|
||
|
@@ -223,26 +223,26 @@ public void testRebalanceEstimateFinishTime() throws Exception { | |
// Waiting 25% keys will be rebalanced. | ||
int partKeys = KEYS / 2; | ||
|
||
final long keysLine = (long)(partKeys - (partKeys * 0.25)); | ||
final long keysLine = partKeys - partKeys / 4; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think, it could be transform to something like partKeys*3/4, due to partKeys is long and partKeys is int and overflow is excluded. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @1vanan Done |
||
|
||
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) { | ||
while (finishRebalanceLatch.getCount() != 0L) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove L postfix from this place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @1vanan Done |
||
CacheMetrics m = ig2.cache(CACHE1).localMetrics(); | ||
|
||
long keyLeft = m.getKeysToRebalanceLeft(); | ||
|
||
if (keyLeft > 0 && keyLeft < keysLine) | ||
if (keyLeft > 0L && keyLeft < keysLine) | ||
latch.countDown(); | ||
|
||
System.out.println("Keys left: " + m.getKeysToRebalanceLeft()); | ||
log.info("Keys left: " + m.getKeysToRebalanceLeft() + '.'); | ||
|
||
try { | ||
Thread.sleep(1_000); | ||
Thread.sleep(1_000L); | ||
} | ||
catch (InterruptedException e) { | ||
System.out.println("Interrupt thread: " + e.getMessage()); | ||
log.warning("Interrupt thread.", e); | ||
|
||
Thread.currentThread().interrupt(); | ||
} | ||
|
@@ -254,32 +254,44 @@ public void testRebalanceEstimateFinishTime() throws Exception { | |
} | ||
}); | ||
|
||
assertTrue(latch.await(getTestTimeout(), TimeUnit.MILLISECONDS)); | ||
assertTrue("Got timeout while waiting 25% keys will be rebalanced.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this message, pls. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @1vanan Done |
||
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); | ||
|
||
long timePassed = U.currentTimeMillis() - startTime; | ||
long timeLeft = finishTime - System.currentTimeMillis(); | ||
currentTime = System.currentTimeMillis(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May be use U.currentTimeMillis() instead of System.currentTimeMillis()? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @1vanan Done |
||
long timePassed = currentTime - startTime; | ||
long timeLeft = finishTime - currentTime; | ||
|
||
assertTrue(finishRebalanceLatch.await(timeLeft + 2_000, TimeUnit.SECONDS)); | ||
assertTrue("Got timeout while waiting to rebalance. Estimated left time: " + timeLeft + '.', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'Got timeout while waiting for rebalance' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @1vanan Done |
||
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 + '.' + | ||
U.nl() + "TimeLeft: " + timeLeft + '.' + | ||
U.nl() + "Time to rebalance: " + (finishTime - startTime) + '.' + | ||
U.nl() + "StartTime: " + startTime + '.' + | ||
U.nl() + "FinishTime: " + finishTime + '.' | ||
); | ||
|
||
System.clearProperty(IGNITE_REBALANCE_STATISTICS_TIME_INTERVAL); | ||
|
||
System.out.println("Rebalance time:" + (U.currentTimeMillis() - startTime)); | ||
currentTime = System.currentTimeMillis(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about U.currentTimeMillis()? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @1vanan Done |
||
|
||
log.info("Rebalance time: " + (currentTime - startTime) + '.'); | ||
|
||
long diff = finishTime - U.currentTimeMillis(); | ||
long diff = finishTime - currentTime; | ||
|
||
assertTrue("Expected less 5000, Actual:" + diff, Math.abs(diff) < 10_000); | ||
assertTrue("Expected less than 5000, but actual: " + diff + '.', Math.abs(diff) < 10_000L); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @1vanan Done |
||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change it with U.currentTimeMillis(); pls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@1vanan Done