HDFS-11252. TestFileTruncate#testTruncateWithDataNodesRestartImmediately can fail with BindException. Contributed by Yiqun Lin.

(cherry picked from commit 0ddb8defad)
This commit is contained in:
Brahma Reddy Battula 2016-12-28 10:34:33 +05:30
parent 9a976f3859
commit 218ed0a96b
1 changed files with 15 additions and 16 deletions

View File

@ -680,13 +680,7 @@ public class TestFileTruncate {
int toTruncateLength = 1; int toTruncateLength = 1;
int newLength = startingFileSize - toTruncateLength; int newLength = startingFileSize - toTruncateLength;
cluster.getDataNodes().get(dn).shutdown(); cluster.getDataNodes().get(dn).shutdown();
try { truncateAndRestartDN(p, dn, newLength);
boolean isReady = fs.truncate(p, newLength);
assertFalse(isReady);
} finally {
cluster.restartDataNode(dn, true, true);
cluster.waitActive();
}
checkBlockRecovery(p); checkBlockRecovery(p);
LocatedBlock newBlock = getLocatedBlocks(p).getLastLocatedBlock(); LocatedBlock newBlock = getLocatedBlocks(p).getLastLocatedBlock();
@ -739,13 +733,7 @@ public class TestFileTruncate {
int toTruncateLength = 1; int toTruncateLength = 1;
int newLength = startingFileSize - toTruncateLength; int newLength = startingFileSize - toTruncateLength;
cluster.getDataNodes().get(dn).shutdown(); cluster.getDataNodes().get(dn).shutdown();
try { truncateAndRestartDN(p, dn, newLength);
boolean isReady = fs.truncate(p, newLength);
assertFalse(isReady);
} finally {
cluster.restartDataNode(dn, true, true);
cluster.waitActive();
}
checkBlockRecovery(p); checkBlockRecovery(p);
LocatedBlock newBlock = getLocatedBlocks(p).getLastLocatedBlock(); LocatedBlock newBlock = getLocatedBlocks(p).getLastLocatedBlock();
@ -799,8 +787,8 @@ public class TestFileTruncate {
boolean isReady = fs.truncate(p, newLength); boolean isReady = fs.truncate(p, newLength);
assertFalse(isReady); assertFalse(isReady);
cluster.restartDataNode(dn0, true, true); cluster.restartDataNode(dn0, false, true);
cluster.restartDataNode(dn1, true, true); cluster.restartDataNode(dn1, false, true);
cluster.waitActive(); cluster.waitActive();
checkBlockRecovery(p); checkBlockRecovery(p);
@ -1240,4 +1228,15 @@ public class TestFileTruncate {
.build(); .build();
fs = cluster.getFileSystem(); fs = cluster.getFileSystem();
} }
private void truncateAndRestartDN(Path p, int dn, int newLength)
throws IOException {
try {
boolean isReady = fs.truncate(p, newLength);
assertFalse(isReady);
} finally {
cluster.restartDataNode(dn, false, true);
cluster.waitActive();
}
}
} }