aayush2761 commented on code in PR #12053:
URL: https://github.com/apache/ozone/pull/12053#discussion_r4633348594
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueHandler.java:
##########
@@ -704,6 +709,101 @@ public void testDeleteRecoveringContainer() throws
IOException {
}
}
+ @Test
+ public void testFailedCloseKeepsRecoveringContainerTracked() throws
IOException {
+ HandlerWithVolumeSet handlerCtx = createKeyValueHandler(tempDir);
+ KeyValueHandler keyValueHandler = handlerCtx.getHandler();
+ ContainerSet containerSet = handlerCtx.getContainerSet();
+ try {
+ ContainerCommandRequestProto.Builder request =
createContainerRequest(DATANODE_UUID, DUMMY_CONTAINER_ID)
+ .toBuilder();
+ request.getCreateContainerBuilder().setState(State.RECOVERING);
+ assertThat(keyValueHandler.handleCreateContainer(request.build(),
null).getResult())
+ .isEqualTo(ContainerProtos.Result.SUCCESS);
+ KeyValueContainer container = (KeyValueContainer)
containerSet.getContainer(DUMMY_CONTAINER_ID);
+ assertThat(container).isNotNull();
+ assertThat(container.getContainerState()).isEqualTo(State.RECOVERING);
+
assertThat(containerSet.getRecoveringContainerMap()).containsKey(DUMMY_CONTAINER_ID);
+
+ KeyValueContainer containerSpy = spy(container);
+ doThrow(new StorageContainerException("Failed to update .container file",
+ ContainerProtos.Result.CONTAINER_FILES_CREATE_ERROR))
+ .doCallRealMethod()
+ .when(containerSpy).markContainerForClose();
+ StorageContainerException ex =
assertThrows(StorageContainerException.class,
+ () -> keyValueHandler.markContainerForClose(containerSpy));
+ assertEquals(ContainerProtos.Result.CONTAINER_FILES_CREATE_ERROR,
ex.getResult());
+ assertThat(container.getContainerState()).isEqualTo(State.RECOVERING);
Review Comment:
addressed, Thanks!
--
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]