xBis7 commented on code in PR #6112:
URL: https://github.com/apache/ozone/pull/6112#discussion_r1469271821


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/recon/TestReconAndAdminContainerCLI.java:
##########
@@ -330,34 +363,21 @@ private static void compareRMReportToReconResponse(String 
containerState)
     long rmMisReplCounter = rmReport.getStat(
         ReplicationManagerReport.HealthState.MIS_REPLICATED);
 
-    // Both threads are running every 1 second.
-    // Wait until all values are equal.
-    GenericTestUtils.waitFor(
-            () -> rmMissingCounter == reconResponse.getMissingCount() &&

Review Comment:
   I see, without getting a new instance of the stats inside the waitFor, the 
value is always fixed. Thanks for catching that.



##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/recon/TestReconAndAdminContainerCLI.java:
##########
@@ -303,23 +305,54 @@ public void testNodesInDecommissionOrMaintenance(
     TestNodeUtil.waitForDnToReachPersistedOpState(nodeToGoOffline1, 
IN_SERVICE);
     TestNodeUtil.waitForDnToReachPersistedOpState(nodeToGoOffline2, 
IN_SERVICE);
 
-    compareRMReportToReconResponse(underReplicatedState.toString());
-    compareRMReportToReconResponse(overReplicatedState.toString());
+    compareRMReportToReconResponse(underReplicatedState);
+    compareRMReportToReconResponse(overReplicatedState);
   }
 
   /**
    * The purpose of this method, isn't to validate the numbers
    * but to make sure that they are consistent between
    * Recon and the ReplicationManager.
    */
-  private static void compareRMReportToReconResponse(String containerState)
+  private static void compareRMReportToReconResponse(UnHealthyContainerStates 
containerState)
       throws Exception {
-    Assertions.assertFalse(Strings.isNullOrEmpty(containerState));
+    assertNotNull(containerState);
+
+    // Both threads are running every 1 second.
+    // Wait until all values are equal.
+    GenericTestUtils.waitFor(() -> assertReportsMatch(containerState),
+        1000, 40000);
+  }
 
-    ReplicationManagerReport rmReport = 
scmClient.getReplicationManagerReport();
-    UnhealthyContainersResponse reconResponse =
-        TestReconEndpointUtil
-            .getUnhealthyContainersFromRecon(CONF, containerState);
+  private static boolean assertReportsMatch(UnHealthyContainerStates state) {
+    ReplicationManagerReport rmReport;
+    UnhealthyContainersResponse reconResponse;
+
+    try {
+      rmReport = scmClient.getReplicationManagerReport();
+      reconResponse = TestReconEndpointUtil
+          .getUnhealthyContainersFromRecon(CONF, state);
+
+      long rmMissingCounter = rmReport.getStat(
+          ReplicationManagerReport.HealthState.MISSING);
+      long rmUnderReplCounter = rmReport.getStat(
+          ReplicationManagerReport.HealthState.UNDER_REPLICATED);
+      long rmOverReplCounter = rmReport.getStat(
+          ReplicationManagerReport.HealthState.OVER_REPLICATED);
+      long rmMisReplCounter = rmReport.getStat(
+          ReplicationManagerReport.HealthState.MIS_REPLICATED);
+
+      assertEquals(rmMissingCounter, reconResponse.getMissingCount());
+      assertEquals(rmUnderReplCounter, 
reconResponse.getUnderReplicatedCount());
+      assertEquals(rmOverReplCounter, reconResponse.getOverReplicatedCount());
+      assertEquals(rmMisReplCounter, reconResponse.getMisReplicatedCount());
+    } catch (IOException e) {
+      LOG.info("Error getting report", e);
+      return false;
+    } catch (AssertionError e) {
+      LOG.info("Reports do not match (yet): {}", e.getMessage());
+      return false;
+    }
 
     long rmMissingCounter = rmReport.getStat(

Review Comment:
   Do we need to get the stats again?



-- 
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