smengcl commented on code in PR #12053:
URL: https://github.com/apache/ozone/pull/12053#discussion_r4633973355
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueHandler.java:
##########
@@ -704,6 +710,99 @@ 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);
+
+ File metadataDir = new
File(container.getContainerData().getMetadataPath());
+ assumeThat(metadataDir.setWritable(false)).isTrue();
+ File writeProbe = new File(metadataDir, "write-probe");
+ try {
+ assumeThat(writeProbe.createNewFile()).isFalse();
Review Comment:
`File.createNewFile()` throws `IOException: Permission denied` in a
directory that is not writable, it does not return false. So on any non-root
run both new tests stop here with an error, before `markContainerForClose` is
called, with or without the fix.
Could we drop the probe and use
`assumeThat(Files.isWritable(metadataDir.toPath())).isFalse()` instead? It
still skips when running as root.
--
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]