hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject [02/50] [abbrv] hadoop git commit: HDFS-10668. Fix intermittently failing UT TestDataNodeMXBean#testDataNodeMXBeanBlockCount. Contributed by Mingliang Liu.
Date Mon, 01 Aug 2016 15:54:53 GMT
HDFS-10668. Fix intermittently failing UT TestDataNodeMXBean#testDataNodeMXBeanBlockCount.
Contributed by Mingliang Liu.


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

Branch: refs/heads/HADOOP-12756
Commit: 7cac7655fd84ac394250705b31e3927fe548e34a
Parents: 85a2050
Author: Brahma Reddy Battula <brahma@apache.org>
Authored: Tue Jul 26 10:54:24 2016 +0530
Committer: Brahma Reddy Battula <brahma@apache.org>
Committed: Tue Jul 26 10:54:24 2016 +0530

----------------------------------------------------------------------
 .../server/datanode/TestDataNodeMXBean.java     | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/7cac7655/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java
index 2a3ed3b..e7b2c7c 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java
@@ -25,11 +25,13 @@ import java.util.Map;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
+import com.google.common.base.Supplier;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hdfs.DFSTestUtil;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.apache.hadoop.test.GenericTestUtils;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mortbay.util.ajax.JSON;
@@ -119,10 +121,18 @@ public class TestDataNodeMXBean {
       cluster.waitActive();
       assertEquals("After restart DN", 5, getTotalNumBlocks(mbs, mxbeanName));
       fs.delete(new Path("/tmp.txt1"), true);
-      // Wait till replica gets deleted on disk.
-      Thread.sleep(5000);
-      assertEquals("After delete one file", 4,
-              getTotalNumBlocks(mbs, mxbeanName));
+      // The total numBlocks should be updated after one file is deleted
+      GenericTestUtils.waitFor(new Supplier<Boolean>() {
+        @Override
+        public Boolean get() {
+          try {
+            return getTotalNumBlocks(mbs, mxbeanName) == 4;
+          } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+          }
+        }
+      }, 100, 30000);
     } finally {
       if (cluster != null) {
         cluster.shutdown();
@@ -131,7 +141,7 @@ public class TestDataNodeMXBean {
   }
 
   @SuppressWarnings("unchecked")
-  int getTotalNumBlocks(MBeanServer mbs, ObjectName mxbeanName)
+  private int getTotalNumBlocks(MBeanServer mbs, ObjectName mxbeanName)
           throws Exception {
     int totalBlocks = 0;
     String volumeInfo = (String) mbs.getAttribute(mxbeanName, "VolumeInfo");


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message