hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jl...@apache.org
Subject svn commit: r1488040 [2/2] - in /hadoop/common/trunk/hadoop-common-project/hadoop-common: ./ src/test/java/org/apache/hadoop/conf/ src/test/java/org/apache/hadoop/fs/ src/test/java/org/apache/hadoop/fs/shell/ src/test/java/org/apache/hadoop/fs/viewfs/ ...
Date Thu, 30 May 2013 22:43:17 GMT
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java Thu May 30 22:43:16 2013
@@ -68,7 +68,15 @@ public class ViewFileSystemBaseTest {
   FileSystem fsTarget;  // the target file system - the mount will point here
   Path targetTestRoot;
   Configuration conf;
+  final FileSystemTestHelper fileSystemTestHelper;
 
+  public ViewFileSystemBaseTest() {
+      this.fileSystemTestHelper = createFileSystemHelper();
+  }
+
+  protected FileSystemTestHelper createFileSystemHelper() {
+    return new FileSystemTestHelper();
+  }
 
   @Before
   public void setUp() throws Exception {
@@ -94,11 +102,11 @@ public class ViewFileSystemBaseTest {
 
   @After
   public void tearDown() throws Exception {
-    fsTarget.delete(FileSystemTestHelper.getTestRootPath(fsTarget), true);
+    fsTarget.delete(fileSystemTestHelper.getTestRootPath(fsTarget), true);
   }
   
   void initializeTargetTestRoot() throws IOException {
-    targetTestRoot = FileSystemTestHelper.getAbsoluteTestRootPath(fsTarget);
+    targetTestRoot = fileSystemTestHelper.getAbsoluteTestRootPath(fsTarget);
     // In case previous test was killed before cleanup
     fsTarget.delete(targetTestRoot, true);
     
@@ -199,7 +207,7 @@ public class ViewFileSystemBaseTest {
   @Test
   public void testOperationsThroughMountLinks() throws IOException {
     // Create file 
-    FileSystemTestHelper.createFile(fsView, "/user/foo");
+    fileSystemTestHelper.createFile(fsView, "/user/foo");
     Assert.assertTrue("Created file should be type file",
         fsView.isFile(new Path("/user/foo")));
     Assert.assertTrue("Target of created file should be type file",
@@ -214,7 +222,7 @@ public class ViewFileSystemBaseTest {
         fsTarget.exists(new Path(targetTestRoot,"user/foo")));
     
     // Create file with a 2 component dirs
-    FileSystemTestHelper.createFile(fsView, "/internalDir/linkToDir2/foo");
+    fileSystemTestHelper.createFile(fsView, "/internalDir/linkToDir2/foo");
     Assert.assertTrue("Created file should be type file",
         fsView.isFile(new Path("/internalDir/linkToDir2/foo")));
     Assert.assertTrue("Target of created file should be type file",
@@ -230,14 +238,14 @@ public class ViewFileSystemBaseTest {
     
     
     // Create file with a 3 component dirs
-    FileSystemTestHelper.createFile(fsView, "/internalDir/internalDir2/linkToDir3/foo");
+    fileSystemTestHelper.createFile(fsView, "/internalDir/internalDir2/linkToDir3/foo");
     Assert.assertTrue("Created file should be type file",
         fsView.isFile(new Path("/internalDir/internalDir2/linkToDir3/foo")));
     Assert.assertTrue("Target of created file should be type file",
         fsTarget.isFile(new Path(targetTestRoot,"dir3/foo")));
     
     // Recursive Create file with missing dirs
-    FileSystemTestHelper.createFile(fsView,
+    fileSystemTestHelper.createFile(fsView,
         "/internalDir/linkToDir2/missingDir/miss2/foo");
     Assert.assertTrue("Created file should be type file",
         fsView.isFile(new Path("/internalDir/linkToDir2/missingDir/miss2/foo")));
@@ -256,14 +264,14 @@ public class ViewFileSystemBaseTest {
     
       
     // mkdir
-    fsView.mkdirs(FileSystemTestHelper.getTestRootPath(fsView, "/user/dirX"));
+    fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView, "/user/dirX"));
     Assert.assertTrue("New dir should be type dir", 
         fsView.isDirectory(new Path("/user/dirX")));
     Assert.assertTrue("Target of new dir should be of type dir",
         fsTarget.isDirectory(new Path(targetTestRoot,"user/dirX")));
     
     fsView.mkdirs(
-        FileSystemTestHelper.getTestRootPath(fsView, "/user/dirX/dirY"));
+        fileSystemTestHelper.getTestRootPath(fsView, "/user/dirX/dirY"));
     Assert.assertTrue("New dir should be type dir", 
         fsView.isDirectory(new Path("/user/dirX/dirY")));
     Assert.assertTrue("Target of new dir should be of type dir",
@@ -285,14 +293,14 @@ public class ViewFileSystemBaseTest {
     Assert.assertFalse(fsTarget.exists(new Path(targetTestRoot,"user/dirX")));
     
     // Rename a file 
-    FileSystemTestHelper.createFile(fsView, "/user/foo");
+    fileSystemTestHelper.createFile(fsView, "/user/foo");
     fsView.rename(new Path("/user/foo"), new Path("/user/fooBar"));
     Assert.assertFalse("Renamed src should not exist", 
         fsView.exists(new Path("/user/foo")));
     Assert.assertFalse("Renamed src should not exist in target",
         fsTarget.exists(new Path(targetTestRoot,"user/foo")));
     Assert.assertTrue("Renamed dest should  exist as file",
-        fsView.isFile(FileSystemTestHelper.getTestRootPath(fsView,"/user/fooBar")));
+        fsView.isFile(fileSystemTestHelper.getTestRootPath(fsView,"/user/fooBar")));
     Assert.assertTrue("Renamed dest should  exist as file in target",
         fsTarget.isFile(new Path(targetTestRoot,"user/fooBar")));
     
@@ -303,7 +311,7 @@ public class ViewFileSystemBaseTest {
     Assert.assertFalse("Renamed src should not exist in target",
         fsTarget.exists(new Path(targetTestRoot,"user/dirFoo")));
     Assert.assertTrue("Renamed dest should  exist as dir",
-        fsView.isDirectory(FileSystemTestHelper.getTestRootPath(fsView,"/user/dirFooBar")));
+        fsView.isDirectory(fileSystemTestHelper.getTestRootPath(fsView,"/user/dirFooBar")));
     Assert.assertTrue("Renamed dest should  exist as dir in target",
         fsTarget.isDirectory(new Path(targetTestRoot,"user/dirFooBar")));
     
@@ -322,7 +330,7 @@ public class ViewFileSystemBaseTest {
   // rename across mount points that point to same target also fail 
   @Test(expected=IOException.class) 
   public void testRenameAcrossMounts1() throws IOException {
-    FileSystemTestHelper.createFile(fsView, "/user/foo");
+    fileSystemTestHelper.createFile(fsView, "/user/foo");
     fsView.rename(new Path("/user/foo"), new Path("/user2/fooBarBar"));
     /* - code if we had wanted this to suceed
     Assert.assertFalse(fSys.exists(new Path("/user/foo")));
@@ -338,7 +346,7 @@ public class ViewFileSystemBaseTest {
 
   @Test(expected=IOException.class) 
   public void testRenameAcrossMounts2() throws IOException {
-    FileSystemTestHelper.createFile(fsView, "/user/foo");
+    fileSystemTestHelper.createFile(fsView, "/user/foo");
     fsView.rename(new Path("/user/foo"), new Path("/data/fooBar"));
   }
   
@@ -394,19 +402,19 @@ public class ViewFileSystemBaseTest {
     FileStatus[] dirPaths = fsView.listStatus(new Path("/"));
     FileStatus fs;
     Assert.assertEquals(getExpectedDirPaths(), dirPaths.length);
-    fs = FileSystemTestHelper.containsPath(fsView, "/user", dirPaths);
+    fs = fileSystemTestHelper.containsPath(fsView, "/user", dirPaths);
       Assert.assertNotNull(fs);
       Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
-    fs = FileSystemTestHelper.containsPath(fsView, "/data", dirPaths);
+    fs = fileSystemTestHelper.containsPath(fsView, "/data", dirPaths);
       Assert.assertNotNull(fs);
       Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
-    fs = FileSystemTestHelper.containsPath(fsView, "/internalDir", dirPaths);
+    fs = fileSystemTestHelper.containsPath(fsView, "/internalDir", dirPaths);
       Assert.assertNotNull(fs);
       Assert.assertTrue("A mount should appear as symlink", fs.isDirectory());
-    fs = FileSystemTestHelper.containsPath(fsView, "/danglingLink", dirPaths);
+    fs = fileSystemTestHelper.containsPath(fsView, "/danglingLink", dirPaths);
       Assert.assertNotNull(fs);
       Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
-    fs = FileSystemTestHelper.containsPath(fsView, "/linkToAFile", dirPaths);
+    fs = fileSystemTestHelper.containsPath(fsView, "/linkToAFile", dirPaths);
       Assert.assertNotNull(fs);
       Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
       
@@ -416,10 +424,10 @@ public class ViewFileSystemBaseTest {
       dirPaths = fsView.listStatus(new Path("/internalDir"));
       Assert.assertEquals(2, dirPaths.length);
 
-      fs = FileSystemTestHelper.containsPath(fsView, "/internalDir/internalDir2", dirPaths);
+      fs = fileSystemTestHelper.containsPath(fsView, "/internalDir/internalDir2", dirPaths);
         Assert.assertNotNull(fs);
         Assert.assertTrue("A mount should appear as symlink", fs.isDirectory());
-      fs = FileSystemTestHelper.containsPath(fsView, "/internalDir/linkToDir2",
+      fs = fileSystemTestHelper.containsPath(fsView, "/internalDir/linkToDir2",
           dirPaths);
         Assert.assertNotNull(fs);
         Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
@@ -436,22 +444,22 @@ public class ViewFileSystemBaseTest {
     Assert.assertEquals(0, dirPaths.length);
     
     // add a file
-    long len = FileSystemTestHelper.createFile(fsView, "/data/foo");
+    long len = fileSystemTestHelper.createFile(fsView, "/data/foo");
     dirPaths = fsView.listStatus(new Path("/data"));
     Assert.assertEquals(1, dirPaths.length);
-    fs = FileSystemTestHelper.containsPath(fsView, "/data/foo", dirPaths);
+    fs = fileSystemTestHelper.containsPath(fsView, "/data/foo", dirPaths);
     Assert.assertNotNull(fs);
     Assert.assertTrue("Created file shoudl appear as a file", fs.isFile());
     Assert.assertEquals(len, fs.getLen());
     
     // add a dir
-    fsView.mkdirs(FileSystemTestHelper.getTestRootPath(fsView, "/data/dirX"));
+    fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView, "/data/dirX"));
     dirPaths = fsView.listStatus(new Path("/data"));
     Assert.assertEquals(2, dirPaths.length);
-    fs = FileSystemTestHelper.containsPath(fsView, "/data/foo", dirPaths);
+    fs = fileSystemTestHelper.containsPath(fsView, "/data/foo", dirPaths);
     Assert.assertNotNull(fs);
     Assert.assertTrue("Created file shoudl appear as a file", fs.isFile());
-    fs = FileSystemTestHelper.containsPath(fsView, "/data/dirX", dirPaths);
+    fs = fileSystemTestHelper.containsPath(fsView, "/data/dirX", dirPaths);
     Assert.assertNotNull(fs);
     Assert.assertTrue("Created dir should appear as a dir", fs.isDirectory()); 
   }
@@ -487,12 +495,12 @@ public class ViewFileSystemBaseTest {
   public void testResolvePathInternalPaths() throws IOException {
     Assert.assertEquals(new Path("/"), fsView.resolvePath(new Path("/")));
     Assert.assertEquals(new Path("/internalDir"),
-                          fsView.resolvePath(new Path("/internalDir")));
+        fsView.resolvePath(new Path("/internalDir")));
   }
   @Test
   public void testResolvePathMountPoints() throws IOException {
     Assert.assertEquals(new Path(targetTestRoot,"user"),
-                          fsView.resolvePath(new Path("/user")));
+        fsView.resolvePath(new Path("/user")));
     Assert.assertEquals(new Path(targetTestRoot,"data"),
         fsView.resolvePath(new Path("/data")));
     Assert.assertEquals(new Path(targetTestRoot,"dir2"),
@@ -504,25 +512,25 @@ public class ViewFileSystemBaseTest {
   
   @Test
   public void testResolvePathThroughMountPoints() throws IOException {
-    FileSystemTestHelper.createFile(fsView, "/user/foo");
+    fileSystemTestHelper.createFile(fsView, "/user/foo");
     Assert.assertEquals(new Path(targetTestRoot,"user/foo"),
-                          fsView.resolvePath(new Path("/user/foo")));
+        fsView.resolvePath(new Path("/user/foo")));
     
     fsView.mkdirs(
-        FileSystemTestHelper.getTestRootPath(fsView, "/user/dirX"));
+        fileSystemTestHelper.getTestRootPath(fsView, "/user/dirX"));
     Assert.assertEquals(new Path(targetTestRoot,"user/dirX"),
         fsView.resolvePath(new Path("/user/dirX")));
 
     
     fsView.mkdirs(
-        FileSystemTestHelper.getTestRootPath(fsView, "/user/dirX/dirY"));
+        fileSystemTestHelper.getTestRootPath(fsView, "/user/dirX/dirY"));
     Assert.assertEquals(new Path(targetTestRoot,"user/dirX/dirY"),
         fsView.resolvePath(new Path("/user/dirX/dirY")));
   }
 
   @Test(expected=FileNotFoundException.class) 
   public void testResolvePathDanglingLink() throws IOException {
-      fsView.resolvePath(new Path("/danglingLink"));
+    fsView.resolvePath(new Path("/danglingLink"));
   }
   
   @Test(expected=FileNotFoundException.class) 
@@ -534,7 +542,7 @@ public class ViewFileSystemBaseTest {
   @Test(expected=FileNotFoundException.class) 
   public void testResolvePathMissingThroughMountPoints2() throws IOException {
     fsView.mkdirs(
-        FileSystemTestHelper.getTestRootPath(fsView, "/user/dirX"));
+        fileSystemTestHelper.getTestRootPath(fsView, "/user/dirX"));
     fsView.resolvePath(new Path("/user/dirX/nonExisting"));
   }
   
@@ -550,76 +558,76 @@ public class ViewFileSystemBaseTest {
   // Mkdir on existing internal mount table succeed except for /
   @Test(expected=AccessControlException.class) 
   public void testInternalMkdirSlash() throws IOException {
-    fsView.mkdirs(FileSystemTestHelper.getTestRootPath(fsView, "/"));
+    fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView, "/"));
   }
   
   public void testInternalMkdirExisting1() throws IOException {
     Assert.assertTrue("mkdir of existing dir should succeed", 
-        fsView.mkdirs(FileSystemTestHelper.getTestRootPath(fsView,
+        fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView,
         "/internalDir")));
   }
 
   public void testInternalMkdirExisting2() throws IOException {
     Assert.assertTrue("mkdir of existing dir should succeed", 
-        fsView.mkdirs(FileSystemTestHelper.getTestRootPath(fsView,
+        fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView,
         "/internalDir/linkToDir2")));
   }
   
   // Mkdir for new internal mount table should fail
   @Test(expected=AccessControlException.class) 
   public void testInternalMkdirNew() throws IOException {
-    fsView.mkdirs(FileSystemTestHelper.getTestRootPath(fsView, "/dirNew"));
+    fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView, "/dirNew"));
   }
   @Test(expected=AccessControlException.class) 
   public void testInternalMkdirNew2() throws IOException {
-    fsView.mkdirs(FileSystemTestHelper.getTestRootPath(fsView, "/internalDir/dirNew"));
+    fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView, "/internalDir/dirNew"));
   }
   
   // Create File on internal mount table should fail
   
   @Test(expected=AccessControlException.class) 
   public void testInternalCreate1() throws IOException {
-    FileSystemTestHelper.createFile(fsView, "/foo"); // 1 component
+    fileSystemTestHelper.createFile(fsView, "/foo"); // 1 component
   }
   
   @Test(expected=AccessControlException.class) 
   public void testInternalCreate2() throws IOException {  // 2 component
-    FileSystemTestHelper.createFile(fsView, "/internalDir/foo");
+    fileSystemTestHelper.createFile(fsView, "/internalDir/foo");
   }
   
   @Test(expected=AccessControlException.class) 
   public void testInternalCreateMissingDir() throws IOException {
-    FileSystemTestHelper.createFile(fsView, "/missingDir/foo");
+    fileSystemTestHelper.createFile(fsView, "/missingDir/foo");
   }
   
   @Test(expected=AccessControlException.class) 
   public void testInternalCreateMissingDir2() throws IOException {
-    FileSystemTestHelper.createFile(fsView, "/missingDir/miss2/foo");
+    fileSystemTestHelper.createFile(fsView, "/missingDir/miss2/foo");
   }
   
   
   @Test(expected=AccessControlException.class) 
   public void testInternalCreateMissingDir3() throws IOException {
-    FileSystemTestHelper.createFile(fsView, "/internalDir/miss2/foo");
+    fileSystemTestHelper.createFile(fsView, "/internalDir/miss2/foo");
   }
   
   // Delete on internal mount table should fail
   
   @Test(expected=FileNotFoundException.class) 
   public void testInternalDeleteNonExisting() throws IOException {
-      fsView.delete(new Path("/NonExisting"), false);
+    fsView.delete(new Path("/NonExisting"), false);
   }
   @Test(expected=FileNotFoundException.class) 
   public void testInternalDeleteNonExisting2() throws IOException {
-      fsView.delete(new Path("/internalDir/NonExisting"), false);
+    fsView.delete(new Path("/internalDir/NonExisting"), false);
   }
   @Test(expected=AccessControlException.class) 
   public void testInternalDeleteExisting() throws IOException {
-      fsView.delete(new Path("/internalDir"), false);
+    fsView.delete(new Path("/internalDir"), false);
   }
   @Test(expected=AccessControlException.class) 
   public void testInternalDeleteExisting2() throws IOException {
-        fsView.getFileStatus(
+    fsView.getFileStatus(
             new Path("/internalDir/linkToDir2")).isDirectory();
     fsView.delete(new Path("/internalDir/linkToDir2"), false);
   } 
@@ -641,7 +649,7 @@ public class ViewFileSystemBaseTest {
   }
   @Test(expected=AccessControlException.class) 
   public void testInternalRename2() throws IOException {
-       fsView.getFileStatus(new Path("/internalDir/linkToDir2")).isDirectory();
+    fsView.getFileStatus(new Path("/internalDir/linkToDir2")).isDirectory();
     fsView.rename(new Path("/internalDir/linkToDir2"),
         new Path("/internalDir/dir1"));
   }
@@ -665,7 +673,7 @@ public class ViewFileSystemBaseTest {
   
   @Test
   public void testCreateNonRecursive() throws IOException {
-    Path path = FileSystemTestHelper.getTestRootPath(fsView, "/user/foo");
+    Path path = fileSystemTestHelper.getTestRootPath(fsView, "/user/foo");
     fsView.createNonRecursive(path, false, 1024, (short)1, 1024L, null);
     FileStatus status = fsView.getFileStatus(new Path("/user/foo"));
     Assert.assertTrue("Created file should be type file",

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemTestSetup.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemTestSetup.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemTestSetup.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemTestSetup.java Thu May 30 22:43:16 2013
@@ -56,18 +56,18 @@ public class ViewFileSystemTestSetup {
    * @return return the ViewFS File context to be used for tests
    * @throws Exception
    */
-  static public FileSystem setupForViewFileSystem(Configuration conf, FileSystem fsTarget) throws Exception {
+  static public FileSystem setupForViewFileSystem(Configuration conf, FileSystemTestHelper fileSystemTestHelper, FileSystem fsTarget) throws Exception {
     /**
      * create the test root on local_fs - the  mount table will point here
      */
-    Path targetOfTests = FileSystemTestHelper.getTestRootPath(fsTarget);
+    Path targetOfTests = fileSystemTestHelper.getTestRootPath(fsTarget);
     // In case previous test was killed before cleanup
     fsTarget.delete(targetOfTests, true);
     fsTarget.mkdirs(targetOfTests);
 
 
     // Set up viewfs link for test dir as described above
-    String testDir = FileSystemTestHelper.getTestRootPath(fsTarget).toUri()
+    String testDir = fileSystemTestHelper.getTestRootPath(fsTarget).toUri()
         .getPath();
     linkUpFirstComponents(conf, testDir, fsTarget, "test dir");
     
@@ -92,14 +92,21 @@ public class ViewFileSystemTestSetup {
    * 
    * delete the test directory in the target  fs
    */
-  static public void tearDown(FileSystem fsTarget) throws Exception {
-    Path targetOfTests = FileSystemTestHelper.getTestRootPath(fsTarget);
+  static public void tearDown(FileSystemTestHelper fileSystemTestHelper, FileSystem fsTarget) throws Exception {
+    Path targetOfTests = fileSystemTestHelper.getTestRootPath(fsTarget);
     fsTarget.delete(targetOfTests, true);
   }
   
   public static Configuration createConfig() {
+    return createConfig(true);
+  }
+  
+  public static Configuration createConfig(boolean disableCache) {
     Configuration conf = new Configuration();
     conf.set("fs.viewfs.impl", ViewFileSystem.class.getName());
+    if (disableCache) {
+      conf.set("fs.viewfs.impl.disable.cache", "true");
+    }
     return conf; 
   }
   

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java Thu May 30 22:43:16 2013
@@ -75,6 +75,7 @@ public class ViewFsBaseTest {
   Configuration conf;
   FileContext xfcViewWithAuthority; // same as fsView but with authority
   URI schemeWithAuthority;
+  final FileContextTestHelper fileContextTestHelper = new FileContextTestHelper();
 
   @Before
   public void setUp() throws Exception {
@@ -118,7 +119,7 @@ public class ViewFsBaseTest {
   }
   
   void initializeTargetTestRoot() throws IOException {
-    targetTestRoot = FileContextTestHelper.getAbsoluteTestRootPath(fcTarget);
+    targetTestRoot = fileContextTestHelper.getAbsoluteTestRootPath(fcTarget);
     // In case previous test was killed before cleanup
     fcTarget.delete(targetTestRoot, true);
     
@@ -127,7 +128,7 @@ public class ViewFsBaseTest {
 
   @After
   public void tearDown() throws Exception {
-    fcTarget.delete(FileContextTestHelper.getTestRootPath(fcTarget), true);
+    fcTarget.delete(fileContextTestHelper.getTestRootPath(fcTarget), true);
   }
   
   @Test
@@ -181,7 +182,7 @@ public class ViewFsBaseTest {
   @Test
   public void testOperationsThroughMountLinks() throws IOException {
     // Create file 
-    FileContextTestHelper.createFileNonRecursive(fcView, "/user/foo");
+    fileContextTestHelper.createFileNonRecursive(fcView, "/user/foo");
     Assert.assertTrue("Create file should be file",
 		isFile(fcView, new Path("/user/foo")));
     Assert.assertTrue("Target of created file should be type file",
@@ -196,7 +197,7 @@ public class ViewFsBaseTest {
         exists(fcTarget, new Path(targetTestRoot,"user/foo")));
     
     // Create file with a 2 component dirs
-    FileContextTestHelper.createFileNonRecursive(fcView,
+    fileContextTestHelper.createFileNonRecursive(fcView,
         "/internalDir/linkToDir2/foo");
     Assert.assertTrue("Created file should be type file",
         isFile(fcView, new Path("/internalDir/linkToDir2/foo")));
@@ -213,7 +214,7 @@ public class ViewFsBaseTest {
     
     
     // Create file with a 3 component dirs
-    FileContextTestHelper.createFileNonRecursive(fcView,
+    fileContextTestHelper.createFileNonRecursive(fcView,
         "/internalDir/internalDir2/linkToDir3/foo");
     Assert.assertTrue("Created file should be of type file", 
         isFile(fcView, new Path("/internalDir/internalDir2/linkToDir3/foo")));
@@ -221,7 +222,7 @@ public class ViewFsBaseTest {
         isFile(fcTarget, new Path(targetTestRoot,"dir3/foo")));
     
     // Recursive Create file with missing dirs
-    FileContextTestHelper.createFile(fcView,
+    fileContextTestHelper.createFile(fcView,
         "/internalDir/linkToDir2/missingDir/miss2/foo");
     Assert.assertTrue("Created file should be of type file",
       isFile(fcView, new Path("/internalDir/linkToDir2/missingDir/miss2/foo")));
@@ -239,14 +240,14 @@ public class ViewFsBaseTest {
     
       
     // mkdir
-    fcView.mkdir(FileContextTestHelper.getTestRootPath(fcView, "/user/dirX"),
+    fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/user/dirX"),
         FileContext.DEFAULT_PERM, false);
     Assert.assertTrue("New dir should be type dir", 
         isDir(fcView, new Path("/user/dirX")));
     Assert.assertTrue("Target of new dir should be of type dir",
         isDir(fcTarget, new Path(targetTestRoot,"user/dirX")));
     
-    fcView.mkdir(FileContextTestHelper.getTestRootPath(fcView, "/user/dirX/dirY"),
+    fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/user/dirX/dirY"),
         FileContext.DEFAULT_PERM, false);
     Assert.assertTrue("New dir should be type dir", 
         isDir(fcView, new Path("/user/dirX/dirY")));
@@ -270,13 +271,13 @@ public class ViewFsBaseTest {
         exists(fcTarget, new Path(targetTestRoot,"user/dirX")));
     
     // Rename a file 
-    FileContextTestHelper.createFile(fcView, "/user/foo");
+    fileContextTestHelper.createFile(fcView, "/user/foo");
     fcView.rename(new Path("/user/foo"), new Path("/user/fooBar"));
     Assert.assertFalse("Renamed src should not exist", 
         exists(fcView, new Path("/user/foo")));
     Assert.assertFalse(exists(fcTarget, new Path(targetTestRoot,"user/foo")));
     Assert.assertTrue(isFile(fcView,
-        FileContextTestHelper.getTestRootPath(fcView,"/user/fooBar")));
+        fileContextTestHelper.getTestRootPath(fcView,"/user/fooBar")));
     Assert.assertTrue(isFile(fcTarget, new Path(targetTestRoot,"user/fooBar")));
     
     fcView.mkdir(new Path("/user/dirFoo"), FileContext.DEFAULT_PERM, false);
@@ -287,7 +288,7 @@ public class ViewFsBaseTest {
         exists(fcTarget, new Path(targetTestRoot,"user/dirFoo")));
     Assert.assertTrue("Renamed dest should  exist as dir",
         isDir(fcView,
-        FileContextTestHelper.getTestRootPath(fcView,"/user/dirFooBar")));
+        fileContextTestHelper.getTestRootPath(fcView,"/user/dirFooBar")));
     Assert.assertTrue("Renamed dest should  exist as dir in target",
         isDir(fcTarget,new Path(targetTestRoot,"user/dirFooBar")));
     
@@ -309,7 +310,7 @@ public class ViewFsBaseTest {
   // rename across mount points that point to same target also fail 
   @Test(expected=IOException.class) 
   public void testRenameAcrossMounts1() throws IOException {
-    FileContextTestHelper.createFile(fcView, "/user/foo");
+    fileContextTestHelper.createFile(fcView, "/user/foo");
     fcView.rename(new Path("/user/foo"), new Path("/user2/fooBarBar"));
     /* - code if we had wanted this to succeed
     Assert.assertFalse(exists(fc, new Path("/user/foo")));
@@ -327,7 +328,7 @@ public class ViewFsBaseTest {
 
   @Test(expected=IOException.class) 
   public void testRenameAcrossMounts2() throws IOException {
-    FileContextTestHelper.createFile(fcView, "/user/foo");
+    fileContextTestHelper.createFile(fcView, "/user/foo");
     fcView.rename(new Path("/user/foo"), new Path("/data/fooBar"));
   }
   
@@ -382,19 +383,19 @@ public class ViewFsBaseTest {
     FileStatus[] dirPaths = fcView.util().listStatus(new Path("/"));
     FileStatus fs;
     Assert.assertEquals(7, dirPaths.length);
-    fs = FileContextTestHelper.containsPath(fcView, "/user", dirPaths);
+    fs = fileContextTestHelper.containsPath(fcView, "/user", dirPaths);
       Assert.assertNotNull(fs);
       Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
-    fs = FileContextTestHelper.containsPath(fcView, "/data", dirPaths);
+    fs = fileContextTestHelper.containsPath(fcView, "/data", dirPaths);
       Assert.assertNotNull(fs);
       Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
-    fs = FileContextTestHelper.containsPath(fcView, "/internalDir", dirPaths);
+    fs = fileContextTestHelper.containsPath(fcView, "/internalDir", dirPaths);
       Assert.assertNotNull(fs);
       Assert.assertTrue("InternalDirs should appear as dir", fs.isDirectory());
-    fs = FileContextTestHelper.containsPath(fcView, "/danglingLink", dirPaths);
+    fs = fileContextTestHelper.containsPath(fcView, "/danglingLink", dirPaths);
       Assert.assertNotNull(fs);
       Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
-    fs = FileContextTestHelper.containsPath(fcView, "/linkToAFile", dirPaths);
+    fs = fileContextTestHelper.containsPath(fcView, "/linkToAFile", dirPaths);
       Assert.assertNotNull(fs);
       Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
       
@@ -404,11 +405,11 @@ public class ViewFsBaseTest {
       dirPaths = fcView.util().listStatus(new Path("/internalDir"));
       Assert.assertEquals(2, dirPaths.length);
 
-      fs = FileContextTestHelper.containsPath(fcView,
+      fs = fileContextTestHelper.containsPath(fcView,
           "/internalDir/internalDir2", dirPaths);
         Assert.assertNotNull(fs);
         Assert.assertTrue("InternalDirs should appear as dir",fs.isDirectory());
-      fs = FileContextTestHelper.containsPath(fcView,
+      fs = fileContextTestHelper.containsPath(fcView,
           "/internalDir/linkToDir2", dirPaths);
         Assert.assertNotNull(fs);
         Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
@@ -534,19 +535,19 @@ public class ViewFsBaseTest {
   
   @Test
   public void testResolvePathThroughMountPoints() throws IOException {
-    FileContextTestHelper.createFile(fcView, "/user/foo");
+    fileContextTestHelper.createFile(fcView, "/user/foo");
     Assert.assertEquals(new Path(targetTestRoot,"user/foo"),
                           fcView.resolvePath(new Path("/user/foo")));
     
     fcView.mkdir(
-        FileContextTestHelper.getTestRootPath(fcView, "/user/dirX"),
+        fileContextTestHelper.getTestRootPath(fcView, "/user/dirX"),
         FileContext.DEFAULT_PERM, false);
     Assert.assertEquals(new Path(targetTestRoot,"user/dirX"),
         fcView.resolvePath(new Path("/user/dirX")));
 
     
     fcView.mkdir(
-        FileContextTestHelper.getTestRootPath(fcView, "/user/dirX/dirY"),
+        fileContextTestHelper.getTestRootPath(fcView, "/user/dirX/dirY"),
         FileContext.DEFAULT_PERM, false);
     Assert.assertEquals(new Path(targetTestRoot,"user/dirX/dirY"),
         fcView.resolvePath(new Path("/user/dirX/dirY")));
@@ -566,7 +567,7 @@ public class ViewFsBaseTest {
   @Test(expected=FileNotFoundException.class) 
   public void testResolvePathMissingThroughMountPoints2() throws IOException {
     fcView.mkdir(
-        FileContextTestHelper.getTestRootPath(fcView, "/user/dirX"),
+        fileContextTestHelper.getTestRootPath(fcView, "/user/dirX"),
         FileContext.DEFAULT_PERM, false);
     fcView.resolvePath(new Path("/user/dirX/nonExisting"));
   }
@@ -584,29 +585,29 @@ public class ViewFsBaseTest {
   // Mkdir on internal mount table should fail
   @Test(expected=AccessControlException.class) 
   public void testInternalMkdirSlash() throws IOException {
-    fcView.mkdir(FileContextTestHelper.getTestRootPath(fcView, "/"),
+    fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/"),
         FileContext.DEFAULT_PERM, false);
   }
   
   @Test(expected=AccessControlException.class) 
   public void testInternalMkdirExisting1() throws IOException {
-    fcView.mkdir(FileContextTestHelper.getTestRootPath(fcView, "/internalDir"),
+    fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/internalDir"),
         FileContext.DEFAULT_PERM, false);
   }
   @Test(expected=AccessControlException.class) 
   public void testInternalMkdirExisting2() throws IOException {
-    fcView.mkdir(FileContextTestHelper.getTestRootPath(fcView,
+    fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView,
         "/internalDir/linkToDir2"),
         FileContext.DEFAULT_PERM, false);
   }
   @Test(expected=AccessControlException.class) 
   public void testInternalMkdirNew() throws IOException {
-    fcView.mkdir(FileContextTestHelper.getTestRootPath(fcView, "/dirNew"),
+    fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/dirNew"),
         FileContext.DEFAULT_PERM, false);
   }
   @Test(expected=AccessControlException.class) 
   public void testInternalMkdirNew2() throws IOException {
-    fcView.mkdir(FileContextTestHelper.getTestRootPath(fcView, "/internalDir/dirNew"),
+    fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/internalDir/dirNew"),
         FileContext.DEFAULT_PERM, false);
   }
   
@@ -614,28 +615,28 @@ public class ViewFsBaseTest {
   
   @Test(expected=AccessControlException.class) 
   public void testInternalCreate1() throws IOException {
-    FileContextTestHelper.createFileNonRecursive(fcView, "/foo"); // 1 component
+    fileContextTestHelper.createFileNonRecursive(fcView, "/foo"); // 1 component
   }
   
   @Test(expected=AccessControlException.class) 
   public void testInternalCreate2() throws IOException {  // 2 component
-    FileContextTestHelper.createFileNonRecursive(fcView, "/internalDir/foo");
+    fileContextTestHelper.createFileNonRecursive(fcView, "/internalDir/foo");
   }
   
   @Test(expected=AccessControlException.class) 
   public void testInternalCreateMissingDir() throws IOException {
-    FileContextTestHelper.createFile(fcView, "/missingDir/foo");
+    fileContextTestHelper.createFile(fcView, "/missingDir/foo");
   }
   
   @Test(expected=AccessControlException.class) 
   public void testInternalCreateMissingDir2() throws IOException {
-    FileContextTestHelper.createFile(fcView, "/missingDir/miss2/foo");
+    fileContextTestHelper.createFile(fcView, "/missingDir/miss2/foo");
   }
   
   
   @Test(expected=AccessControlException.class) 
   public void testInternalCreateMissingDir3() throws IOException {
-    FileContextTestHelper.createFile(fcView, "/internalDir/miss2/foo");
+    fileContextTestHelper.createFile(fcView, "/internalDir/miss2/foo");
   }
   
   // Delete on internal mount table should fail

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsTestSetup.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsTestSetup.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsTestSetup.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsTestSetup.java Thu May 30 22:43:16 2013
@@ -54,12 +54,12 @@ public class ViewFsTestSetup {
    /* 
    * return the ViewFS File context to be used for tests
    */
-  static public FileContext setupForViewFsLocalFs() throws Exception {
+  static public FileContext setupForViewFsLocalFs(FileContextTestHelper helper) throws Exception {
     /**
      * create the test root on local_fs - the  mount table will point here
      */
     FileContext fsTarget = FileContext.getLocalFSFileContext();
-    Path targetOfTests = FileContextTestHelper.getTestRootPath(fsTarget);
+    Path targetOfTests = helper.getTestRootPath(fsTarget);
     // In case previous test was killed before cleanup
     fsTarget.delete(targetOfTests, true);
     
@@ -67,7 +67,7 @@ public class ViewFsTestSetup {
     Configuration conf = new Configuration();
     
     // Set up viewfs link for test dir as described above
-    String testDir = FileContextTestHelper.getTestRootPath(fsTarget).toUri()
+    String testDir = helper.getTestRootPath(fsTarget).toUri()
         .getPath();
     linkUpFirstComponents(conf, testDir, fsTarget, "test dir");
     
@@ -92,9 +92,9 @@ public class ViewFsTestSetup {
    * 
    * delete the test directory in the target local fs
    */
-  static public void tearDownForViewFsLocalFs() throws Exception {
+  static public void tearDownForViewFsLocalFs(FileContextTestHelper helper) throws Exception {
     FileContext fclocal = FileContext.getLocalFSFileContext();
-    Path targetOfTests = FileContextTestHelper.getTestRootPath(fclocal);
+    Path targetOfTests = helper.getTestRootPath(fclocal);
     fclocal.delete(targetOfTests, true);
   }
   

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java Thu May 30 22:43:16 2013
@@ -23,7 +23,10 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
+import java.io.RandomAccessFile;
 import java.net.Socket;
+import java.nio.channels.FileLock;
+import java.nio.channels.OverlappingFileLockException;
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
@@ -63,17 +66,13 @@ public abstract class ClientBaseWithFixe
     static final File BASETEST =
         new File(System.getProperty("build.test.dir", "build"));
 
-    protected String hostPort = "127.0.0.1:" + PortAssignment.unique();
+    protected final String hostPort = initHostPort();
     protected int maxCnxns = 0;
     protected ServerCnxnFactory serverFactory = null;
     protected File tmpDir = null;
     
     long initialFdCount;
     
-    public ClientBaseWithFixes() {
-        super();
-    }
-
     /**
      * In general don't use this. Only use in the special case that you
      * want to ignore results (for whatever reason) in your test. Don't
@@ -154,6 +153,10 @@ public abstract class ClientBaseWithFixe
     private LinkedList<ZooKeeper> allClients;
     private boolean allClientsSetup = false;
 
+    private RandomAccessFile portNumLockFile;
+
+    private File portNumFile;
+
     protected TestableZooKeeper createClient(CountdownWatcher watcher, String hp)
         throws IOException, InterruptedException
     {
@@ -311,6 +314,7 @@ public abstract class ClientBaseWithFixe
 
         return tmpDir;
     }
+
     private static int getPort(String hostPort) {
         String[] split = hostPort.split(":");
         String portstr = split[split.length-1];
@@ -394,6 +398,35 @@ public abstract class ClientBaseWithFixe
         LOG.info("Client test setup finished");
     }
 
+    private String initHostPort() {
+        BASETEST.mkdirs();
+        int port;
+        for (;;) {
+            port = PortAssignment.unique();
+            FileLock lock = null;
+            portNumLockFile = null;
+            try {
+                try {
+                    portNumFile = new File(BASETEST, port + ".lock");
+                    portNumLockFile = new RandomAccessFile(portNumFile, "rw");
+                    try {
+                        lock = portNumLockFile.getChannel().tryLock();
+                    } catch (OverlappingFileLockException e) {
+                        continue;
+                    }
+                } finally {
+                    if (lock != null)
+                        break;
+                    if (portNumLockFile != null)
+                        portNumLockFile.close();
+                }
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return "127.0.0.1:" + port;
+    }
+
     protected void startServer() throws Exception {
         LOG.info("STARTING server");
         serverFactory = createNewServerInstance(tmpDir, serverFactory, hostPort, maxCnxns);
@@ -434,6 +467,9 @@ public abstract class ClientBaseWithFixe
 
         stopServer();
 
+        portNumLockFile.close();
+        portNumFile.delete();
+        
         if (tmpDir != null) {
             Assert.assertTrue("delete " + tmpDir.toString(), recursiveDelete(tmpDir));
         }

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java Thu May 30 22:43:16 2013
@@ -39,8 +39,10 @@ import org.mockito.Mockito;
 public class TestSequenceFile extends TestCase {
   private static final Log LOG = LogFactory.getLog(TestSequenceFile.class);
 
-  private static Configuration conf = new Configuration();
+  private Configuration conf = new Configuration();
   
+  public TestSequenceFile() { }
+
   public TestSequenceFile(String name) { super(name); }
 
   /** Unit tests for SequenceFile. */
@@ -126,7 +128,7 @@ public class TestSequenceFile extends Te
     }
   }
 
-  private static void writeTest(FileSystem fs, int count, int seed, Path file, 
+  private void writeTest(FileSystem fs, int count, int seed, Path file, 
                                 CompressionType compressionType, CompressionCodec codec)
     throws IOException {
     fs.delete(file, true);
@@ -146,7 +148,7 @@ public class TestSequenceFile extends Te
     writer.close();
   }
 
-  private static void readTest(FileSystem fs, int count, int seed, Path file)
+  private void readTest(FileSystem fs, int count, int seed, Path file)
     throws IOException {
     LOG.debug("reading " + count + " records");
     SequenceFile.Reader reader = new SequenceFile.Reader(fs, file, conf);
@@ -202,7 +204,7 @@ public class TestSequenceFile extends Te
   }
 
 
-  private static void sortTest(FileSystem fs, int count, int megabytes, 
+  private void sortTest(FileSystem fs, int count, int megabytes, 
                                int factor, boolean fast, Path file)
     throws IOException {
     fs.delete(new Path(file+".sorted"), true);
@@ -212,7 +214,7 @@ public class TestSequenceFile extends Te
     LOG.info("done sorting " + count + " debug");
   }
 
-  private static void checkSort(FileSystem fs, int count, int seed, Path file)
+  private void checkSort(FileSystem fs, int count, int seed, Path file)
     throws IOException {
     LOG.info("sorting " + count + " records in memory for debug");
     RandomDatum.Generator generator = new RandomDatum.Generator(seed);
@@ -249,7 +251,7 @@ public class TestSequenceFile extends Te
     LOG.debug("sucessfully checked " + count + " records");
   }
 
-  private static void mergeTest(FileSystem fs, int count, int seed, Path file, 
+  private void mergeTest(FileSystem fs, int count, int seed, Path file, 
                                 CompressionType compressionType,
                                 boolean fast, int factor, int megabytes)
     throws IOException {
@@ -293,7 +295,7 @@ public class TestSequenceFile extends Te
       .merge(sortedNames, file.suffix(".sorted"));
   }
 
-  private static SequenceFile.Sorter newSorter(FileSystem fs, 
+  private SequenceFile.Sorter newSorter(FileSystem fs, 
                                                boolean fast,
                                                int megabytes, int factor) {
     SequenceFile.Sorter sorter = 
@@ -370,7 +372,7 @@ public class TestSequenceFile extends Te
   }
   
   
-  private static SequenceFile.Metadata readMetadata(FileSystem fs, Path file)
+  private SequenceFile.Metadata readMetadata(FileSystem fs, Path file)
     throws IOException {
     LOG.info("reading file: " + file.toString());
     SequenceFile.Reader reader = new SequenceFile.Reader(fs, file, conf);
@@ -379,7 +381,7 @@ public class TestSequenceFile extends Te
     return meta;
   }
 
-  private static void writeMetadataTest(FileSystem fs, int count, int seed, Path file, 
+  private void writeMetadataTest(FileSystem fs, int count, int seed, Path file, 
                                         CompressionType compressionType, CompressionCodec codec, SequenceFile.Metadata metadata)
     throws IOException {
     fs.delete(file, true);
@@ -399,7 +401,7 @@ public class TestSequenceFile extends Te
     writer.close();
   }
 
-  private static void sortMetadataTest(FileSystem fs, Path unsortedFile, Path sortedFile, SequenceFile.Metadata metadata)
+  private void sortMetadataTest(FileSystem fs, Path unsortedFile, Path sortedFile, SequenceFile.Metadata metadata)
     throws IOException {
     fs.delete(sortedFile, true);
     LOG.info("sorting: " + unsortedFile + " to: " + sortedFile);
@@ -538,7 +540,6 @@ public class TestSequenceFile extends Te
   }
 
   public void testRecursiveSeqFileCreate() throws IOException {
-    Configuration conf = new Configuration();
     FileSystem fs = FileSystem.getLocal(conf);
     Path name = new Path(new Path(System.getProperty("test.build.data","."),
         "recursiveCreateDir") , "file");
@@ -673,7 +674,9 @@ public class TestSequenceFile extends Te
         }
       }
         
-      fs = file.getFileSystem(conf);
+      TestSequenceFile test = new TestSequenceFile();
+      
+      fs = file.getFileSystem(test.conf);
 
       LOG.info("count = " + count);
       LOG.info("megabytes = " + megabytes);
@@ -696,25 +699,25 @@ public class TestSequenceFile extends Te
       CompressionType compressionType = 
         CompressionType.valueOf(compressType);
       CompressionCodec codec = (CompressionCodec)ReflectionUtils.newInstance(
-                                                                             conf.getClassByName(compressionCodec), 
-                                                                             conf);
+                                                                             test.conf.getClassByName(compressionCodec), 
+                                                                             test.conf);
 
       if (rwonly || (create && !merge)) {
-        writeTest(fs, count, seed, file, compressionType, codec);
-        readTest(fs, count, seed, file);
+        test.writeTest(fs, count, seed, file, compressionType, codec);
+        test.readTest(fs, count, seed, file);
       }
 
       if (!rwonly) {
         if (merge) {
-          mergeTest(fs, count, seed, file, compressionType, 
+          test.mergeTest(fs, count, seed, file, compressionType, 
                     fast, factor, megabytes);
         } else {
-          sortTest(fs, count, megabytes, factor, fast, file);
+          test.sortTest(fs, count, megabytes, factor, fast, file);
         }
       }
     
       if (check) {
-        checkSort(fs, count, seed, file);
+        test.checkSort(fs, count, seed, file);
       }
     } finally {
       fs.close();

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSerialization.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSerialization.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSerialization.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSerialization.java Thu May 30 22:43:16 2013
@@ -46,7 +46,7 @@ public class TestSequenceFileSerializati
   
   public void testJavaSerialization() throws Exception {
     Path file = new Path(System.getProperty("test.build.data",".") +
-        "/test.seq");
+        "/testseqser.seq");
     
     fs.delete(file, true);
     Writer writer = SequenceFile.createWriter(fs, conf, file, Long.class,

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileByteArrays.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileByteArrays.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileByteArrays.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileByteArrays.java Thu May 30 22:43:16 2013
@@ -64,7 +64,7 @@ public class TestTFileByteArrays {
 
   private String compression = Compression.Algorithm.GZ.getName();
   private String comparator = "memcmp";
-  private String outputFile = "TFileTestByteArrays";
+  private final String outputFile = getClass().getSimpleName();
 
   /*
    * pre-sampled numbers of records in one block, based on the given the
@@ -75,17 +75,16 @@ public class TestTFileByteArrays {
   private int records1stBlock = usingNative ? 5674 : 4480;
   private int records2ndBlock = usingNative ? 5574 : 4263;
 
-  public void init(String compression, String comparator, String outputFile,
+  public void init(String compression, String comparator,
       int numRecords1stBlock, int numRecords2ndBlock) {
-    init(compression, comparator, outputFile);
+    init(compression, comparator);
     this.records1stBlock = numRecords1stBlock;
     this.records2ndBlock = numRecords2ndBlock;
   }
   
-  public void init(String compression, String comparator, String outputFile) {
+  public void init(String compression, String comparator) {
     this.compression = compression;
     this.comparator = comparator;
-    this.outputFile = outputFile;
   }
 
   @Before
@@ -99,7 +98,7 @@ public class TestTFileByteArrays {
   @After
   public void tearDown() throws IOException {
     if (!skip)
-    fs.delete(path, true);
+      fs.delete(path, true);
   }
 
   @Test

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileJClassComparatorByteArrays.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileJClassComparatorByteArrays.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileJClassComparatorByteArrays.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileJClassComparatorByteArrays.java Thu May 30 22:43:16 2013
@@ -37,8 +37,7 @@ public class TestTFileJClassComparatorBy
   @Override
   public void setUp() throws IOException {
     init(Compression.Algorithm.GZ.getName(),
-        "jclass: org.apache.hadoop.io.file.tfile.MyComparator",
-        "TFileTestJClassComparator");
+        "jclass: org.apache.hadoop.io.file.tfile.MyComparator");
     super.setUp();
   }
 }

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileLzoCodecsByteArrays.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileLzoCodecsByteArrays.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileLzoCodecsByteArrays.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileLzoCodecsByteArrays.java Thu May 30 22:43:16 2013
@@ -34,8 +34,7 @@ public class TestTFileLzoCodecsByteArray
     }
 
     // TODO: sample the generated key/value records, and put the numbers below
-    init(Compression.Algorithm.LZO.getName(), "memcmp", "TFileTestCodecsLzo",
-        2605, 2558);
+    init(Compression.Algorithm.LZO.getName(), "memcmp", 2605, 2558);
     if (!skip)
       super.setUp();
   }

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileLzoCodecsStreams.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileLzoCodecsStreams.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileLzoCodecsStreams.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileLzoCodecsStreams.java Thu May 30 22:43:16 2013
@@ -32,7 +32,7 @@ public class TestTFileLzoCodecsStreams e
     if (skip) {
       System.out.println("Skipped");
     }
-    init(Compression.Algorithm.LZO.getName(), "memcmp", "TFileTestCodecsLzo");
+    init(Compression.Algorithm.LZO.getName(), "memcmp");
     if (!skip) 
       super.setUp();
   }

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsByteArrays.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsByteArrays.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsByteArrays.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsByteArrays.java Thu May 30 22:43:16 2013
@@ -25,8 +25,7 @@ public class TestTFileNoneCodecsByteArra
    */
   @Override
   public void setUp() throws IOException {
-    init(Compression.Algorithm.NONE.getName(), "memcmp", "TFileTestCodecsNone",
-        24, 24);
+    init(Compression.Algorithm.NONE.getName(), "memcmp", 24, 24);
     super.setUp();
   }
 }

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsJClassComparatorByteArrays.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsJClassComparatorByteArrays.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsJClassComparatorByteArrays.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsJClassComparatorByteArrays.java Thu May 30 22:43:16 2013
@@ -33,8 +33,7 @@ public class TestTFileNoneCodecsJClassCo
   @Override
   public void setUp() throws IOException {
     init(Compression.Algorithm.NONE.getName(),
-        "jclass: org.apache.hadoop.io.file.tfile.MyComparator",
-        "TestTFileNoneCodecsJClassComparatorByteArrays", 24, 24);
+        "jclass: org.apache.hadoop.io.file.tfile.MyComparator", 24, 24);
     super.setUp();
   }
 }

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsStreams.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsStreams.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsStreams.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsStreams.java Thu May 30 22:43:16 2013
@@ -26,7 +26,7 @@ public class TestTFileNoneCodecsStreams 
    */
   @Override
   public void setUp() throws IOException {
-    init(Compression.Algorithm.NONE.getName(), "memcmp", "TFileTestCodecsNone");
+    init(Compression.Algorithm.NONE.getName(), "memcmp");
     super.setUp();
   }
 }

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileStreams.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileStreams.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileStreams.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileStreams.java Thu May 30 22:43:16 2013
@@ -57,12 +57,11 @@ public class TestTFileStreams extends Te
 
   private String compression = Compression.Algorithm.GZ.getName();
   private String comparator = "memcmp";
-  private String outputFile = "TFileTestStreams";
+  private final String outputFile = getClass().getSimpleName();
 
-  public void init(String compression, String comparator, String outputFile) {
+  public void init(String compression, String comparator) {
     this.compression = compression;
     this.comparator = comparator;
-    this.outputFile = outputFile;
   }
 
   @Override

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSystemImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSystemImpl.java?rev=1488040&r1=1488039&r2=1488040&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSystemImpl.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSystemImpl.java Thu May 30 22:43:16 2013
@@ -64,6 +64,9 @@ import org.apache.hadoop.metrics2.lib.De
 @RunWith(MockitoJUnitRunner.class)
 public class TestMetricsSystemImpl {
   private static final Log LOG = LogFactory.getLog(TestMetricsSystemImpl.class);
+  
+  static { DefaultMetricsSystem.setMiniClusterMode(true); }
+  
   @Captor private ArgumentCaptor<MetricsRecord> r1;
   @Captor private ArgumentCaptor<MetricsRecord> r2;
   private static String hostname = MetricsSystemImpl.getHostname();



Mime
View raw message