Skip to content

Commit e355ad0

Browse files
26.3 fb investigate windows failures (#2922)
1 parent 6685eb9 commit e355ad0

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.labkey.test.tests.assay;
22

3+
import org.apache.commons.io.FileUtils;
34
import org.junit.Test;
45
import org.junit.experimental.categories.Category;
56
import org.labkey.api.util.FileUtil;
@@ -14,6 +15,8 @@
1415
import org.labkey.test.params.assay.GeneralAssayDesign;
1516

1617
import java.io.File;
18+
import java.io.IOException;
19+
import java.nio.file.AccessDeniedException;
1720
import java.nio.file.Files;
1821
import java.nio.file.Path;
1922

@@ -45,8 +48,29 @@ public void testMissingParentDirectoryRegression() throws Exception
4548
assayDesignerPage.addTransformScript(transformFile);
4649
assayDesignerPage.clickSave();
4750

48-
// Now delete the parent dir to ensure we handle it reasonably
49-
TestFileUtils.deleteDir(parentDir.toFile());
51+
// Now delete the parent dir to ensure we handle it reasonably. On Windows something locks the directory, maybe
52+
// an external process. If that happens sleep for a second and try again.
53+
for (int attempt = 1; attempt <= 10; attempt++) {
54+
try
55+
{
56+
FileUtils.deleteDirectory(parentDir.toFile());
57+
log(String.format("Deletion of directory %s was successful.", parentDir));
58+
break;
59+
} catch (AccessDeniedException deniedException) {
60+
// Yes I know AccessDeniedException is a subset of an IOException, but I wanted to log explicitly a
61+
// failure and retry because of an AccessDeniedException from some other IOException.
62+
log(String.format("Access denied trying to delete directory %s. Error: %s. Waiting 10s and retrying. Attempt %d of 10.",
63+
parentDir, deniedException.getMessage(), attempt));
64+
if (attempt == 10) throw deniedException;
65+
sleep(10_000);
66+
}
67+
catch (IOException ioException) {
68+
log(String.format("IOException trying to delete directory %s. Error: %s. Waiting 10s and retrying. Attempt %d of 10.",
69+
parentDir, ioException.getMessage(), attempt));
70+
if (attempt == 10) throw ioException;
71+
sleep(10_000);
72+
}
73+
}
5074

5175
// Attempt to import data and verify a reasonable error message is shown
5276
String importData = """

0 commit comments

Comments
 (0)