Copilot commented on code in PR #10985:
URL: https://github.com/apache/ozone/pull/10985#discussion_r3751691335
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/ratis/TestOzoneManagerRatisServer.java:
##########
@@ -145,6 +163,97 @@ public void testStartOMRatisServer() throws Exception {
"Ratis Server should be in running state");
}
+ /**
+ * HDDS-13621: a failed Raft reply in RetryCache must not be converted via
+ * getOMResponse (no response message), so checkRetryCache returns null.
+ */
+ @Test
+ public void checkRetryCacheReturnsNullWhenCachedReplyFailed() throws
Exception {
+ when(ozoneManager.isTestSecureOmFlag()).thenReturn(true);
+ ClientId ratisClientId = ClientId.randomId();
+ int callId = 42;
+ RaftGroupMemberId memberId = RaftGroupMemberId.valueOf(
+ omRatisServer.getRaftPeerId(),
omRatisServer.getRaftGroup().getGroupId());
+ RaftClientReply failedReply = RaftClientReply.newBuilder()
+ .setClientId(ratisClientId)
+ .setServerId(memberId)
+ .setGroupId(omRatisServer.getRaftGroup().getGroupId())
+ .setCallId(callId)
+ .setSuccess(false)
+ .setMessage(Message.EMPTY)
+ .setException(new NotLeaderException(memberId, null,
Collections.emptyList()))
+ .build();
+
+ OzoneManagerRatisServer spyServer = spy(omRatisServer);
+ injectRetryCacheEntry(spyServer, ratisClientId, callId, failedReply);
+
+ Server.Call previousCall = Server.getCurCall().get();
+ try {
+ Server.getCurCall().set(new Server.Call(callId, 0, null, null,
+ RPC.RpcKind.RPC_BUILTIN,
ratisClientId.toByteString().toByteArray()));
+ assertNull(spyServer.checkRetryCache());
+ } finally {
+ Server.getCurCall().set(previousCall);
+ }
Review Comment:
checkRetryCache() derives the RetryCache key from Hadoop IPC clientId bytes
(UUID.nameUUIDFromBytes(Server.getClientId())) rather than using a Ratis
ClientId’s protobuf bytes directly. In this test, Server.Call is populated with
ratisClientId.toByteString(), which doesn’t match the production mapping
and—combined with the broad RetryCache stubbing—can let the test pass even if
the lookup key computation regresses. Consider deriving the ClientId from the
same clientIdBytes you put into Server.Call, and verify the expected
ClientInvocationId is used for the cache lookup.
This issue also appears in the following locations of the same file:
- line 207
- line 225
- line 242
--
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]