hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sur...@apache.org
Subject svn commit: r817497 - in /hadoop/common/branches/branch-0.21: CHANGES.txt src/test/core/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java
Date Tue, 22 Sep 2009 04:15:49 GMT
Author: suresh
Date: Tue Sep 22 04:15:48 2009
New Revision: 817497

URL: http://svn.apache.org/viewvc?rev=817497&view=rev
Log:
HADOOP-6274. Fix TestLocalFSFileContextMainOperations test failure. Contributed by Gary Murry.

Modified:
    hadoop/common/branches/branch-0.21/CHANGES.txt
    hadoop/common/branches/branch-0.21/src/test/core/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java

Modified: hadoop/common/branches/branch-0.21/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.21/CHANGES.txt?rev=817497&r1=817496&r2=817497&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.21/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.21/CHANGES.txt Tue Sep 22 04:15:48 2009
@@ -1061,6 +1061,8 @@
     html characters in the parameters, to prevent cross site scripting 
     attacks. (omalley)
 
+    HADOOP-6274. Fix TestLocalFSFileContextMainOperations test failure. (Gary Murry via suresh).
+
 Release 0.20.1 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-0.21/src/test/core/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.21/src/test/core/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java?rev=817497&r1=817496&r2=817497&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.21/src/test/core/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java
(original)
+++ hadoop/common/branches/branch-0.21/src/test/core/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java
Tue Sep 22 04:15:48 2009
@@ -267,18 +267,10 @@
     paths = fc.listStatus(getTestRootPath("test/hadoop"));
     Assert.assertEquals(3, paths.length);
 
-    
-    Assert.assertTrue(getTestRootPath("test/hadoop/a").equals(paths[0].getPath()) ||
-        getTestRootPath("test/hadoop/a").equals(paths[1].getPath()) ||
-        getTestRootPath("test/hadoop/a").equals(paths[2].getPath()));
-    Assert.assertTrue(getTestRootPath("test/hadoop/b").equals(paths[0].getPath()) ||
-        getTestRootPath("test/hadoop/b").equals(paths[1].getPath()) ||
-        getTestRootPath("test/hadoop/b").equals(paths[2].getPath()));
-    Assert.assertTrue(getTestRootPath("test/hadoop/c").equals(paths[0].getPath()) ||
-        getTestRootPath("test/hadoop/c").equals(paths[1].getPath()) ||
-        getTestRootPath("test/hadoop/c").equals(paths[2].getPath()));
-
-
+    Assert.assertTrue(containsPath(getTestRootPath("test/hadoop/a"), paths));
+    Assert.assertTrue(containsPath(getTestRootPath("test/hadoop/b"), paths));
+    Assert.assertTrue(containsPath(getTestRootPath("test/hadoop/c"), paths));
+  
     paths = fc.listStatus(getTestRootPath("test/hadoop/a"));
     Assert.assertEquals(0, paths.length);
   }
@@ -315,39 +307,12 @@
       }
     }
 
-    //should return 2 paths ("/test/hadoop/axa2" and "/test/hadoop/axx2")
+    //should return 2 paths ("/test/hadoop/axa" and "/test/hadoop/axx")
     FileStatus[] filteredPaths = fc.util().listStatus(getTestRootPath("test/hadoop"), 
                                                       TEST_X_FILTER);
     Assert.assertEquals(2,filteredPaths.length);
-    Assert.assertTrue(getTestRootPath(TEST_DIR_AXA).equals(filteredPaths[0].getPath()) ||
-        getTestRootPath(TEST_DIR_AXA).equals(filteredPaths[1].getPath()));
-    Assert.assertTrue(getTestRootPath(TEST_DIR_AXX).equals(filteredPaths[0].getPath()) ||
-        getTestRootPath(TEST_DIR_AXX).equals(filteredPaths[1].getPath()));
-  }
-  
-  @Test
-  public void testListStatusFilterWithAnArrayOrPaths() throws Exception {
-    Path[] testDirs = { getTestRootPath(TEST_DIR_AAA),
-                        getTestRootPath(TEST_DIR_AXA),
-                        getTestRootPath(TEST_DIR_AXX),
-                        getTestRootPath(TEST_DIR_AAA2), };
-    Path[] targetDirs = { getTestRootPath("test"),
-                          getTestRootPath("test/hadoop"), };
-
-    if (fc.exists(testDirs[0]) == false) {
-      for (Path path : testDirs) {
-        fc.mkdir(path, FsPermission.getDefault(), true);
-      }
-    }
-
-    //test using a path[]
-    FileStatus[] filteredPaths = fc.util().listStatus(targetDirs, TEST_X_FILTER);
-    Assert.assertEquals(2,filteredPaths.length);
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AXA), 
-                        filteredPaths[0].getPath());
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AXX), 
-                        filteredPaths[1].getPath()); 
-   
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXA), filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXX), filteredPaths));
   }
   
   @Test
