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
This commit is contained in:
Jitendra Nath Pandey 2012-02-09 21:08:17 +00:00
parent 1b4c990b61
commit b5d02a63cb
2 changed files with 18 additions and 3 deletions

View File

@ -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)

View File

@ -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())
@ -144,7 +146,13 @@ public void testFailureOfSharedDir() throws Exception {
// Blow away the shared edits dir.
URI sharedEditsUri = cluster.getSharedEditsDir(0, 1);
FileUtil.fullyDelete(new File(sharedEditsUri));
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 {
@ -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();
}