hani-fouladgar commented on code in PR #11423:
URL: https://github.com/apache/ozone/pull/11423#discussion_r4382894172
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/states/endpoint/TestHeartbeatEndpointTask.java:
##########
@@ -396,6 +402,88 @@ public void testheartbeatWithAllReports() throws Exception
{
}
}
+ @Test
+ public void testHeartbeatCapsReportsAndSchedulesFollowup() throws Exception {
+ OzoneConfiguration conf = new OzoneConfiguration();
+ conf.setInt(HDDS_CONTAINER_REPORT_MAX_LIMIT, 2);
+ DatanodeStateMachine datanodeStateMachine = mockDatanodeStateMachine();
+ StateContext context = new StateContext(conf, DatanodeStates.RUNNING,
+ datanodeStateMachine, "");
+
+ when(datanodeStateMachine.getQueuedCommandCount())
+ .thenReturn(new EnumCounters<>(SCMCommandProto.Type.class));
+
+ StorageContainerDatanodeProtocolClientSideTranslatorPB scm =
+ mock(StorageContainerDatanodeProtocolClientSideTranslatorPB.class);
+ ArgumentCaptor<SCMHeartbeatRequestProto> argument = ArgumentCaptor
+ .forClass(SCMHeartbeatRequestProto.class);
+ when(scm.sendHeartbeat(argument.capture()))
+ .thenAnswer(invocation ->
+ SCMHeartbeatResponseProto.newBuilder()
+ .setDatanodeUUID(
+ ((SCMHeartbeatRequestProto) invocation.getArgument(0))
+ .getDatanodeDetails().getUuid())
+ .build());
+
+ HeartbeatEndpointTask endpointTask = getHeartbeatEndpointTask(
+ conf, context, scm);
+ context.addEndpoint(TEST_SCM_ENDPOINT);
+ // Queue more ICRs than the per-heartbeat limit.
+ for (int i = 0; i < 5; i++) {
+ context.addIncrementalReport(
+ IncrementalContainerReportProto.getDefaultInstance());
+ }
+
+ endpointTask.call();
+
+ // Only the capped number of ICRs is sent in this heartbeat.
+ SCMHeartbeatRequestProto heartbeat = argument.getValue();
+ assertEquals(2, heartbeat.getIncrementalContainerReportCount());
+ // The remainder stays queued and a follow-up heartbeat is scheduled now.
+ assertTrue(context.hasPendingReports(TEST_SCM_ENDPOINT));
+ verify(datanodeStateMachine).setNextHB(anyLong());
Review Comment:
Added the negative case.
--
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]