hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [21/50] hadoop git commit: HDFS-10318. TestJMXGet hides the real error in case of test failure. Contributed by Andras Bokor.
Date Tue, 03 May 2016 22:06:08 GMT
HDFS-10318. TestJMXGet hides the real error in case of test failure. Contributed by Andras
Bokor.

(cherry picked from commit 10f0f7851a3255caab775777e8fb6c2781d97062)


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

Branch: refs/heads/branch-2.8
Commit: 973c73aa68b9339bcf69e49ab27e7a20ff2063be
Parents: e01242e
Author: Kihwal Lee <kihwal@apache.org>
Authored: Mon Apr 25 11:42:17 2016 -0500
Committer: Kihwal Lee <kihwal@apache.org>
Committed: Mon Apr 25 11:42:17 2016 -0500

----------------------------------------------------------------------
 .../java/org/apache/hadoop/tools/TestJMXGet.java    | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/973c73aa/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tools/TestJMXGet.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tools/TestJMXGet.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tools/TestJMXGet.java
index f64ee9d..36fdac4 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tools/TestJMXGet.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tools/TestJMXGet.java
@@ -31,6 +31,7 @@ import java.io.PrintStream;
 import java.lang.management.ManagementFactory;
 import java.util.Random;
 import java.util.Set;
+import java.util.concurrent.TimeoutException;
 
 import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
@@ -55,6 +56,7 @@ import org.junit.Test;
  * 
  */
 public class TestJMXGet {
+  public static final String WRONG_METRIC_VALUE_ERROR_MSG = "Unable to get the correct value
for %s.";
 
   private Configuration config;
   private MiniDFSCluster cluster;
@@ -118,9 +120,12 @@ public class TestJMXGet {
     assertTrue("error printAllValues", checkPrintAllValues(jmx));
 
     //get some data from different source
-    DFSTestUtil.waitForMetric(jmx, "NumLiveDataNodes", numDatanodes);
-    assertEquals(numDatanodes, Integer.parseInt(
+    try {
+      DFSTestUtil.waitForMetric(jmx, "NumLiveDataNodes", numDatanodes);
+    } catch (TimeoutException e) {
+    assertEquals(String.format(WRONG_METRIC_VALUE_ERROR_MSG, "NumLiveDataNodes"),numDatanodes,
Integer.parseInt(
         jmx.getValue("NumLiveDataNodes")));
+    }
     assertGauge("CorruptBlocks", Long.parseLong(jmx.getValue("CorruptBlocks")),
                 getMetrics("FSNamesystem"));
 
@@ -169,8 +174,11 @@ public class TestJMXGet {
     String serviceName = "DataNode";
     jmx.setService(serviceName);
     jmx.init();
-    DFSTestUtil.waitForMetric(jmx, "BytesWritten", fileSize);
-    assertEquals(fileSize, Integer.parseInt(jmx.getValue("BytesWritten")));
+    try {
+      DFSTestUtil.waitForMetric(jmx, "BytesWritten", fileSize);
+    } catch (TimeoutException e) {
+      assertEquals(String.format(WRONG_METRIC_VALUE_ERROR_MSG, "BytesWritten"), fileSize,
Integer.parseInt(jmx.getValue("BytesWritten")));
+    }
 
     cluster.shutdown();
     MBeanServerConnection mbsc = ManagementFactory.getPlatformMBeanServer();


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