Skip to content
Browse files

Fix TestFSEditLogLoader for new layout. (trivial fixup)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/branches/HDFS-1073@1134166 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent b3fe242 commit a425c4f0c1a633b31a5a22a4b2a5e4aa85512a10 @toddlipcon toddlipcon committed
View
14 src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/FSImageTestUtil.java
@@ -35,6 +35,7 @@
import java.util.Set;
import org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory;
+import org.apache.hadoop.hdfs.server.namenode.FSImageTransactionalStorageInspector.FoundEditLog;
import org.apache.hadoop.hdfs.server.namenode.FSImageTransactionalStorageInspector.FoundFSImage;
import org.apache.hadoop.hdfs.server.namenode.NNStorage.NameNodeDirType;
import org.apache.hadoop.hdfs.util.MD5FileUtils;
@@ -236,6 +237,19 @@ public static File findNewestImageFile(String currentDirPath) throws IOException
}
/**
+ * @return the latest edits log, finalized or otherwise, from the given
+ * storage directory.
+ */
+ public static FoundEditLog findLatestEditsLog(StorageDirectory sd)
+ throws IOException {
+ FSImageTransactionalStorageInspector inspector =
+ new FSImageTransactionalStorageInspector();
+ inspector.inspectDirectory(sd);
+
+ return inspector.foundEditLogs.get(inspector.foundEditLogs.size() - 1);
+ }
+
+ /**
* Corrupt the given VERSION file by replacing a given
* key with a new value and re-writing the file.
*
View
6 src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFSEditLogLoader.java
@@ -57,9 +57,11 @@ public void testDisplayRecentEditLogOpCodes() throws IOException {
fileSys.mkdirs(new Path("/tmp/tmp" + i));
}
StorageDirectory sd = fsimage.getStorage().dirIterator(NameNodeDirType.EDITS).next();
- File editFile = NNStorage.getStorageFile(sd, NameNodeFile.EDITS);
cluster.shutdown();
-
+
+ File editFile = FSImageTestUtil.findLatestEditsLog(sd).getFile();
+ assertTrue("Should exist: " + editFile, editFile.exists());
+
// Corrupt the edits file.
long fileLen = editFile.length();
RandomAccessFile rwf = new RandomAccessFile(editFile, "rw");

0 comments on commit a425c4f

Please sign in to comment.
Something went wrong with that request. Please try again.