hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sur...@apache.org
Subject svn commit: r1476591 - in /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs: CHANGES.txt src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNNStorageRetentionManager.java
Date Sat, 27 Apr 2013 14:38:02 GMT
Author: suresh
Date: Sat Apr 27 14:38:02 2013
New Revision: 1476591

URL: http://svn.apache.org/r1476591
Log:
HDFS-4743. TestNNStorageRetentionManager fails on Windows. Contributed by Chris Nauroth.

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/server/namenode/TestNNStorageRetentionManager.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=1476591&r1=1476590&r2=1476591&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Sat Apr 27 14:38:02 2013
@@ -314,6 +314,9 @@ Trunk (Unreleased)
     HDFS-4741. TestStorageRestore#testStorageRestoreFailure fails on Windows.
     (Arpit Agarwal via suresh)
 
+    HDFS-4743. TestNNStorageRetentionManager fails on Windows.
+    (Chris Nauroth via suresh)
+
   BREAKDOWN OF HDFS-347 SUBTASKS AND RELATED JIRAS
 
     HDFS-4353. Encapsulate connections to peers in Peer and PeerServer classes.

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNNStorageRetentionManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNNStorageRetentionManager.java?rev=1476591&r1=1476590&r2=1476591&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNNStorageRetentionManager.java
(original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNNStorageRetentionManager.java
Sat Apr 27 14:38:02 2013
@@ -21,6 +21,7 @@ import static org.apache.hadoop.hdfs.ser
 import static org.apache.hadoop.hdfs.server.namenode.NNStorage.getImageFileName;
 import static org.apache.hadoop.hdfs.server.namenode.NNStorage.getInProgressEditsFileName;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.List;
@@ -247,30 +248,32 @@ public class TestNNStorageRetentionManag
       .purgeLog(logsPurgedCaptor.capture());
 
     // Check images
-    Set<String> purgedPaths = Sets.newHashSet();
+    Set<String> purgedPaths = Sets.newLinkedHashSet();
     for (FSImageFile purged : imagesPurgedCaptor.getAllValues()) {
-      purgedPaths.add(purged.getFile().toString());
+      purgedPaths.add(fileToPath(purged.getFile()));
     }    
-    Assert.assertEquals(Joiner.on(",").join(tc.expectedPurgedImages),
-        Joiner.on(",").join(purgedPaths));
+    Assert.assertEquals(
+      Joiner.on(",").join(filesToPaths(tc.expectedPurgedImages)),
+      Joiner.on(",").join(purgedPaths));
 
     // Check images
     purgedPaths.clear();
     for (EditLogFile purged : logsPurgedCaptor.getAllValues()) {
-      purgedPaths.add(purged.getFile().toString());
+      purgedPaths.add(fileToPath(purged.getFile()));
     }    
-    Assert.assertEquals(Joiner.on(",").join(tc.expectedPurgedLogs),
-        Joiner.on(",").join(purgedPaths));
+    Assert.assertEquals(
+      Joiner.on(",").join(filesToPaths(tc.expectedPurgedLogs)),
+      Joiner.on(",").join(purgedPaths));
   }
   
   private static class TestCaseDescription {
-    private Map<String, FakeRoot> dirRoots = Maps.newHashMap();
-    private Set<String> expectedPurgedLogs = Sets.newHashSet();
-    private Set<String> expectedPurgedImages = Sets.newHashSet();
+    private Map<File, FakeRoot> dirRoots = Maps.newHashMap();
+    private Set<File> expectedPurgedLogs = Sets.newLinkedHashSet();
+    private Set<File> expectedPurgedImages = Sets.newLinkedHashSet();
     
     private static class FakeRoot {
       NameNodeDirType type;
-      List<String> files;
+      List<File> files;
       
       FakeRoot(NameNodeDirType type) {
         this.type = type;
@@ -280,33 +283,35 @@ public class TestNNStorageRetentionManag
       StorageDirectory mockStorageDir() {
         return FSImageTestUtil.mockStorageDirectory(
             type, false,
-            files.toArray(new String[0]));
+            filesToPaths(files).toArray(new String[0]));
       }
     }
 
     void addRoot(String root, NameNodeDirType dir) {
-      dirRoots.put(root, new FakeRoot(dir));
+      dirRoots.put(new File(root), new FakeRoot(dir));
     }
 
-    private void addFile(String path) {
-      for (Map.Entry<String, FakeRoot> entry : dirRoots.entrySet()) {
-        if (path.startsWith(entry.getKey())) {
-          entry.getValue().files.add(path);
+    private void addFile(File file) {
+      for (Map.Entry<File, FakeRoot> entry : dirRoots.entrySet()) {
+        if (fileToPath(file).startsWith(fileToPath(entry.getKey()))) {
+          entry.getValue().files.add(file);
         }
       }
     }
     
     void addLog(String path, boolean expectPurge) {
-      addFile(path);
+      File file = new File(path);
+      addFile(file);
       if (expectPurge) {
-        expectedPurgedLogs.add(path);
+        expectedPurgedLogs.add(file);
       }
     }
     
     void addImage(String path, boolean expectPurge) {
-      addFile(path);
+      File file = new File(path);
+      addFile(file);
       if (expectPurge) {
-        expectedPurgedImages.add(path);
+        expectedPurgedImages.add(file);
       }
     }
     
@@ -364,6 +369,30 @@ public class TestNNStorageRetentionManag
     }
   }
 
+  /**
+   * Converts a file to a platform-agnostic URI path.
+   * 
+   * @param file File to convert
+   * @return String path
+   */
+  private static String fileToPath(File file) {
+    return file.toURI().getPath();
+  }
+
+  /**
+   * Converts multiple files to platform-agnostic URI paths.
+   * 
+   * @param files Collection<File> files to convert
+   * @return Collection<String> paths
+   */
+  private static Collection<String> filesToPaths(Collection<File> files) {
+    List<String> paths = Lists.newArrayList();
+    for (File file: files) {
+      paths.add(fileToPath(file));
+    }
+    return paths;
+  }
+
   private static NNStorage mockStorageForDirs(final StorageDirectory ... mockDirs)
       throws IOException {
     NNStorage mockStorage = Mockito.mock(NNStorage.class);



Mime
View raw message