Copilot commented on code in PR #11445:
URL: https://github.com/apache/ozone/pull/11445#discussion_r4220120537
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMMetricsSetters.java:
##########
@@ -55,4 +55,22 @@ public void testSetTotals() {
assertGauge("NumDirs", 4L, rb);
assertGauge("NumFiles", 5L, rb);
}
+
+ @Test
+ public void testSnapshotAndTenantCounts() {
+ metrics = OMMetrics.create(new OzoneConfiguration());
+ metrics.setNumSnapshotActive(5);
+ metrics.setNumSnapshotActive(3);
+ metrics.decNumSnapshotActive();
+ metrics.setNumSnapshotDeleted(1);
+ metrics.setNumSnapshotDeleted(4);
+ metrics.incNumTenants();
+ metrics.incNumTenants();
+ metrics.decNumTenants();
+
+ MetricsRecordBuilder rb = getMetrics("OMMetrics");
+ assertGauge("NumSnapshotActive", 2L, rb);
+ assertGauge("NumSnapshotDeleted", 4L, rb);
Review Comment:
`NumSnapshotDeleted` is described as a metric that “can go down”, but this
new test only exercises it increasing (1 -> 4). Consider adding a decrease case
(e.g., set to a lower value after setting higher) to ensure the gauge change
actually covers the previously broken behavior for deleted snapshots too.
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMMetricsSetters.java:
##########
@@ -55,4 +55,22 @@ public void testSetTotals() {
assertGauge("NumDirs", 4L, rb);
assertGauge("NumFiles", 5L, rb);
}
+
+ @Test
+ public void testSnapshotAndTenantCounts() {
+ metrics = OMMetrics.create(new OzoneConfiguration());
Review Comment:
Creating a new `OMMetrics` instance inside the test can register an
additional metrics source (depending on how `OMMetrics.create()` interacts with
the global metrics system), which may cause cross-test interference/flakiness
in the same JVM. Prefer reusing the test’s existing `metrics` instance created
in setup (if present), or explicitly unregister/shutdown the metrics system in
teardown before/after creating a new instance.
--
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]