@@ -395,8 +360,8 @@
     //Should return two items ("/test/hadoop" and "/test/hadoop2")
     FileStatus[] paths = fc.util().globStatus(getTestRootPath("test/hadoop*"));
     Assert.assertEquals(2, paths.length);
-    Assert.assertEquals(getTestRootPath("test/hadoop"), paths[0].getPath());
-    Assert.assertEquals(getTestRootPath("test/hadoop2"), paths[1].getPath());
+    Assert.assertTrue(containsPath(getTestRootPath("test/hadoop"), paths));
+    Assert.assertTrue(containsPath(getTestRootPath("test/hadoop2"), paths));
   }
   
   @Test
@@ -416,10 +381,10 @@
     //"/test/hadoop/axx", and "/test/hadoop2/axx")
     FileStatus[] paths = fc.util().globStatus(getTestRootPath("test/hadoop*/*"));
     Assert.assertEquals(4, paths.length);
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AAA), paths[0].getPath());
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AXA), paths[1].getPath());
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AXX), paths[2].getPath());
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AAA2), paths[3].getPath());
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AAA), paths));
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXA), paths));
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXX), paths));
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AAA2), paths));
   }
   
   @Test
@@ -438,8 +403,8 @@
     //Should return only 2 items ("/test/hadoop/axa", "/test/hadoop/axx")
     FileStatus[] paths = fc.util().globStatus(getTestRootPath("test/hadoop/ax?"));
     Assert.assertEquals(2, paths.length);
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AXA), paths[0].getPath());
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AXX), paths[1].getPath());
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXA), paths));
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXX), paths));
   }
   
   @Test
@@ -478,12 +443,9 @@
     FileStatus[] filteredPaths = fc.util().globStatus(getTestRootPath("test/hadoop/*"), 
                                                       DEFAULT_FILTER);  
     Assert.assertEquals(3,filteredPaths.length);
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AAA), 
-                        filteredPaths[0].getPath());
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AXA), 
-                        filteredPaths[1].getPath());
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AXX), 
-                        filteredPaths[2].getPath());
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AAA), filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXA), filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXX), filteredPaths));
   }
   
   @Test
@@ -503,8 +465,9 @@
     FileStatus[] filteredPaths = fc.util().globStatus(getTestRootPath("test/hadoop/a??"),

                                                       DEFAULT_FILTER);
     Assert.assertEquals(3,filteredPaths.length);
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AAA), filteredPaths[0].getPath());
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AXA), filteredPaths[1].getPath());
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AAA), filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXA), filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXX), filteredPaths));
   }
   
   @Test
@@ -524,10 +487,8 @@
     FileStatus[] filteredPaths = fc.util().globStatus(getTestRootPath("test/hadoop/*"), 
                                                       TEST_X_FILTER);  
     Assert.assertEquals(2,filteredPaths.length);
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AXA), 
-                        filteredPaths[0].getPath());
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AXX), 
-                        filteredPaths[1].getPath());
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXA), filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXX), filteredPaths));
   }
   
   @Test
@@ -566,8 +527,8 @@
     FileStatus[] filteredPaths = fc.util().globStatus(getTestRootPath("test/hadoop/a??"),

                                                       TEST_X_FILTER);
     Assert.assertEquals(2,filteredPaths.length);
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AXA), filteredPaths[0].getPath());
-    Assert.assertEquals(getTestRootPath(TEST_DIR_AXX), filteredPaths[1].getPath());
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXA), filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXX), filteredPaths));
   }
   
   @Test
@@ -969,4 +930,11 @@
     Assert.assertEquals("Source exists", srcExists, fc.exists(src));
     Assert.assertEquals("Destination exists", dstExists, fc.exists(dst));
   }
+  private boolean containsPath(Path path, FileStatus[] filteredPaths) {
+    for(int i = 0; i < filteredPaths.length; i ++) { 
+      if(getTestRootPath(path.toString()).equals(filteredPaths[i].getPath())) 
+        return true;
+      }
+    return false;
+ }
 }



Mime
View raw message