XComp commented on a change in pull request #18963:
URL: https://github.com/apache/flink/pull/18963#discussion_r818967894
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/state/filesystem/FileStateHandleTest.java
##########
@@ -57,27 +59,97 @@ public void testDisposeDeletesFile() throws Exception {
*/
@Test
public void testDisposeDoesNotDeleteParentDirectory() throws Exception {
- File parentDir = tempFolder.newFolder();
- assertTrue(parentDir.exists());
+ final Path p = new Path(TEST_SCHEME + "://path/with/parent");
+ final List<Path> pathsToDelete = new ArrayList<>();
- File file = new File(parentDir, "test");
- writeTestData(file);
- assertTrue(file.exists());
+ initializeFileSystem(
+ (path, ignoredRecursionMarker) -> {
+ pathsToDelete.add(path);
+ return true;
+ });
- FileStateHandle handle = new FileStateHandle(Path.fromLocalFile(file),
file.length());
+ final FileStateHandle handle = new FileStateHandle(p, 42);
handle.discardState();
- assertFalse(file.exists());
- assertTrue(parentDir.exists());
+ assertThat(pathsToDelete)
+ .as(
+ "Only one delete call should have happened on the
actual path but not the parent.")
+ .singleElement()
+ .isEqualTo(p);
Review comment:
I agree. But the older version didn't enable us to simulate errors. So,
I sticked to it for consistency reasons.
--
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]