tillrohrmann commented on a change in pull request #18191: URL: https://github.com/apache/flink/pull/18191#discussion_r785895143
########## 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) Review comment: I think this problem has been solved with 63201b3abe1c4c55383ca34130c6c49483c683ed. -- 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-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org