Repository: hadoop
Updated Branches:
  refs/heads/trunk 6502d59e7 -> 621cbb4f6


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


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/621cbb4f
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/621cbb4f
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/621cbb4f

Branch: refs/heads/trunk
Commit: 621cbb4f69072bde259f213629f84494416ae12f
Parents: 6502d59
Author: Walter Su <waltersu4...@apache.org>
Authored: Tue Nov 17 10:51:29 2015 +0800
Committer: Walter Su <waltersu4...@apache.org>
Committed: Tue Nov 17 10:51:29 2015 +0800

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt     |  3 +++
 .../server/blockmanagement/TestNodeCount.java   | 24 ++++++++++++--------
 2 files changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/621cbb4f/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt 
b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index d76253a..d909d46 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -2311,6 +2311,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

http://git-wip-us.apache.org/repos/asf/hadoop/blob/621cbb4f/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestNodeCount.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestNodeCount.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestNodeCount.java
index c33667d..83d7305 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestNodeCount.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestNodeCount.java
@@ -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 */

Reply via email to