Skip to content
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

HDDS-11927. Fix flaky TestContainerBalancerStatusInfo.testGetCurrentStatisticsWhileBalancingInProgress #7579

Merged
merged 2 commits into from
Dec 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading