Skip to content

Commit

Permalink
HDDS-11927. Fix flaky TestContainerBalancerStatusInfo.testGetCurrentS…
Browse files Browse the repository at this point in the history
…tatisticsWhileBalancingInProgress (#7579)
  • Loading branch information
juncevich authored Dec 15, 2024
1 parent bef2415 commit f5e5493
Showing 1 changed file with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.ozone.test.LambdaTestUtils;
import org.apache.ozone.test.tag.Flaky;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -95,9 +94,9 @@ void testGetCurrentStatisticsRequestInPeriodBetweenIterations() throws Exception
config.setMaxSizeToMovePerIteration(50 * OzoneConsts.GB);

ContainerBalancerTask task = mockedScm.startBalancerTaskAsync(config, false);
LambdaTestUtils.await(1000, 500,
LambdaTestUtils.await(5000, 10,
() -> task.getCurrentIterationsStatistic().size() == 1 &&
task.getCurrentIterationsStatistic().get(0).getIterationResult().equals("ITERATION_COMPLETED"));
"ITERATION_COMPLETED".equals(task.getCurrentIterationsStatistic().get(0).getIterationResult()));
List<ContainerBalancerTaskIterationStatusInfo> iterationsStatic = task.getCurrentIterationsStatistic();
assertEquals(1, iterationsStatic.size());

Expand Down Expand Up @@ -150,7 +149,6 @@ void testGetCurrentStatisticsWithDelay() throws Exception {
}

@Test
@Flaky("HDDS-11927")
void testGetCurrentStatisticsWhileBalancingInProgress() throws Exception {
MockedSCM mockedScm = new MockedSCM(new TestableCluster(20, OzoneConsts.GB));

Expand All @@ -162,7 +160,7 @@ void testGetCurrentStatisticsWhileBalancingInProgress() throws Exception {

ContainerBalancerTask task = mockedScm.startBalancerTaskAsync(config, false);
// Get the current iteration statistics when it has information about the containers moving.
LambdaTestUtils.await(1000, 10,
LambdaTestUtils.await(5000, 1,
() -> task.getCurrentIterationsStatistic().size() == 2 &&
task.getCurrentIterationsStatistic().get(1).getContainerMovesScheduled() > 0);
List<ContainerBalancerTaskIterationStatusInfo> iterationsStatic = task.getCurrentIterationsStatistic();
Expand All @@ -174,18 +172,11 @@ void testGetCurrentStatisticsWhileBalancingInProgress() throws Exception {
private static void assertCurrentIterationStatisticWhileBalancingInProgress(
ContainerBalancerTaskIterationStatusInfo iterationsStatic
) {

// No need to check others iterationsStatic fields(e.x. '*ContainerMoves*'), because it can lead to flaky results.
assertEquals(2, iterationsStatic.getIterationNumber());
assertEquals(0, iterationsStatic.getIterationDuration());
assertNull(iterationsStatic.getIterationResult());
assertTrue(iterationsStatic.getContainerMovesScheduled() > 0);
assertTrue(iterationsStatic.getContainerMovesCompleted() > 0);
assertEquals(0, iterationsStatic.getContainerMovesFailed());
assertEquals(0, iterationsStatic.getContainerMovesTimeout());
assertTrue(iterationsStatic.getSizeScheduledForMove() > 0);
assertTrue(iterationsStatic.getDataSizeMoved() > 0);
assertFalse(iterationsStatic.getSizeEnteringNodes().isEmpty());
assertFalse(iterationsStatic.getSizeLeavingNodes().isEmpty());
iterationsStatic.getSizeEnteringNodes().forEach((id, size) -> {
assertNotNull(id);
assertTrue(size > 0);
Expand All @@ -194,9 +185,6 @@ private static void assertCurrentIterationStatisticWhileBalancingInProgress(
assertNotNull(id);
assertTrue(size > 0);
});
Long enteringDataSum = getTotalMovedData(iterationsStatic.getSizeEnteringNodes());
Long leavingDataSum = getTotalMovedData(iterationsStatic.getSizeLeavingNodes());
assertEquals(enteringDataSum, leavingDataSum);
}

private void verifyCompletedIteration(
Expand Down

0 comments on commit f5e5493

Please sign in to comment.