adoroszlai opened a new pull request, #7989:
URL: https://github.com/apache/ozone/pull/7989

   ## What changes were proposed in this pull request?
   
   Fix intermittent test failure:
   
   ```
   Tests run: 8, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.411 s <<< 
FAILURE! - in 
org.apache.hadoop.hdds.scm.cli.datanode.TestContainerBalancerSubCommand
   
org.apache.hadoop.hdds.scm.cli.datanode.TestContainerBalancerSubCommand.testContainerBalancerStatusInfoSubcommandVerboseHistory
  Time elapsed: 0.127 s  <<< FAILURE!
   AssertionFailedError: expected: <true> but was: <false>
     ...
     at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:183)
     at 
org.apache.hadoop.hdds.scm.cli.datanode.TestContainerBalancerSubCommand.testContainerBalancerStatusInfoSubcommandVerboseHistory(TestContainerBalancerSubCommand.java:305)
   ```
   
   which occurs if balancer happens to be started at the start of the minute 
(`:00` seconds).  It is caused by relying on `LocalTime.toString()`, which 
omits 0 seconds from output, but the test expects it in HH:MM:SS format.
   
   Reproduced the problem in `flaky-test-check`:
   
https://github.com/adoroszlai/ozone/actions/runs/13592212498/job/38002149684#step:7:858
   
   The problem can be consistently reproduced by applying tweak:
   
   ```diff
   --- 
hadoop-hdds/tools/src/test/java/org/apache/hadoop/hdds/scm/cli/datanode/TestContainerBalancerSubCommand.java
   +++ 
hadoop-hdds/tools/src/test/java/org/apache/hadoop/hdds/scm/cli/datanode/TestContainerBalancerSubCommand.java
   @@ -173,7 +173,7 @@ private static ContainerBalancerStatusInfoResponseProto 
getContainerBalancerStat
        return ContainerBalancerStatusInfoResponseProto.newBuilder()
                .setIsRunning(true)
                
.setContainerBalancerStatusInfo(ContainerBalancerStatusInfoProto.newBuilder()
   -                .setStartedAt(OffsetDateTime.now().toEpochSecond())
   +                
.setStartedAt(OffsetDateTime.now().truncatedTo(java.time.temporal.ChronoUnit.MINUTES).toEpochSecond())
                    
.setConfiguration(config.toProtobufBuilder().setShouldRun(true))
                    .addAllIterationsStatusInfo(
                        Arrays.asList(iteration1StatusInfo, 
iteration2StatusInfo, iteration3StatusInfo)
   ```
   
   It is fixed by using ISO formatter instead of `toString()`.
   
   Also improve `TestContainerBalancerSubCommand`:
   
   - change assertions to `assertThat` to show expected and actual input
   - reduce duplication
   
   https://issues.apache.org/jira/browse/HDDS-12443
   
   ## How was this patch tested?
   
   Verified that the test passes even with the tweak, plus an additional change 
needed to avoid flakiness caused by the tweak itself:
   
   ```diff
   --- 
hadoop-hdds/tools/src/test/java/org/apache/hadoop/hdds/scm/cli/datanode/TestContainerBalancerSubCommand.java
   +++ 
hadoop-hdds/tools/src/test/java/org/apache/hadoop/hdds/scm/cli/datanode/TestContainerBalancerSubCommand.java
   @@ -48,7 +48,7 @@
    class TestContainerBalancerSubCommand {
    
      public static final Pattern DURATION = Pattern.compile(
   -      "^Balancing duration: \\d{1}s$", Pattern.MULTILINE);
   +      "^Balancing duration: \\d+s$", Pattern.MULTILINE);
      public static final Pattern FAILED_TO_START = Pattern.compile(
          "^Failed\\sto\\sstart\\sContainer\\sBalancer.");
      public static final Pattern IS_NOT_RUNNING = Pattern.compile(
   @@ -199,7 +199,7 @@ private static ContainerBalancerStatusInfoResponseProto 
getContainerBalancerStat
        return ContainerBalancerStatusInfoResponseProto.newBuilder()
                .setIsRunning(true)
                
.setContainerBalancerStatusInfo(ContainerBalancerStatusInfoProto.newBuilder()
   -                .setStartedAt(OffsetDateTime.now().toEpochSecond())
   +                
.setStartedAt(OffsetDateTime.now().truncatedTo(java.time.temporal.ChronoUnit.MINUTES).toEpochSecond())
                    
.setConfiguration(config.toProtobufBuilder().setShouldRun(true))
                    .addAllIterationsStatusInfo(
                        Arrays.asList(iteration1StatusInfo, 
iteration2StatusInfo, iteration3StatusInfo)
   ```
   
   CI:
   https://github.com/adoroszlai/ozone/actions/runs/13593432908
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to