Copilot commented on code in PR #25132:
URL: https://github.com/apache/pulsar/pull/25132#discussion_r2675121356
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelTest.java:
##########
@@ -731,6 +732,41 @@ public void handleMetadataSessionEventTest() throws
IllegalAccessException {
}
+
+ @Test
+ public void metadataStateMetricsTest() throws IllegalAccessException {
+ ServiceUnitStateChannelImpl channel1 = (ServiceUnitStateChannelImpl)
this.channel1;
+
+ long now = System.currentTimeMillis();
+ FieldUtils.writeDeclaredField(channel1, "lastMetadataSessionEvent",
SessionReestablished, true);
+ FieldUtils.writeDeclaredField(channel1,
"lastMetadataSessionEventTimestamp",
+ now - (MAX_CLEAN_UP_DELAY_TIME_IN_SECS * 1000) - 1, true);
+ assertEquals(0, getMetadataStateMetric(channel1.getMetrics()));
+
+ FieldUtils.writeDeclaredField(channel1, "lastMetadataSessionEvent",
SessionReestablished, true);
+ FieldUtils.writeDeclaredField(channel1,
"lastMetadataSessionEventTimestamp", now, true);
+ assertEquals(1, getMetadataStateMetric(channel1.getMetrics()));
+
+ FieldUtils.writeDeclaredField(channel1, "lastMetadataSessionEvent",
SessionLost, true);
+ FieldUtils.writeDeclaredField(channel1,
"lastMetadataSessionEventTimestamp", now, true);
+ assertEquals(2, getMetadataStateMetric(channel1.getMetrics()));
+ }
Review Comment:
The test only verifies the `brk_sunit_state_chn_metadata_state` metric but
does not test the other three new metrics introduced in this PR:
`brk_sunit_state_chn_last_metadata_session_event_is_reestablished`,
`brk_sunit_state_chn_last_metadata_session_event_timestamp_ms`, and
`brk_sunit_state_chn_last_metadata_session_event_age_seconds`. Consider adding
assertions to verify these metrics as well to ensure complete test coverage for
all newly introduced metrics.
--
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]