ayushtkn commented on code in PR #8064:
URL: https://github.com/apache/hadoop/pull/8064#discussion_r2535427559


##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeReconfigure.java:
##########
@@ -865,6 +866,35 @@ public void testReconfigureSlowPeerCollectInterval() 
throws Exception {
     assertEquals(600000, datanodeManager.getSlowPeerCollectionInterval());
   }
 
+  @Test
+  public void testReconfigureMaxDirItems() throws ReconfigurationException {
+    final NameNode nameNode = cluster.getNameNode();
+    final FSDirectory fsd = nameNode.namesystem.getFSDirectory();
+
+    // By default, DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY is 1024 * 1024.
+    assertEquals(1024 * 1024, fsd.getMaxDirItems());
+
+    // Reconfigure.
+    nameNode.reconfigureProperty(DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY,
+        Integer.toString(1024 * 1024 * 2));
+
+    // Assert DFS_NAMENODE_MAX_SLOWPEER_COLLECT_NODES_KEY is 1024 * 1024 * 2.
+    assertEquals(1024 * 1024 * 2, fsd.getMaxDirItems());
+
+    try {
+      // Reconfigure to negative, and expect failed.
+      nameNode.reconfigureProperty(DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY,
+          Integer.toString(1024 * 1024 * -1));
+    } catch (ReconfigurationException e) {
+      assertEquals("Could not change property " +
+          "dfs.namenode.fs-limits.max-directory-items from '" + 1024 * 1024 * 2
+          + "' to '" + 1024 * 1024 * -1 + "'", e.getMessage());
+    }

Review Comment:
   use LamdaTestUtils
   ```
   
       LambdaTestUtils.intercept(ReconfigurationException.class,
           "Could not change property 
dfs.namenode.fs-limits.max-directory-items from '" + 1024 * 1024 * 2 + "' to '"
               + 1024 * 1024 * -1 + "'",
           () -> 
nameNode.reconfigureProperty(DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY, 
Integer.toString(1024 * 1024 * -1)));
   ```



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