From 9a114bebd8130b40144bb78864e107c8159e3199 Mon Sep 17 00:00:00 2001 From: Tsz-wo Sze Date: Thu, 27 Feb 2014 03:10:25 +0000 Subject: [PATCH] HDFS-6026. Fix TestDFSUpgrade and TestDataNodeRollingUpgrade. Contributed by jing9 git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-5535@1572417 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-5535.txt | 3 +++ .../src/test/java/org/apache/hadoop/hdfs/TestDFSUpgrade.java | 4 ++-- .../hdfs/server/datanode/TestDataNodeRollingUpgrade.java | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-5535.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-5535.txt index a9dc4a564f..e021cd9947 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-5535.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-5535.txt @@ -114,3 +114,6 @@ HDFS-5535 subtasks: HDFS-6024. Test whether the NN will reject the downgrade if it has a fsimage from a newer release. (Haohui Mai via jing9) + + HDFS-6026. Fix TestDFSUpgrade and TestDataNodeRollingUpgrade. + (jing9 via szetszwo) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSUpgrade.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSUpgrade.java index 73006baed1..ee9e91dc73 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSUpgrade.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSUpgrade.java @@ -235,7 +235,7 @@ public void testUpgrade() throws Exception { // make sure that rolling upgrade cannot be started try { final DistributedFileSystem dfs = cluster.getFileSystem(); - dfs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE); + dfs.setSafeMode(SafeModeAction.SAFEMODE_ENTER); dfs.rollingUpgrade(RollingUpgradeAction.PREPARE); fail(); } catch(RemoteException re) { @@ -378,7 +378,7 @@ public void testUpgrade() throws Exception { // make sure that rolling upgrade cannot be started try { final DistributedFileSystem dfs = cluster.getFileSystem(); - dfs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE); + dfs.setSafeMode(SafeModeAction.SAFEMODE_ENTER); dfs.rollingUpgrade(RollingUpgradeAction.PREPARE); fail(); } catch(RemoteException re) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeRollingUpgrade.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeRollingUpgrade.java index d548da4e10..5299c7c2ec 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeRollingUpgrade.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeRollingUpgrade.java @@ -41,6 +41,7 @@ import org.apache.hadoop.hdfs.protocol.BlockLocalPathInfo; import org.apache.hadoop.hdfs.protocol.ExtendedBlock; import org.apache.hadoop.hdfs.protocol.LocatedBlocks; +import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction; import org.apache.hadoop.hdfs.server.namenode.NameNode; import org.apache.hadoop.hdfs.tools.DFSAdmin; import org.junit.Test; @@ -194,6 +195,7 @@ public void testDatanodeRollingUpgradeWithFinalize() throws Exception { DFSTestUtil.createFile(fs, testFile1, FILE_SIZE, REPL_FACTOR, SEED); DFSTestUtil.createFile(fs, testFile2, FILE_SIZE, REPL_FACTOR, SEED); + fs.setSafeMode(SafeModeAction.SAFEMODE_ENTER); startRollingUpgrade(); File blockFile = getBlockForFile(testFile2, true); File trashFile = getTrashFileForBlock(blockFile, false); @@ -220,6 +222,7 @@ public void testDatanodeRollingUpgradeWithRollback() throws Exception { DFSTestUtil.createFile(fs, testFile1, FILE_SIZE, REPL_FACTOR, SEED); String fileContents1 = DFSTestUtil.readFile(fs, testFile1); + fs.setSafeMode(SafeModeAction.SAFEMODE_ENTER); startRollingUpgrade(); File blockFile = getBlockForFile(testFile1, true);