From 9e148aa0bc387a098785a8dddbbce23480aa5eb9 Mon Sep 17 00:00:00 2001 From: Inigo Goiri Date: Fri, 15 Jun 2018 16:49:06 -0700 Subject: [PATCH] HDFS-13681. Fix TestStartup.testNNFailToStartOnReadOnlyNNDir test failure on Windows. Contributed by Xiao Liang. (cherry picked from commit 8762e9cf10fa100dd5f7fd695f5e52b75a94c5d4) --- .../apache/hadoop/hdfs/server/namenode/TestStartup.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStartup.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStartup.java index f8a033641d3..5d58658bb0f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStartup.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStartup.java @@ -689,8 +689,8 @@ public class TestStartup { assertTrue(nnDirs.iterator().hasNext()); assertEquals( "NN dir should be created after NN startup.", - nnDirStr, - nnDirs.iterator().next().getPath()); + new File(nnDirStr), + new File(nnDirs.iterator().next().getPath())); final File nnDir = new File(nnDirStr); assertTrue(nnDir.exists()); assertTrue(nnDir.isDirectory()); @@ -699,7 +699,7 @@ public class TestStartup { /* set read only */ assertTrue( "Setting NN dir read only should succeed.", - nnDir.setReadOnly()); + FileUtil.setWritable(nnDir, false)); cluster.restartNameNodes(); fail("Restarting NN should fail on read only NN dir."); } catch (InconsistentFSStateException e) { @@ -711,7 +711,8 @@ public class TestStartup { "storage directory does not exist or is not accessible.")))); } finally { /* set back to writable in order to clean it */ - assertTrue("Setting NN dir should succeed.", nnDir.setWritable(true)); + assertTrue("Setting NN dir should succeed.", + FileUtil.setWritable(nnDir, true)); } } }