hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cnaur...@apache.org
Subject svn commit: r1502422 - /hadoop/common/branches/branch-2.1.0-beta/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/MetricsAsserts.java
Date Fri, 12 Jul 2013 04:46:53 GMT
Author: cnauroth
Date: Fri Jul 12 04:46:52 2013
New Revision: 1502422

URL: http://svn.apache.org/r1502422
Log:
HDFS-4372. Merging change r1502420 from branch-2.1-beta to branch-2.1.0-beta.

Modified:
    hadoop/common/branches/branch-2.1.0-beta/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/MetricsAsserts.java

Modified: hadoop/common/branches/branch-2.1.0-beta/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/MetricsAsserts.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1.0-beta/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/MetricsAsserts.java?rev=1502422&r1=1502421&r2=1502422&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1.0-beta/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/MetricsAsserts.java
(original)
+++ hadoop/common/branches/branch-2.1.0-beta/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/MetricsAsserts.java
Fri Jul 12 04:46:52 2013
@@ -236,6 +236,25 @@ public class MetricsAsserts {
     return captor.getValue();
   }
 
+   /**
+   * Assert a float gauge metric as expected
+   * @param name  of the metric
+   * @param expected  value of the metric
+   * @param rb  the record builder mock used to getMetrics
+   */
+  public static void assertGauge(String name, float expected,
+                                 MetricsRecordBuilder rb) {
+    Assert.assertEquals("Bad value for metric " + name,
+        expected, getFloatGauge(name, rb), EPSILON);
+  }
+
+  public static float getFloatGauge(String name, MetricsRecordBuilder rb) {
+    ArgumentCaptor<Float> captor = ArgumentCaptor.forClass(Float.class);
+    verify(rb, atLeast(0)).addGauge(eqName(info(name, "")), captor.capture());
+    checkCaptured(captor, name);
+    return captor.getValue();
+  }
+
   /**
    * Check that this metric was captured exactly once.
    */



Mime
View raw message