From 4760e3e333847434add73651dc0c194c57354c49 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Tue, 31 Mar 2026 19:11:27 -0700 Subject: [PATCH 1/5] Setting the writable flag of the child directory before deleting. --- .../assay/AssayTransformMissingParentDirTest.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java index d0979ba985..32d6c96fb6 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -19,6 +19,7 @@ import java.nio.file.AccessDeniedException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.stream.Stream; /** * Issue 54156: Regression test to ensure a reasonable error message is shown when an assay design references @@ -48,11 +49,19 @@ public void testMissingParentDirectoryRegression() throws Exception assayDesignerPage.addTransformScript(transformFile); assayDesignerPage.clickSave(); - // Now delete the parent dir to ensure we handle it reasonably. On Windows something locks the directory, maybe - // an external process. If that happens sleep for a second and try again. + // Now delete the parent dir to ensure we handle it reasonably. + // Sometimes on Windows the directory could be locked, maybe by an external process, or the child directory is + // readonly. Use a retry mechanism to set the writeable flag and then try to delete the parent directory. for (int attempt = 1; attempt <= 10; attempt++) { try { + parentDir.toFile().setWritable(true, false); + + // Wrap in a try to close the stream. + try (Stream files = Files.walk(parentDir)) { + files.forEach(p -> p.toFile().setWritable(true, false)); + } + FileUtils.deleteDirectory(parentDir.toFile()); log(String.format("Deletion of directory %s was successful.", parentDir)); break; From a6716e09ccf49a32baf18bed2107c74ed237ff17 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Mon, 6 Apr 2026 19:36:14 -0700 Subject: [PATCH 2/5] Adding a call to run "tasklist" if running on Windows. --- .../AssayTransformMissingParentDirTest.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java index 32d6c96fb6..660bc32079 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -1,9 +1,11 @@ package org.labkey.test.tests.assay; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.SystemUtils; import org.junit.Test; import org.junit.experimental.categories.Category; import org.labkey.api.util.FileUtil; +import org.labkey.api.util.StringUtilsLabKey; import org.labkey.test.Locator; import org.labkey.test.TestFileUtils; import org.labkey.test.categories.Assays; @@ -76,7 +78,22 @@ public void testMissingParentDirectoryRegression() throws Exception catch (IOException ioException) { log(String.format("IOException trying to delete directory %s. Error: %s. Waiting 10s and retrying. Attempt %d of 10.", parentDir, ioException.getMessage(), attempt)); - if (attempt == 10) throw ioException; + if (attempt == 10) + { + if (SystemUtils.IS_OS_WINDOWS) { + try { + log("Lock diagnostic..."); + ProcessBuilder pb = new ProcessBuilder("tasklist"); + pb.redirectErrorStream(true); + Process p = pb.start(); + String output = new String(p.getInputStream().readAllBytes(), StringUtilsLabKey.DEFAULT_CHARSET); + log("Running processes:\n" + output); + } catch (IOException diagnosticException) { + log("Failed to run lock diagnostic: " + diagnosticException.getMessage()); + } + } + throw ioException; + } sleep(10_000); } } From 195b11234ec01d97aab066b7cb2c87a9116a8eae Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Tue, 7 Apr 2026 18:11:11 -0700 Subject: [PATCH 3/5] Let the search indexer run. --- .../test/tests/assay/AssayTransformMissingParentDirTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java index 660bc32079..4ea482faa0 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -15,6 +15,7 @@ import org.labkey.test.pages.assay.AssayImportPage; import org.labkey.test.pages.assay.AssayRunsPage; import org.labkey.test.params.assay.GeneralAssayDesign; +import org.labkey.test.util.search.SearchAdminAPIHelper; import java.io.File; import java.io.IOException; @@ -51,6 +52,9 @@ public void testMissingParentDirectoryRegression() throws Exception assayDesignerPage.addTransformScript(transformFile); assayDesignerPage.clickSave(); + // Let the index run if needed. + SearchAdminAPIHelper.waitForIndexer(); + // Now delete the parent dir to ensure we handle it reasonably. // Sometimes on Windows the directory could be locked, maybe by an external process, or the child directory is // readonly. Use a retry mechanism to set the writeable flag and then try to delete the parent directory. From 7850ea49bbbab99b0a72e8df4b4da4497d113a90 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Wed, 8 Apr 2026 18:44:33 -0700 Subject: [PATCH 4/5] Remove wait for pipeline jobs and add heapDump. --- .../test/tests/assay/AssayTransformMissingParentDirTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java index 4ea482faa0..2d1733f8e9 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -84,6 +84,9 @@ public void testMissingParentDirectoryRegression() throws Exception parentDir, ioException.getMessage(), attempt)); if (attempt == 10) { + log("Dump the heap."); + dumpHeap(); + if (SystemUtils.IS_OS_WINDOWS) { try { log("Lock diagnostic..."); From 8bbb7eec0b3002e9063531c4acbdf40100457510 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Fri, 10 Apr 2026 16:10:14 -0700 Subject: [PATCH 5/5] Revert changes to AssayReimportIndexTest. No need to wait for the search indexer. --- .../test/tests/assay/AssayTransformMissingParentDirTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java index 2d1733f8e9..5cd0267904 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -52,9 +52,6 @@ public void testMissingParentDirectoryRegression() throws Exception assayDesignerPage.addTransformScript(transformFile); assayDesignerPage.clickSave(); - // Let the index run if needed. - SearchAdminAPIHelper.waitForIndexer(); - // Now delete the parent dir to ensure we handle it reasonably. // Sometimes on Windows the directory could be locked, maybe by an external process, or the child directory is // readonly. Use a retry mechanism to set the writeable flag and then try to delete the parent directory.