hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1349634 - in /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs: CHANGES.txt src/test/java/org/apache/hadoop/hdfs/TestQuota.java
Date Wed, 13 Jun 2012 05:04:21 GMT
Author: eli
Date: Wed Jun 13 05:04:20 2012
New Revision: 1349634

URL: http://svn.apache.org/viewvc?rev=1349634&view=rev
Log:
HDFS-3478. Test quotas with Long.Max_Value. Contributed by Sujay Rau

Modified:
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestQuota.java

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1349634&r1=1349633&r2=1349634&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Wed Jun 13 05:04:20 2012
@@ -93,6 +93,8 @@ Trunk (unreleased changes)
     HDFS-3049. During the normal NN startup process, fall back on a different
     edit log if we see one that is corrupt (Colin Patrick McCabe via todd)
 
+    HDFS-3478. Test quotas with Long.Max_Value. (Sujay Rau via eli)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestQuota.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestQuota.java?rev=1349634&r1=1349633&r2=1349634&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestQuota.java
(original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestQuota.java
Wed Jun 13 05:04:20 2012
@@ -17,9 +17,7 @@
  */
 package org.apache.hadoop.hdfs;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 import java.io.OutputStream;
 import java.security.PrivilegedExceptionAction;
@@ -773,7 +771,60 @@ public class TestQuota {
       final ContentSummary computed) {
     assertEquals(expected.toString(), computed.toString());
   }
-
+ 
+  /**
+   * Test limit cases for setting space quotas.
+   */
+  @Test
+  public void testMaxSpaceQuotas() throws Exception {
+    final Configuration conf = new HdfsConfiguration();
+    final MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build();
+    final FileSystem fs = cluster.getFileSystem();
+    assertTrue("Not a HDFS: "+fs.getUri(),
+                fs instanceof DistributedFileSystem);
+    final DistributedFileSystem dfs = (DistributedFileSystem)fs;
+    
+    // create test directory
+    final Path testFolder = new Path("/testFolder");
+    assertTrue(dfs.mkdirs(testFolder));
+    
+    // setting namespace quota to Long.MAX_VALUE - 1 should work
+    dfs.setQuota(testFolder, Long.MAX_VALUE - 1, 10);
+    ContentSummary c = dfs.getContentSummary(testFolder);
+    assertTrue("Quota not set properly", c.getQuota() == Long.MAX_VALUE - 1);
+    
+    // setting diskspace quota to Long.MAX_VALUE - 1 should work
+    dfs.setQuota(testFolder, 10, Long.MAX_VALUE - 1);
+    c = dfs.getContentSummary(testFolder);
+    assertTrue("Quota not set properly", c.getSpaceQuota() == Long.MAX_VALUE - 1);
+    
+    // setting namespace quota to Long.MAX_VALUE should not work + no error
+    dfs.setQuota(testFolder, Long.MAX_VALUE, 10);
+    c = dfs.getContentSummary(testFolder);
+    assertTrue("Quota should not have changed", c.getQuota() == 10);
+    
+    // setting diskspace quota to Long.MAX_VALUE should not work + no error
+    dfs.setQuota(testFolder, 10, Long.MAX_VALUE);
+    c = dfs.getContentSummary(testFolder);
+    assertTrue("Quota should not have changed", c.getSpaceQuota() == 10);
+    
+    // setting namespace quota to Long.MAX_VALUE + 1 should not work + error
+    try {
+      dfs.setQuota(testFolder, Long.MAX_VALUE + 1, 10);
+      fail("Exception not thrown");
+    } catch (IllegalArgumentException e) {
+      // Expected
+    }
+    
+    // setting diskspace quota to Long.MAX_VALUE + 1 should not work + error
+    try {
+      dfs.setQuota(testFolder, 10, Long.MAX_VALUE + 1);
+      fail("Exception not thrown");
+    } catch (IllegalArgumentException e) {
+      // Expected
+    }
+  }
+  
   /**
    * Violate a space quota using files of size < 1 block. Test that block
    * allocation conservatively assumes that for quota checking the entire



Mime
View raw message