HDFS-9358. TestNodeCount#testNodeCount timed out. Contributed by Masatake Iwasaki.

(cherry picked from commit 621cbb4f69)
This commit is contained in:
Walter Su 2015-11-17 10:51:29 +08:00
parent f562c155d2
commit bff9d08a43
2 changed files with 18 additions and 9 deletions

View File

@ -1459,6 +1459,9 @@ Release 2.8.0 - UNRELEASED
HDFS-9421. NNThroughputBenchmark replication test NPE with -namenode option.
(Mingliang Liu via xyao)
HDFS-9358. TestNodeCount#testNodeCount timed out.
(Masatake Iwasaki via waltersu4549)
Release 2.7.3 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -25,6 +25,7 @@ import java.util.concurrent.TimeoutException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.DFSTestUtil;
import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.hdfs.MiniDFSCluster;
@ -38,9 +39,6 @@ import org.junit.Test;
/**
* Test if live nodes count per node is correct
* so NN makes right decision for under/over-replicated blocks
*
* Two of the "while" loops below use "busy wait"
* because they are detecting transient states.
*/
public class TestNodeCount {
final short REPLICATION_FACTOR = (short)2;
@ -50,10 +48,19 @@ public class TestNodeCount {
Block lastBlock = null;
NumberReplicas lastNum = null;
@Test
@Test(timeout = 60000)
public void testNodeCount() throws Exception {
// start a mini dfs cluster of 2 nodes
final Configuration conf = new HdfsConfiguration();
// avoid invalidation by startup delay in order to make test non-transient
conf.setInt(DFSConfigKeys.DFS_NAMENODE_STARTUP_DELAY_BLOCK_DELETION_SEC_KEY,
60);
// reduce intervals to make test execution time shorter
conf.setInt(DFSConfigKeys.DFS_NAMENODE_REPLICATION_INTERVAL_KEY, 1);
conf.setInt(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, 1);
// start a mini dfs cluster of 2 nodes
final MiniDFSCluster cluster =
new MiniDFSCluster.Builder(conf).numDataNodes(REPLICATION_FACTOR).build();
try {
@ -90,7 +97,7 @@ public class TestNodeCount {
cluster.restartDataNode(dnprop);
cluster.waitActive();
// check if excessive replica is detected (transient)
// check if excessive replica is detected
initializeTimeout(TIMEOUT);
while (countNodes(block.getLocalBlock(), namesystem).excessReplicas() == 0) {
checkTimeout("excess replicas not detected");
@ -124,7 +131,7 @@ public class TestNodeCount {
cluster.restartDataNode(dnprop);
cluster.waitActive();
// check if excessive replica is detected (transient)
// check if excessive replica is detected
initializeTimeout(TIMEOUT);
while (countNodes(block.getLocalBlock(), namesystem).excessReplicas() != 2) {
checkTimeout("excess replica count not equal to 2");
@ -141,9 +148,8 @@ public class TestNodeCount {
+ ((timeout <= 0) ? Long.MAX_VALUE : timeout);
}
/* busy wait on transient conditions */
void checkTimeout(String testLabel) throws TimeoutException {
checkTimeout(testLabel, 0);
checkTimeout(testLabel, 10);
}
/* check for timeout, then wait for cycleTime msec */