XComp commented on code in PR #22341:
URL: https://github.com/apache/flink/pull/22341#discussion_r1288764461
##########
flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/FileSystemJobResultStoreFileOperationsTest.java:
##########
@@ -116,46 +123,80 @@ public void
testBaseDirectoryCreationOnResultStoreInitialization() throws Except
assertThat(emptyBaseDirectory).doesNotExist();
fileSystemJobResultStore =
- new FileSystemJobResultStore(basePath.getFileSystem(),
basePath, false);
+ new FileSystemJobResultStore(
+ basePath.getFileSystem(), basePath, false,
manuallyTriggeredExecutor);
// Result store operations are creating the base directory on-the-fly
assertThat(emptyBaseDirectory).doesNotExist();
- fileSystemJobResultStore.createDirtyResult(DUMMY_JOB_RESULT_ENTRY);
+ CompletableFuture<Void> dirtyResultAsync =
+
fileSystemJobResultStore.createDirtyResultAsync(DUMMY_JOB_RESULT_ENTRY);
+ assertThat(emptyBaseDirectory).doesNotExist();
+ manuallyTriggeredExecutor.triggerAll();
+
FlinkAssertions.assertThatFuture(dirtyResultAsync).eventuallySucceeds();
assertThat(emptyBaseDirectory).exists().isDirectory();
}
@Test
public void testStoreDirtyJobResultCreatesFile() throws Exception {
- fileSystemJobResultStore.createDirtyResult(DUMMY_JOB_RESULT_ENTRY);
+ CompletableFuture<Void> dirtyResultAsync =
+
fileSystemJobResultStore.createDirtyResultAsync(DUMMY_JOB_RESULT_ENTRY);
+ assertThat(expectedDirtyFile(DUMMY_JOB_RESULT_ENTRY)).doesNotExist();
+ manuallyTriggeredExecutor.triggerAll();
+
FlinkAssertions.assertThatFuture(dirtyResultAsync).eventuallySucceeds();
assertThat(getCleanResultIdsFromFileSystem()).isEmpty();
assertThat(expectedDirtyFile(DUMMY_JOB_RESULT_ENTRY)).exists().isFile().isNotEmpty();
}
@Test
public void testStoreCleanJobResultCreatesFile() throws Exception {
- fileSystemJobResultStore.createDirtyResult(DUMMY_JOB_RESULT_ENTRY);
-
fileSystemJobResultStore.markResultAsClean(DUMMY_JOB_RESULT_ENTRY.getJobId());
+ CompletableFuture<Void> dirtyResultAsync =
+
fileSystemJobResultStore.createDirtyResultAsync(DUMMY_JOB_RESULT_ENTRY);
+ manuallyTriggeredExecutor.triggerAll();
+
FlinkAssertions.assertThatFuture(dirtyResultAsync).eventuallySucceeds();
+ CompletableFuture<Void> markCleanAsync =
+
fileSystemJobResultStore.markResultAsCleanAsync(DUMMY_JOB_RESULT_ENTRY.getJobId());
+ assertThat(getCleanResultIdsFromFileSystem())
+ .doesNotContain(DUMMY_JOB_RESULT_ENTRY.getJobId());
+ manuallyTriggeredExecutor.triggerAll();
+ FlinkAssertions.assertThatFuture(markCleanAsync).eventuallySucceeds();
assertThat(getCleanResultIdsFromFileSystem())
.containsExactlyInAnyOrder(DUMMY_JOB_RESULT_ENTRY.getJobId());
}
@Test
- public void testStoreCleanJobResultDeletesDirtyFile() throws Exception {
- fileSystemJobResultStore.createDirtyResult(DUMMY_JOB_RESULT_ENTRY);
+ public void testStoreCleanJobResultDeletesDirtyFile() {
+ CompletableFuture<Void> dirtyResultAsync =
+
fileSystemJobResultStore.createDirtyResultAsync(DUMMY_JOB_RESULT_ENTRY);
+ assertThat(expectedDirtyFile(DUMMY_JOB_RESULT_ENTRY)).doesNotExist();
+ manuallyTriggeredExecutor.triggerAll();
+
FlinkAssertions.assertThatFuture(dirtyResultAsync).eventuallySucceeds();
assertThat(expectedDirtyFile(DUMMY_JOB_RESULT_ENTRY)).exists().isFile().isNotEmpty();
-
fileSystemJobResultStore.markResultAsClean(DUMMY_JOB_RESULT_ENTRY.getJobId());
+ CompletableFuture<Void> markResultAsCleanAsync =
+
fileSystemJobResultStore.markResultAsCleanAsync(DUMMY_JOB_RESULT_ENTRY.getJobId());
+ manuallyTriggeredExecutor.triggerAll();
+
FlinkAssertions.assertThatFuture(markResultAsCleanAsync).eventuallySucceeds();
assertThat(expectedDirtyFile(DUMMY_JOB_RESULT_ENTRY)).doesNotExist();
}
@Test
public void testCleanDirtyJobResultTwiceIsIdempotent() throws IOException {
- fileSystemJobResultStore.createDirtyResult(DUMMY_JOB_RESULT_ENTRY);
-
fileSystemJobResultStore.markResultAsClean(DUMMY_JOB_RESULT_ENTRY.getJobId());
-
+ CompletableFuture<Void> dirtyResultAsync =
+
fileSystemJobResultStore.createDirtyResultAsync(DUMMY_JOB_RESULT_ENTRY);
+ manuallyTriggeredExecutor.triggerAll();
+
FlinkAssertions.assertThatFuture(dirtyResultAsync).eventuallySucceeds();
+ CompletableFuture<Void> cleanResultAsync =
+
fileSystemJobResultStore.markResultAsCleanAsync(DUMMY_JOB_RESULT_ENTRY.getJobId());
+ manuallyTriggeredExecutor.triggerAll();
+
FlinkAssertions.assertThatFuture(cleanResultAsync).eventuallySucceeds();
final byte[] cleanFileData =
FileUtils.readAllBytes(expectedCleanFile(DUMMY_JOB_RESULT_ENTRY).toPath());
-
fileSystemJobResultStore.markResultAsClean(DUMMY_JOB_RESULT_ENTRY.getJobId());
+ CompletableFuture<Void> markResultAsCleanAsync =
+
fileSystemJobResultStore.markResultAsCleanAsync(DUMMY_JOB_RESULT_ENTRY.getJobId());
+ assertThat(expectedCleanFile(DUMMY_JOB_RESULT_ENTRY))
+ .doesNotHaveSameHashCodeAs(cleanFileData);
Review Comment:
I don't get this assert? Why do we check this here? Essentially, what we
want to check is that the modification date of the file is the same after each
`markResultAsCleanAsync` call. :thinking:
--
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]