mjsax commented on code in PR #16373: URL: https://github.com/apache/kafka/pull/16373#discussion_r1685169625
########## clients/src/test/java/org/apache/kafka/clients/consumer/internals/HeartbeatRequestManagerTest.java: ########## @@ -153,6 +154,35 @@ public void cleanup() { } } + @Test + public void testHeartBeatRequestStateToStringBase() { + long retryBackoffMs = 100; + long retryBackoffMaxMs = 1000; + LogContext logContext = new LogContext(); + HeartbeatRequestState heartbeatRequestState = new HeartbeatRequestState( + logContext, + time, + DEFAULT_HEARTBEAT_INTERVAL_MS, + retryBackoffMs, + retryBackoffMaxMs, + .2 + ); + + RequestState requestState = new RequestState( + logContext, + HeartbeatRequestManager.HeartbeatRequestState.class.getName(), + retryBackoffMs, + retryBackoffMaxMs + ); + + String target = requestState.toStringBase() + + ", remainingMs=" + heartbeatRequestState.heartbeatTimer().remainingMs() + Review Comment: We should not call `heartbeatRequestState.heartbeatTimer().remainingMs()` here -- it defeats the purpose of the test. Assume we except `remainingMs:500` but there is a bug -- this call will compute the incorrect `target` and we would compare it to itself. We should just put down the expected target hard-coded (or compute is some different way if we need some flexibility) For `DEFAULT_HEARTBEAT_INTERVAL_MS` is fine as this is a `final` variable. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org