rich7420 commented on code in PR #11341:
URL: https://github.com/apache/ozone/pull/11341#discussion_r4128940969


##########
hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestReconAsPassiveScm.java:
##########
@@ -91,15 +89,22 @@ public void testDatanodeRegistrationAndReports() throws 
Exception {
     PipelineManager reconPipelineManager = reconScm.getPipelineManager();
     PipelineManager scmPipelineManager = scm.getPipelineManager();
 
-    LambdaTestUtils.await(60000, 5000,
-        () -> (reconPipelineManager.getPipelines().size() >= 4));
-
-    // Verify if Recon has all the pipelines from SCM.
-    scmPipelineManager.getPipelines().forEach(p -> {
+    // SCM and Recon update their pipeline state asynchronously. Validate the
+    // complete SCM snapshot inside the retry loop so a pipeline created after
+    // Recon reaches the expected count does not cause a one-shot failure.
+    LambdaTestUtils.await(60000, 5000, () -> {
+      if (scmPipelineManager.getPipelines().size() < 4) {
+        return false;
+      }
       try {
-        assertNotNull(reconPipelineManager.getPipeline(p.getId()));
+        for (Pipeline pipeline : scmPipelineManager.getPipelines()) {
+          if (reconPipelineManager.getPipeline(pipeline.getId()) == null) {
+            return false;
+          }
+        }
+        return true;
       } catch (PipelineNotFoundException e) {

Review Comment:
   Could we take one SCM pipeline snapshot per attempt and let 
`LambdaTestUtils.await` handle `PipelineNotFoundException`?
   
   
[`await`](https://github.com/apache/ozone/blob/2f5b8d0f24555b70fcd262ecced660f7617a6b71/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/LambdaTestUtils.java#L115-L130)
 already retries exceptions and retains the last one as the timeout cause. 
Catching it here and returning `false` loses the missing pipeline ID. 
`getPipeline()` throws when absent, so the null check is unnecessary too. Using 
one list also makes the size check and iteration inspect the same snapshot.
   
   ```java
   LambdaTestUtils.await(60000, 5000, () -> {
     List<Pipeline> pipelines = scmPipelineManager.getPipelines();
     if (pipelines.size() < 4) {
       return false;
     }
     for (Pipeline pipeline : pipelines) {
       reconPipelineManager.getPipeline(pipeline.getId());
     }
     return true;
   });
   ```
   
   This would need `java.util.List` in place of the now-unused 
`PipelineNotFoundException` import.



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