adoroszlai commented on code in PR #5629:
URL: https://github.com/apache/ozone/pull/5629#discussion_r1400209599


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineClose.java:
##########
@@ -165,35 +166,41 @@ public void testPipelineCloseWithOpenContainer()
 
   @Test
   public void testPipelineCloseWithPipelineAction() throws Exception {
-    List<DatanodeDetails> dns = ratisContainer.getPipeline().getNodes();
-    PipelineActionsFromDatanode
-        pipelineActionsFromDatanode = HddsTestUtils
-        .getPipelineActionFromDatanode(dns.get(0),
-            ratisContainer.getPipeline().getId());
+    final List<DatanodeDetails> dns = ratisContainer.getPipeline().getNodes();
+    final PipelineID pipelineID = ratisContainer.getPipeline().getId();
+
+    final PipelineActionsFromDatanode pipelineActionsFromDatanode =
+        HddsTestUtils.getPipelineActionFromDatanode(dns.get(0), pipelineID);
+
     // send closing action for pipeline
-    PipelineActionHandler pipelineActionHandler =
-        new PipelineActionHandler(
-            pipelineManager, SCMContext.emptyContext(), conf);
-    pipelineActionHandler
-        .onMessage(pipelineActionsFromDatanode, new EventQueue());
-    Thread.sleep(5000);
-
-    OzoneContainer ozoneContainer =
-        cluster.getHddsDatanodes().get(0).getDatanodeStateMachine()
-            .getContainer();
-    List<PipelineReport> pipelineReports =
-        ozoneContainer.getPipelineReport().getPipelineReportList();
-    for (PipelineReport pipelineReport : pipelineReports) {
-      // ensure the pipeline is not reported by any dn
-      Assert.assertNotEquals(
-          PipelineID.getFromProtobuf(pipelineReport.getPipelineID()),
-          ratisContainer.getPipeline().getId());
-    }
+    final PipelineActionHandler pipelineActionHandler =
+        new PipelineActionHandler(pipelineManager,
+            SCMContext.emptyContext(), conf);
+
+    pipelineActionHandler.onMessage(
+        pipelineActionsFromDatanode, new EventQueue());
+
+    final OzoneContainer ozoneContainer = cluster.getHddsDatanodes()
+        .get(0).getDatanodeStateMachine().getContainer();
+    final HddsProtos.PipelineID pid = pipelineID.getProtobuf();
+
+    // ensure the pipeline is not reported by the dn
+    GenericTestUtils
+        .waitFor(() -> {
+          final List<PipelineReport> pipelineReports = ozoneContainer
+              .getPipelineReport().getPipelineReportList();
+          for (PipelineReport pipelineReport : pipelineReports) {
+            if (pipelineReport.getPipelineID().equals(pid)) {
+              return false;
+            }
+          }
+          return true;
+        }, 500, 5000);
 
     try {
       pipelineManager.getPipeline(ratisContainer.getPipeline().getId());
-      Assert.fail("Pipeline should not exist in SCM");
-    } catch (PipelineNotFoundException e) {
+      Assertions.fail("Pipeline should not exist in SCM");
+    } catch (PipelineNotFoundException ignored) {
     }

Review Comment:
   We should change all assertions to JUnit5 in the file, but I'd prefer to do 
it in a separate task (as part of umbrella: HDDS-6729).  Having both `Assert` 
and `Assertions` will be confusing.
   
   Also, `try-catch` can be replaced with `assertThrows()`.



##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineClose.java:
##########
@@ -165,35 +166,41 @@ public void testPipelineCloseWithOpenContainer()
 
   @Test
   public void testPipelineCloseWithPipelineAction() throws Exception {
-    List<DatanodeDetails> dns = ratisContainer.getPipeline().getNodes();
-    PipelineActionsFromDatanode
-        pipelineActionsFromDatanode = HddsTestUtils
-        .getPipelineActionFromDatanode(dns.get(0),
-            ratisContainer.getPipeline().getId());
+    final List<DatanodeDetails> dns = ratisContainer.getPipeline().getNodes();
+    final PipelineID pipelineID = ratisContainer.getPipeline().getId();
+
+    final PipelineActionsFromDatanode pipelineActionsFromDatanode =
+        HddsTestUtils.getPipelineActionFromDatanode(dns.get(0), pipelineID);
+
     // send closing action for pipeline
-    PipelineActionHandler pipelineActionHandler =
-        new PipelineActionHandler(
-            pipelineManager, SCMContext.emptyContext(), conf);
-    pipelineActionHandler
-        .onMessage(pipelineActionsFromDatanode, new EventQueue());
-    Thread.sleep(5000);
-
-    OzoneContainer ozoneContainer =
-        cluster.getHddsDatanodes().get(0).getDatanodeStateMachine()
-            .getContainer();
-    List<PipelineReport> pipelineReports =
-        ozoneContainer.getPipelineReport().getPipelineReportList();
-    for (PipelineReport pipelineReport : pipelineReports) {
-      // ensure the pipeline is not reported by any dn
-      Assert.assertNotEquals(
-          PipelineID.getFromProtobuf(pipelineReport.getPipelineID()),
-          ratisContainer.getPipeline().getId());
-    }
+    final PipelineActionHandler pipelineActionHandler =
+        new PipelineActionHandler(pipelineManager,
+            SCMContext.emptyContext(), conf);
+
+    pipelineActionHandler.onMessage(
+        pipelineActionsFromDatanode, new EventQueue());
+
+    final OzoneContainer ozoneContainer = cluster.getHddsDatanodes()
+        .get(0).getDatanodeStateMachine().getContainer();
+    final HddsProtos.PipelineID pid = pipelineID.getProtobuf();
+
+    // ensure the pipeline is not reported by the dn
+    GenericTestUtils
+        .waitFor(() -> {
+          final List<PipelineReport> pipelineReports = ozoneContainer
+              .getPipelineReport().getPipelineReportList();
+          for (PipelineReport pipelineReport : pipelineReports) {
+            if (pipelineReport.getPipelineID().equals(pid)) {
+              return false;
+            }
+          }
+          return true;
+        }, 500, 5000);

Review Comment:
   nit: unnecessary indent
   
   ```suggestion
       GenericTestUtils.waitFor(() -> {
         final List<PipelineReport> pipelineReports = ozoneContainer
             .getPipelineReport().getPipelineReportList();
         for (PipelineReport pipelineReport : pipelineReports) {
           if (pipelineReport.getPipelineID().equals(pid)) {
             return false;
           }
         }
         return true;
       }, 500, 5000);
   ```
   
   



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