ZanderXu commented on code in PR #5058:
URL: https://github.com/apache/hadoop/pull/5058#discussion_r1012451085


##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##########
@@ -290,6 +290,26 @@ private static void snapshotMutableRatesWithAggregation(
     }
   }
 
+  /**
+   * MutableStat should output 0 instead of the previous state when there is 
no change

Review Comment:
   Should end with `.`



##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##########
@@ -290,6 +290,26 @@ private static void snapshotMutableRatesWithAggregation(
     }
   }
 
+  /**
+   * MutableStat should output 0 instead of the previous state when there is 
no change
+   */
+  @Test public void testMutableWithoutChanged() {
+    MetricsRecordBuilder builderWithChange = mockMetricsRecordBuilder();
+    MetricsRecordBuilder builderWithoutChange = mockMetricsRecordBuilder();
+    MetricsRegistry registry = new MetricsRegistry("test");
+    MutableStat stat = registry.newStat("Test", "Test", "Ops", "Val", false);
+
+    stat.add(1000, 1000);
+    stat.add(1000, 2000);
+    registry.snapshot(builderWithChange, true);
+
+    assertCounter("TestNumOps", 2000L, builderWithChange);
+    assertGauge("TestAvgVal", 1.5, builderWithChange);
+
+    registry.snapshot(builderWithoutChange, true);
+    assertGauge("TestAvgVal", 0.0, builderWithoutChange);

Review Comment:
   Here too. Can add one UT to verify the `INumOps`?



##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##########
@@ -290,6 +290,26 @@ private static void snapshotMutableRatesWithAggregation(
     }
   }
 
+  /**
+   * MutableStat should output 0 instead of the previous state when there is 
no change
+   */
+  @Test public void testMutableWithoutChanged() {
+    MetricsRecordBuilder builderWithChange = mockMetricsRecordBuilder();
+    MetricsRecordBuilder builderWithoutChange = mockMetricsRecordBuilder();
+    MetricsRegistry registry = new MetricsRegistry("test");
+    MutableStat stat = registry.newStat("Test", "Test", "Ops", "Val", false);
+
+    stat.add(1000, 1000);
+    stat.add(1000, 2000);
+    registry.snapshot(builderWithChange, true);
+
+    assertCounter("TestNumOps", 2000L, builderWithChange);

Review Comment:
   Can add one UT to verify the `INumOps`?



##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java:
##########
@@ -290,6 +290,26 @@ private static void snapshotMutableRatesWithAggregation(
     }
   }
 
+  /**
+   * MutableStat should output 0 instead of the previous state when there is 
no change
+   */
+  @Test public void testMutableWithoutChanged() {
+    MetricsRecordBuilder builderWithChange = mockMetricsRecordBuilder();
+    MetricsRecordBuilder builderWithoutChange = mockMetricsRecordBuilder();
+    MetricsRegistry registry = new MetricsRegistry("test");
+    MutableStat stat = registry.newStat("Test", "Test", "Ops", "Val", false);
+

Review Comment:
   Can remove this empty line.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to