diff --git a/testsuite/integration/vdx/src/test/java/org/wildfly/test/integration/vdx/TestBase.java b/testsuite/integration/vdx/src/test/java/org/wildfly/test/integration/vdx/TestBase.java index b5a3263a961f..2502bf667ff2 100644 --- a/testsuite/integration/vdx/src/test/java/org/wildfly/test/integration/vdx/TestBase.java +++ b/testsuite/integration/vdx/src/test/java/org/wildfly/test/integration/vdx/TestBase.java @@ -15,10 +15,12 @@ import org.wildfly.test.integration.vdx.utils.server.ServerBase; import org.wildfly.test.integration.vdx.utils.server.Server; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; +import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -76,7 +78,7 @@ private void archiveServerLogAndDeleteIt(Path pathToArchiveDirectory) throws Exc // copy server.log files for standalone or host-controller.log for domain Files.copy(container().getServerLogPath(), pathToArchiveDirectory.resolve(container().getServerLogPath().getFileName()), StandardCopyOption.REPLACE_EXISTING); - Files.delete(container().getServerLogPath()); + deleteFile(container().getServerLogPath(), 5000); } private void createAndSetTestArchiveDirectoryToContainer(Path testArchiveDirectory) throws Exception { @@ -86,4 +88,19 @@ private void createAndSetTestArchiveDirectoryToContainer(Path testArchiveDirecto } container().setTestArchiveDirectory(testArchiveDirectory); } + + private void deleteFile(Path path, int timeout) throws IOException, InterruptedException { + long done = System.currentTimeMillis() + timeout; + while (true) { + try { + Files.delete(path); + break; + } catch (IOException e) { + if (System.currentTimeMillis() > done) { + throw e; + } + } + TimeUnit.MILLISECONDS.sleep(500); + } + } }