From b5d02a63cbce062874e3b51816cf9ec962995dbd Mon Sep 17 00:00:00 2001 From: Jitendra Nath Pandey Date: Thu, 9 Feb 2012 21:08:17 +0000 Subject: [PATCH] HDFS-2915. HA: TestFailureOfSharedDir.testFailureOfSharedDir() has race condition. Contributed by Bikas Saha. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1242522 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-hdfs/CHANGES.HDFS-1623.txt | 3 +++ .../namenode/ha/TestFailureOfSharedDir.java | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt index f84ed7b63f..eac0563d7f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt @@ -188,3 +188,6 @@ HDFS-2579. Starting delegation token manager during safemode fails. (todd) HDFS-2510. Add HA-related metrics. (atm) HDFS-2924. Standby checkpointing fails to authenticate in secure cluster. (todd) + +HDFS-2915. HA: TestFailureOfSharedDir.testFailureOfSharedDir() has race condition. (Bikas Saha via jitendra) + diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestFailureOfSharedDir.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestFailureOfSharedDir.java index 84d45c0591..71098d8aaa 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestFailureOfSharedDir.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestFailureOfSharedDir.java @@ -129,6 +129,8 @@ public void testFailureOfSharedDir() throws Exception { // The shared edits dir will automatically be marked required. MiniDFSCluster cluster = null; + int chmodSucceeded = -1; + File sharedEditsDir = null; try { cluster = new MiniDFSCluster.Builder(conf) .nnTopology(MiniDFSNNTopology.simpleHATopology()) @@ -143,9 +145,15 @@ public void testFailureOfSharedDir() throws Exception { assertTrue(fs.mkdirs(new Path("/test1"))); // Blow away the shared edits dir. - URI sharedEditsUri = cluster.getSharedEditsDir(0, 1); - FileUtil.fullyDelete(new File(sharedEditsUri)); - + URI sharedEditsUri = cluster.getSharedEditsDir(0, 1); + sharedEditsDir = new File(sharedEditsUri); + chmodSucceeded = FileUtil.chmod(sharedEditsDir.getAbsolutePath(), "-w", + true); + if (chmodSucceeded != 0) { + LOG.error("Failed to remove write permissions on shared edits dir:" + + sharedEditsDir.getAbsolutePath()); + } + NameNode nn0 = cluster.getNameNode(0); try { // Make sure that subsequent operations on the NN fail. @@ -171,6 +179,10 @@ public void testFailureOfSharedDir() throws Exception { NNStorage.getInProgressEditsFileName(1)); } } finally { + if (chmodSucceeded == 0) { + // without this test cleanup will fail + FileUtil.chmod(sharedEditsDir.getAbsolutePath(), "+w", true); + } if (cluster != null) { cluster.shutdown(); }