From 24f0d56afb853a371f905c4569d82d09d89cf13e Mon Sep 17 00:00:00 2001 From: Konstantin V Shvachko Date: Sat, 24 Jan 2015 18:07:56 -0800 Subject: [PATCH] HDFS-7676. Fix TestFileTruncate to avoid bug of HDFS-7611. Contributed by Konstantin Shvachko. --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../apache/hadoop/hdfs/server/namenode/TestFileTruncate.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 192cfc82150..82d933c179a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -500,6 +500,8 @@ Release 2.7.0 - UNRELEASED HDFS-7659. truncate should check negative value of the new length. (Yi Liu via shv) + HDFS-7676. Fix TestFileTruncate to avoid bug of HDFS-7611. (shv) + Release 2.6.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileTruncate.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileTruncate.java index 1612a24cf5f..e8250a21d09 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileTruncate.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileTruncate.java @@ -496,6 +496,11 @@ public class TestFileTruncate { */ @Test public void testTruncateEditLogLoad() throws IOException { + // purge previously accumulated edits + fs.setSafeMode(SafeModeAction.SAFEMODE_ENTER); + fs.saveNamespace(); + fs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE); + int startingFileSize = 2 * BLOCK_SIZE + BLOCK_SIZE / 2; int toTruncate = 1; final String s = "/testTruncateEditLogLoad";