tillrohrmann commented on a change in pull request #18191:
URL: https://github.com/apache/flink/pull/18191#discussion_r785895656
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobUtilsTest.java
##########
@@ -71,4 +77,44 @@ public void testTaskManagerFallbackBlobStorageDirectory1()
throws IOException {
public void testBlobUtilsFailIfNoStorageDirectoryIsSpecified() throws
IOException {
BlobUtils.createBlobStorageDirectory(new Configuration(), null);
}
+
+ @Test
+ public void testCheckAndDeleteCorruptedBlobsDeletesCorruptedBlobs() throws
IOException {
+ final File storageDir = temporaryFolder.newFolder();
+
+ final BlobKey corruptedBlobKey =
BlobKey.createKey(BlobKey.BlobType.PERMANENT_BLOB);
+ final byte[] corruptedContent =
"corrupted".getBytes(StandardCharsets.UTF_8);
+
+ final byte[] validContent = "valid".getBytes(StandardCharsets.UTF_8);
+ final byte[] validKey =
BlobUtils.createMessageDigest().digest(validContent);
+ final BlobKey validPermanentBlobKey =
+ BlobKey.createKey(BlobKey.BlobType.PERMANENT_BLOB, validKey);
+ final BlobKey validTransientBlobKey =
+ BlobKey.createKey(BlobKey.BlobType.TRANSIENT_BLOB, validKey);
+
+ writeBlob(storageDir, corruptedBlobKey, corruptedContent);
+ writeBlob(storageDir, validPermanentBlobKey, validContent);
+ writeBlob(storageDir, validTransientBlobKey, validContent);
+
+ BlobUtils.checkAndDeleteCorruptedBlobs(storageDir.toPath(), log);
+
+ assertThat(
+ BlobUtils.listBlobsInDirectory(storageDir.toPath()).stream()
+ .map(BlobUtils.Blob::getBlobKey)
+ .collect(Collectors.toList()),
+ containsInAnyOrder(validPermanentBlobKey,
validTransientBlobKey));
+ }
+
+ private void writeBlob(File storageDir, BlobKey corruptedBlobKey, byte[]
fileContent)
+ throws IOException {
+ final File corruptedFile = new File(storageDir, "corrupted");
+ Files.write(corruptedFile.toPath(), fileContent);
Review comment:
I think this problem has been solved with 63201b3.
--
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]