[ 
https://issues.apache.org/jira/browse/HDFS-16522?focusedWorklogId=748345&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-748345
 ]

ASF GitHub Bot logged work on HDFS-16522:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 27/Mar/22 17:12
            Start Date: 27/Mar/22 17:12
    Worklog Time Spent: 10m 
      Work Description: virajjasani commented on a change in pull request #4108:
URL: https://github.com/apache/hadoop/pull/4108#discussion_r835936740



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
##########
@@ -319,4 +327,88 @@ public void testSetUpFederatedCluster() throws Exception {
       cluster.restartNameNode(1);
     }
   }
+
+  @Test
+  public void testStartStopWithPorts() throws Exception {
+    Configuration conf = new Configuration();
+
+    LambdaTestUtils.intercept(
+        IllegalArgumentException.class,
+        "Num of http ports (1) should match num of DataNodes (3)",
+        "MiniJournalCluster port validation failed",
+        () -> {
+          new 
MiniDFSCluster.Builder(conf).numDataNodes(3).setDnHttpPorts(8481).build();
+        });
+
+    LambdaTestUtils.intercept(
+        IllegalArgumentException.class,
+        "Num of ipc ports (2) should match num of DataNodes (1)",
+        "MiniJournalCluster port validation failed",
+        () -> {
+          new MiniDFSCluster.Builder(conf).setDnIpcPorts(8481, 8482).build();
+        });
+
+    LambdaTestUtils.intercept(
+        IllegalArgumentException.class,
+        "Num of ipc ports (1) should match num of DataNodes (3)",
+        "MiniJournalCluster port validation failed",
+        () -> {
+          new MiniDFSCluster.Builder(conf).numDataNodes(3).setDnHttpPorts(800, 
9000, 10000)
+              .setDnIpcPorts(8481).build();
+        });
+
+    LambdaTestUtils.intercept(
+        IllegalArgumentException.class,
+        "Num of http ports (4) should match num of DataNodes (3)",
+        "MiniJournalCluster port validation failed",
+        () -> {
+          new MiniDFSCluster.Builder(conf).setDnHttpPorts(800, 9000, 1000, 
2000)
+              .setDnIpcPorts(8481, 8482, 8483).numDataNodes(3).build();
+        });
+
+    final Set<Integer> httpAndIpcPorts = NetUtils.getFreeSocketPorts(6);
+    LOG.info("Free socket ports: {}", httpAndIpcPorts);
+
+    for (Integer httpAndIpcPort : httpAndIpcPorts) {
+      assertNotEquals("None of the acquired socket port should not be zero", 0,
+          httpAndIpcPort.intValue());
+    }

Review comment:
       As of junit 4.13.2, `assertThat` methods are deprecated. Is it fine 
keeping this as is?




-- 
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: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 748345)
    Time Spent: 1.5h  (was: 1h 20m)

> Set Http and Ipc ports for Datanodes in MiniDFSCluster
> ------------------------------------------------------
>
>                 Key: HDFS-16522
>                 URL: https://issues.apache.org/jira/browse/HDFS-16522
>             Project: Hadoop HDFS
>          Issue Type: Task
>            Reporter: Viraj Jasani
>            Assignee: Viraj Jasani
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> We should provide options to set Http and Ipc ports for Datanodes in 
> MiniDFSCluster.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to