|
@@ -37,6 +37,7 @@ import org.apache.hadoop.hdfs.MiniDFSCluster;
|
|
import org.apache.hadoop.hdfs.protocol.FSLimitException.MaxDirectoryItemsExceededException;
|
|
import org.apache.hadoop.hdfs.protocol.FSLimitException.MaxDirectoryItemsExceededException;
|
|
import org.apache.hadoop.hdfs.protocol.FSLimitException.PathComponentTooLongException;
|
|
import org.apache.hadoop.hdfs.protocol.FSLimitException.PathComponentTooLongException;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|
|
|
+import org.apache.hadoop.test.GenericTestUtils;
|
|
import org.junit.Before;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
|
|
@@ -82,22 +83,6 @@ public class TestFsLimits {
|
|
fsIsReady = true;
|
|
fsIsReady = true;
|
|
}
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
|
- public void testDefaultMaxComponentLength() {
|
|
|
|
- int maxComponentLength = conf.getInt(
|
|
|
|
- DFSConfigKeys.DFS_NAMENODE_MAX_COMPONENT_LENGTH_KEY,
|
|
|
|
- DFSConfigKeys.DFS_NAMENODE_MAX_COMPONENT_LENGTH_DEFAULT);
|
|
|
|
- assertEquals(0, maxComponentLength);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void testDefaultMaxDirItems() {
|
|
|
|
- int maxDirItems = conf.getInt(
|
|
|
|
- DFSConfigKeys.DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY,
|
|
|
|
- DFSConfigKeys.DFS_NAMENODE_MAX_DIRECTORY_ITEMS_DEFAULT);
|
|
|
|
- assertEquals(0, maxDirItems);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Test
|
|
@Test
|
|
public void testNoLimits() throws Exception {
|
|
public void testNoLimits() throws Exception {
|
|
addChildWithName("1", null);
|
|
addChildWithName("1", null);
|
|
@@ -129,6 +114,22 @@ public class TestFsLimits {
|
|
addChildWithName("4444", MaxDirectoryItemsExceededException.class);
|
|
addChildWithName("4444", MaxDirectoryItemsExceededException.class);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Test
|
|
|
|
+ public void testMaxDirItemsLimits() throws Exception {
|
|
|
|
+ conf.setInt(DFSConfigKeys.DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY, 0);
|
|
|
|
+ try {
|
|
|
|
+ addChildWithName("1", null);
|
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
|
+ GenericTestUtils.assertExceptionContains("Cannot set dfs", e);
|
|
|
|
+ }
|
|
|
|
+ conf.setInt(DFSConfigKeys.DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY, 64*100*1024);
|
|
|
|
+ try {
|
|
|
|
+ addChildWithName("1", null);
|
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
|
+ GenericTestUtils.assertExceptionContains("Cannot set dfs", e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Test
|
|
@Test
|
|
public void testMaxComponentsAndMaxDirItems() throws Exception {
|
|
public void testMaxComponentsAndMaxDirItems() throws Exception {
|
|
conf.setInt(DFSConfigKeys.DFS_NAMENODE_MAX_COMPONENT_LENGTH_KEY, 3);
|
|
conf.setInt(DFSConfigKeys.DFS_NAMENODE_MAX_COMPONENT_LENGTH_KEY, 3);
|