hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cnaur...@apache.org
Subject svn commit: r1502120 - /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/MetricsAsserts.java
Date Thu, 11 Jul 2013 05:35:29 GMT
Author: cnauroth
Date: Thu Jul 11 05:35:29 2013
New Revision: 1502120

URL: http://svn.apache.org/r1502120
Log:
HDFS-4372. Track NameNode startup progress. Contributed by Chris Nauroth.

Modified:
    hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/MetricsAsserts.java

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/MetricsAsserts.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/MetricsAsserts.java?rev=1502120&r1=1502119&r2=1502120&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/MetricsAsserts.java
(original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/MetricsAsserts.java
Thu Jul 11 05:35:29 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