slfan1989 opened a new pull request, #1621:
URL: https://github.com/apache/ratis/pull/1621

   ## What changes were proposed in this pull request?
   
   Fix a spurious failure in `testFollowerHeartbeatMetric` after a leader steps 
down.
   
   A former leader's registry object may retain heartbeat gauges after being 
unregistered. 
   
   The test previously read that object directly and incorrectly expected its 
heartbeat gauges to be empty.
   
   This patch checks currently registered follower metrics through 
`MetricRegistries.global()`. 
   
   It also moves cluster shutdown into a `finally` block and removes a 
redundant catch-and-rethrow block.
   
   Original failing CI job:
   https://github.com/slfan1989/ratis/actions/runs/36845521674/job/110314605697
   
   ```
   Failing test:
   TestLogAppenderWithNetty.testFollowerHeartbeatMetric
   
   Error:
   org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
       at 
org.apache.ratis.LogAppenderTests.testFollowerHeartbeatMetric(LogAppenderTests.java:167)
   
   Relevant events:
   09:58:27.425 — s2 became leader at term 1.
   09:58:28.027 — s2 stepped down due to LOST_MAJORITY_HEARTBEATS.
   09:58:28.370 — s1 became leader at term 2.
   
   The test expected a follower's heartbeat gauges to be empty. However,
   the former leader s2 retained those gauges in its unregistered registry
   object, causing the assertion to fail.
   ```
   
   ## What is the link to the Apache JIRA
   
   RATIS-2726. testFollowerHeartbeatMetric may fail after a leader steps down.
   
   ## How was this patch tested?
   
   https://github.com/slfan1989/ratis/actions/runs/36941357166
   


-- 
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]

Reply via email to