You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/03/03 18:50:15 UTC

[GitHub] [flink] XComp commented on a change in pull request #18963: [FLINK-26450][fs] Adds error handling to FileStateHandle.discardState

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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org