Gargi-jais11 commented on code in PR #9925:
URL: https://github.com/apache/ozone/pull/9925#discussion_r2944264301
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestHddsDispatcher.java:
##########
@@ -495,6 +496,50 @@ public void testWriteChunkWithCreateContainerFailure()
throws IOException {
}
}
+ @Test
+ public void testWriteChunkWithContainerAlreadyExistsDoesNotMarkUnhealthy()
+ throws IOException {
+ String testDirPath = testDir.getPath();
+ try {
+ UUID scmId = UUID.randomUUID();
+ OzoneConfiguration conf = new OzoneConfiguration();
+ conf.set(HDDS_DATANODE_DIR_KEY, testDirPath);
+ conf.set(OzoneConfigKeys.OZONE_METADATA_DIRS, testDirPath);
+ DatanodeDetails dd = randomDatanodeDetails();
+ HddsDispatcher hddsDispatcher = createDispatcher(dd, scmId, conf);
+ ContainerCommandRequestProto initialWriteChunkRequest =
+ getWriteChunkRequest(dd.getUuidString(), 1L, 1L);
+
+ ContainerCommandResponseProto initialResponse =
+ hddsDispatcher.dispatch(initialWriteChunkRequest, null);
+ assertEquals(ContainerProtos.Result.SUCCESS,
initialResponse.getResult());
+
+ ContainerCommandRequestProto writeChunkRequest =
+ getWriteChunkRequest(dd.getUuidString(), 1L, 2L);
+ HddsDispatcher mockDispatcher = spy(hddsDispatcher);
+ ContainerCommandResponseProto.Builder builder =
+ getContainerCommandResponse(writeChunkRequest,
+ ContainerProtos.Result.CONTAINER_ALREADY_EXISTS, "");
Review Comment:
using write chunk for the second time `handler.handle` for the main request
is never called. `canIgnoreException` is never reached.
The test should test the direct CreateContainer path:
1. Create a container (e.g., via WriteChunk).
2. Send a CreateContainer request for the same container ID.
3. Assert the container is not marked unhealthy.
```
@Test
public void testCreateContainerWhenAlreadyExistsDoesNotMarkUnhealthy()
throws IOException {
String testDirPath = testDir.getPath();
try {
UUID scmId = UUID.randomUUID();
OzoneConfiguration conf = new OzoneConfiguration();
conf.set(HDDS_DATANODE_DIR_KEY, testDirPath);
conf.set(OzoneConfigKeys.OZONE_METADATA_DIRS, testDirPath);
DatanodeDetails dd = randomDatanodeDetails();
HddsDispatcher hddsDispatcher = createDispatcher(dd, scmId, conf);
// Create container via WriteChunk
ContainerCommandRequestProto writeChunkRequest =
getWriteChunkRequest(dd.getUuidString(), 1L, 1L);
ContainerCommandResponseProto initialResponse =
hddsDispatcher.dispatch(writeChunkRequest, null);
assertEquals(ContainerProtos.Result.SUCCESS,
initialResponse.getResult());
// Send direct CreateContainer for existing container
ContainerCommandRequestProto createRequest =
ContainerCommandRequestProto.newBuilder()
.setCmdType(ContainerProtos.Type.CreateContainer)
.setContainerID(1L)
.setCreateContainer(ContainerProtos.CreateContainerRequestProto.newBuilder()
.setContainerType(ContainerProtos.ContainerType.KeyValueContainer)
.build())
.setDatanodeUuid(dd.getUuidString())
.build();
ContainerCommandResponseProto response =
hddsDispatcher.dispatch(createRequest, null);
assertEquals(ContainerProtos.Result.CONTAINER_ALREADY_EXISTS,
response.getResult());
Container container = hddsDispatcher.getContainer(1L);
assertNotNull(container);
assertTrue(container.getContainerData().isOpen());
assertFalse(container.getContainerData().isUnhealthy());
} finally {
ContainerMetrics.remove();
}
}
```
--
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]