fix (hopefully) test flakiness

This commit is contained in:
Chris Frohoff
2018-11-16 11:02:44 -08:00
parent 377216a525
commit fd911d0969
@@ -47,9 +47,12 @@ public class FileUploadTest implements CustomTest {
payload.call(); payload.call();
File found = null; File found = null;
for ( File f : this.repo.listFiles()) { for (int i = 0; i < 50 && found == null; i++) { // try for 5s before failing
found = f; for (File f : this.repo.listFiles()) {
break; found = f;
break;
}
Thread.sleep(100);
} }
Assert.assertNotNull("File not copied", found); Assert.assertNotNull("File not copied", found);
if (OS.get() != OS.WINDOWS) { if (OS.get() != OS.WINDOWS) {
@@ -60,11 +63,21 @@ public class FileUploadTest implements CustomTest {
} finally { } finally {
if ( this.repo.exists()) { if ( this.repo.exists()) {
for ( File f : this.repo.listFiles()) { for ( File f : this.repo.listFiles()) {
f.deleteOnExit(); safeDeleteOnExit(f);
} }
this.repo.deleteOnExit(); safeDeleteOnExit(this.repo);
} }
this.source.deleteOnExit(); safeDeleteOnExit(this.source);
}
}
private static void safeDeleteOnExit(File f) {
try {
if (f.exists()) {
f.deleteOnExit();
}
} catch (Exception e) {
e.printStackTrace();
} }
} }