Skip to content

Commit

Permalink
[FLINK-13483] Retry delete when checking path existence in AbstractHa…
Browse files Browse the repository at this point in the history
…doopFileSystemITTest

This closes apache#11516.
  • Loading branch information
qqibrow authored and kl0u committed Mar 30, 2020
1 parent f40cd69 commit ff491bd
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.flink.util.TestLogger;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;

import java.io.BufferedReader;
Expand Down Expand Up @@ -137,26 +138,27 @@ public void testDirectoryListing() throws Exception {
}
finally {
// clean up
fs.delete(directory, true);
cleanupDirectoryWithRetry(fs, directory, deadline);
}

// now directory must be gone
checkPathExistence(directory, false, deadline);
}

@AfterClass
public static void teardown() throws IOException, InterruptedException {
try {
if (fs != null) {
// clean up
fs.delete(basePath, true);

// now directory must be gone
checkPathExistence(basePath, false, deadline);
cleanupDirectoryWithRetry(fs, basePath, deadline);
}
}
finally {
FileSystem.initialize(new Configuration());
}
}

public static void cleanupDirectoryWithRetry(FileSystem fs, Path path, long deadline) throws IOException, InterruptedException {
while (fs.exists(path) && System.nanoTime() < deadline) {
fs.delete(path, true);
Thread.sleep(50L);
}
Assert.assertFalse(fs.exists(path));
}
}

0 comments on commit ff491bd

Please sign in to comment.