From c7fc9ac7dbfa68f9eb1827cc5e93a07a5b156ae9 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Wed, 11 Mar 2026 16:01:12 -0700 Subject: [PATCH 01/15] Try getting some screenshots to see what is happening on the Windows runs. --- src/org/labkey/test/tests/DataReportsTest.java | 8 ++++++-- .../tests/assay/AssayTransformMissingParentDirTest.java | 7 +++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/org/labkey/test/tests/DataReportsTest.java b/src/org/labkey/test/tests/DataReportsTest.java index cfa691e780..96eeb3dcc1 100644 --- a/src/org/labkey/test/tests/DataReportsTest.java +++ b/src/org/labkey/test/tests/DataReportsTest.java @@ -437,19 +437,23 @@ public void doRReportsTest() _rReportHelper.ensureFieldSetExpanded("Shared Scripts"); _ext4Helper.checkCheckbox(R_SCRIPTS[0]); _ext4Helper.checkCheckbox(R_SCRIPTS[1]); - assertTrue("Script didn't execute as expeced", _rReportHelper.executeScript(R_SCRIPT3(DATA_BASE_PREFIX, "mouseid"), R_SCRIPT2_TEXT1)); + BaseWebDriverTest.getCurrentTest().getArtifactCollector().dumpPageSnapshot("Check Boxes"); + assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT3(DATA_BASE_PREFIX, "mouseid"), R_SCRIPT2_TEXT1)); saveReport(R_SCRIPTS[2]); log("Test editing R scripts"); signIn(); // Reset session to make sure R report isn't cached navigateToFolder(getProjectName(), getFolderName()); clickReportGridLink(R_SCRIPTS[0]); - assertTrue("Script didn't execute as expeced", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX), R_SCRIPT1_TEXT1)); + BaseWebDriverTest.getCurrentTest().getArtifactCollector().dumpPageSnapshot("Rscripts-0"); + assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX), R_SCRIPT1_TEXT1)); resaveReport(); + BaseWebDriverTest.getCurrentTest().getArtifactCollector().dumpPageSnapshot("resaved"); log("Check that edit worked"); navigateToFolder(getProjectName(), getFolderName()); clickReportGridLink(R_SCRIPTS[1]); + BaseWebDriverTest.getCurrentTest().getArtifactCollector().dumpPageSnapshot("Rscripts-1"); waitAndClick(Locator.lkButton("Start Job")); WebElement pipelineLink = waitForElement(Locator.linkWithText("click here")); diff --git a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java index 69c8a94f29..b236f80072 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -1,8 +1,10 @@ package org.labkey.test.tests.assay; +import org.apache.commons.io.FileUtils; import org.junit.Test; import org.junit.experimental.categories.Category; import org.labkey.api.util.FileUtil; +import org.labkey.test.BaseWebDriverTest; import org.labkey.test.Locator; import org.labkey.test.TestFileUtils; import org.labkey.test.categories.Assays; @@ -43,11 +45,16 @@ public void testMissingParentDirectoryRegression() throws Exception assayDesignerPage.goToBatchFields().removeAllFields(true); // add by path so the absolute path is stored; this allows reproducing the missing parent dir scenario assayDesignerPage.addTransformScript(transformFile); + BaseWebDriverTest.getCurrentTest().getArtifactCollector().dumpPageSnapshot("Transform Scrip Added"); assayDesignerPage.clickSave(); + log("Is directory present? " + FileUtils.isDirectory(parentDir.toFile())); + // Now delete the parent dir to ensure we handle it reasonably TestFileUtils.deleteDir(parentDir.toFile()); + log("Is directory present? " + FileUtils.isDirectory(parentDir.toFile())); + // Attempt to import data and verify a reasonable error message is shown String importData = """ VisitID\tParticipantID\tComment From 9d9915ef447deb6c466b0b6be66336d71b31e601 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Wed, 11 Mar 2026 17:46:49 -0700 Subject: [PATCH 02/15] Try again to get screenshots. --- src/org/labkey/test/tests/DataReportsTest.java | 8 ++++---- .../tests/assay/AssayTransformMissingParentDirTest.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/org/labkey/test/tests/DataReportsTest.java b/src/org/labkey/test/tests/DataReportsTest.java index 96eeb3dcc1..74f859ffa0 100644 --- a/src/org/labkey/test/tests/DataReportsTest.java +++ b/src/org/labkey/test/tests/DataReportsTest.java @@ -437,7 +437,7 @@ public void doRReportsTest() _rReportHelper.ensureFieldSetExpanded("Shared Scripts"); _ext4Helper.checkCheckbox(R_SCRIPTS[0]); _ext4Helper.checkCheckbox(R_SCRIPTS[1]); - BaseWebDriverTest.getCurrentTest().getArtifactCollector().dumpPageSnapshot("Check Boxes"); + getArtifactCollector().dumpPageSnapshot("Check_Boxes"); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT3(DATA_BASE_PREFIX, "mouseid"), R_SCRIPT2_TEXT1)); saveReport(R_SCRIPTS[2]); @@ -445,15 +445,15 @@ public void doRReportsTest() signIn(); // Reset session to make sure R report isn't cached navigateToFolder(getProjectName(), getFolderName()); clickReportGridLink(R_SCRIPTS[0]); - BaseWebDriverTest.getCurrentTest().getArtifactCollector().dumpPageSnapshot("Rscripts-0"); + getArtifactCollector().dumpPageSnapshot("Rscripts_0"); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX), R_SCRIPT1_TEXT1)); resaveReport(); - BaseWebDriverTest.getCurrentTest().getArtifactCollector().dumpPageSnapshot("resaved"); + getArtifactCollector().dumpPageSnapshot("ReSaved"); log("Check that edit worked"); navigateToFolder(getProjectName(), getFolderName()); clickReportGridLink(R_SCRIPTS[1]); - BaseWebDriverTest.getCurrentTest().getArtifactCollector().dumpPageSnapshot("Rscripts-1"); + getArtifactCollector().dumpPageSnapshot("Rscripts_1"); waitAndClick(Locator.lkButton("Start Job")); WebElement pipelineLink = waitForElement(Locator.linkWithText("click here")); diff --git a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java index b236f80072..de73ac9995 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -45,7 +45,7 @@ public void testMissingParentDirectoryRegression() throws Exception assayDesignerPage.goToBatchFields().removeAllFields(true); // add by path so the absolute path is stored; this allows reproducing the missing parent dir scenario assayDesignerPage.addTransformScript(transformFile); - BaseWebDriverTest.getCurrentTest().getArtifactCollector().dumpPageSnapshot("Transform Scrip Added"); + getArtifactCollector().dumpPageSnapshot("TransformScript_Added"); assayDesignerPage.clickSave(); log("Is directory present? " + FileUtils.isDirectory(parentDir.toFile())); From eca274fb21ba469d61a59c962b3a73598162313a Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Thu, 12 Mar 2026 12:28:11 -0700 Subject: [PATCH 03/15] Add more screenshots. Try and wait for folder deltion. --- src/org/labkey/test/tests/DataReportsTest.java | 17 +++++++++++++---- .../AssayTransformMissingParentDirTest.java | 16 ++++++++++++---- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/org/labkey/test/tests/DataReportsTest.java b/src/org/labkey/test/tests/DataReportsTest.java index 74f859ffa0..afd1ade91c 100644 --- a/src/org/labkey/test/tests/DataReportsTest.java +++ b/src/org/labkey/test/tests/DataReportsTest.java @@ -319,19 +319,24 @@ public void doRReportsTest() log("Execute bad scripts"); _rReportHelper.clickReportTab(); + getArtifactCollector().dumpPageSnapshot("Debug_00"); assertTextPresent("Empty script, a script must be provided."); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_ORIG_FUNC, DATA_BASE_PREFIX) + "\nbadString", R_SCRIPT1_TEXT1)); + getArtifactCollector().dumpPageSnapshot("Debug_01"); + // horrible hack to get around single versus double quote difference when running R on Linux or Windows systems. assertTextPresent("Error: object ", "badString", R_SCRIPT1_TEXT1, R_SCRIPT1_TEXT2, R_SCRIPT1_PDF); assertElementPresent(Locator.xpath("//img[starts-with(@id,'" + R_SCRIPT1_IMG + "')]")); log("Execute and save a script"); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_ORIG_FUNC, DATA_BASE_PREFIX), R_SCRIPT1_TEXT1)); + getArtifactCollector().dumpPageSnapshot("Debug_02"); log("Check that the script executed properly"); assertTextPresent(R_SCRIPT1_TEXT1, R_SCRIPT1_TEXT2, R_SCRIPT1_PDF); assertElementPresent(Locator.xpath("//img[starts-with(@id,'" + R_SCRIPT1_IMG + "')]")); + getArtifactCollector().dumpPageSnapshot("Debug_03"); saveReport(R_SCRIPTS[0]); verifyReportPdfDownload("study", 4500d); @@ -368,6 +373,7 @@ public void doRReportsTest() waitForText(WAIT_FOR_PAGE, "Console output"); assertTextPresent("null device", R_SCRIPT1_TEXT1, R_SCRIPT1_TEXT2, R_SCRIPT1_PDF); assertElementPresent(Locator.xpath("//img[starts-with(@id,'" + R_SCRIPT1_IMG + "')]")); + getArtifactCollector().dumpPageSnapshot("Debug_04"); assertTextNotPresent("Error executing command"); verifyReportPdfDownload("study", 4500d); popLocation(); @@ -386,6 +392,7 @@ public void doRReportsTest() navigateToFolder(getProjectName(), getFolderName()); clickAndWait(Locator.linkWithText(DATA_SET)); createRReport(AUTHOR_REPORT, R_SCRIPT2(DATA_BASE_PREFIX, "mouseId"), true, true, new String[0]); + getArtifactCollector().dumpPageSnapshot("Debug_05"); if (!TestProperties.isPrimaryUserAppAdmin()) { stopImpersonating(); @@ -397,10 +404,12 @@ public void doRReportsTest() _rReportHelper.ensureFieldSetExpanded("Shared Scripts"); _ext4Helper.checkCheckbox(R_SCRIPTS[0]); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT2(DATA_BASE_PREFIX, "mouseid"), R_SCRIPT2_TEXT1)); + getArtifactCollector().dumpPageSnapshot("Debug_06"); _rReportHelper.clickSourceTab(); _rReportHelper.selectOption(ScriptReportPage.StandardReportOption.shareReport); _rReportHelper.selectOption(ScriptReportPage.StandardReportOption.runInPipeline); saveReport(R_SCRIPTS[1]); + getArtifactCollector().dumpPageSnapshot("Debug_07"); log("Check that R script worked"); _rReportHelper.clickReportTab(); @@ -437,7 +446,7 @@ public void doRReportsTest() _rReportHelper.ensureFieldSetExpanded("Shared Scripts"); _ext4Helper.checkCheckbox(R_SCRIPTS[0]); _ext4Helper.checkCheckbox(R_SCRIPTS[1]); - getArtifactCollector().dumpPageSnapshot("Check_Boxes"); + getArtifactCollector().dumpPageSnapshot("Debug_08"); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT3(DATA_BASE_PREFIX, "mouseid"), R_SCRIPT2_TEXT1)); saveReport(R_SCRIPTS[2]); @@ -445,15 +454,15 @@ public void doRReportsTest() signIn(); // Reset session to make sure R report isn't cached navigateToFolder(getProjectName(), getFolderName()); clickReportGridLink(R_SCRIPTS[0]); - getArtifactCollector().dumpPageSnapshot("Rscripts_0"); + getArtifactCollector().dumpPageSnapshot("Debug_09"); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX), R_SCRIPT1_TEXT1)); resaveReport(); - getArtifactCollector().dumpPageSnapshot("ReSaved"); + getArtifactCollector().dumpPageSnapshot("Debug_10"); log("Check that edit worked"); navigateToFolder(getProjectName(), getFolderName()); clickReportGridLink(R_SCRIPTS[1]); - getArtifactCollector().dumpPageSnapshot("Rscripts_1"); + getArtifactCollector().dumpPageSnapshot("Debug_011"); waitAndClick(Locator.lkButton("Start Job")); WebElement pipelineLink = waitForElement(Locator.linkWithText("click here")); diff --git a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java index de73ac9995..2887ed479e 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -1,6 +1,7 @@ package org.labkey.test.tests.assay; import org.apache.commons.io.FileUtils; +import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; import org.labkey.api.util.FileUtil; @@ -31,7 +32,7 @@ public void testMissingParentDirectoryRegression() throws Exception { // Create a nested directory and an R transform script within it String assayName = "missingParentDirAssay"; - Path parentDir = Files.createTempDirectory("assay-transform-parent-"); + Path parentDir = Files.createTempDirectory("assay-transform-missing-parent-"); Path nestedDir = FileUtil.createDirectories(parentDir.resolve("child"), false); String scriptName = "transformMissingParent.R"; String transformContent = "library(Rlabkey);"; @@ -48,12 +49,19 @@ public void testMissingParentDirectoryRegression() throws Exception getArtifactCollector().dumpPageSnapshot("TransformScript_Added"); assayDesignerPage.clickSave(); - log("Is directory present? " + FileUtils.isDirectory(parentDir.toFile())); - // Now delete the parent dir to ensure we handle it reasonably TestFileUtils.deleteDir(parentDir.toFile()); - log("Is directory present? " + FileUtils.isDirectory(parentDir.toFile())); + int count = 1; + while (!FileUtils.isDirectory(parentDir.toFile()) && count <= 5) + { + sleep(1_000); + TestFileUtils.deleteDir(parentDir.toFile()); + count++; + } + + Assert.assertFalse(String.format("Directory %s not deleted.", parentDir.toString()), + FileUtils.isDirectory(parentDir.toFile())); // Attempt to import data and verify a reasonable error message is shown String importData = """ From 06cb6f4adb7e269aa812f6c223a6714b31d30d60 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Thu, 12 Mar 2026 13:40:51 -0700 Subject: [PATCH 04/15] Add a few waits before debug screenshots. --- src/org/labkey/test/tests/DataReportsTest.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/org/labkey/test/tests/DataReportsTest.java b/src/org/labkey/test/tests/DataReportsTest.java index afd1ade91c..35df513255 100644 --- a/src/org/labkey/test/tests/DataReportsTest.java +++ b/src/org/labkey/test/tests/DataReportsTest.java @@ -319,10 +319,12 @@ public void doRReportsTest() log("Execute bad scripts"); _rReportHelper.clickReportTab(); + sleep(1_000); getArtifactCollector().dumpPageSnapshot("Debug_00"); assertTextPresent("Empty script, a script must be provided."); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_ORIG_FUNC, DATA_BASE_PREFIX) + "\nbadString", R_SCRIPT1_TEXT1)); + sleep(1_000); getArtifactCollector().dumpPageSnapshot("Debug_01"); // horrible hack to get around single versus double quote difference when running R on Linux or Windows systems. @@ -331,11 +333,13 @@ public void doRReportsTest() log("Execute and save a script"); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_ORIG_FUNC, DATA_BASE_PREFIX), R_SCRIPT1_TEXT1)); + sleep(1_000); getArtifactCollector().dumpPageSnapshot("Debug_02"); log("Check that the script executed properly"); assertTextPresent(R_SCRIPT1_TEXT1, R_SCRIPT1_TEXT2, R_SCRIPT1_PDF); assertElementPresent(Locator.xpath("//img[starts-with(@id,'" + R_SCRIPT1_IMG + "')]")); + sleep(1_000); getArtifactCollector().dumpPageSnapshot("Debug_03"); saveReport(R_SCRIPTS[0]); @@ -373,6 +377,7 @@ public void doRReportsTest() waitForText(WAIT_FOR_PAGE, "Console output"); assertTextPresent("null device", R_SCRIPT1_TEXT1, R_SCRIPT1_TEXT2, R_SCRIPT1_PDF); assertElementPresent(Locator.xpath("//img[starts-with(@id,'" + R_SCRIPT1_IMG + "')]")); + sleep(1_000); getArtifactCollector().dumpPageSnapshot("Debug_04"); assertTextNotPresent("Error executing command"); verifyReportPdfDownload("study", 4500d); @@ -392,6 +397,7 @@ public void doRReportsTest() navigateToFolder(getProjectName(), getFolderName()); clickAndWait(Locator.linkWithText(DATA_SET)); createRReport(AUTHOR_REPORT, R_SCRIPT2(DATA_BASE_PREFIX, "mouseId"), true, true, new String[0]); + sleep(1_000); getArtifactCollector().dumpPageSnapshot("Debug_05"); if (!TestProperties.isPrimaryUserAppAdmin()) { @@ -404,11 +410,13 @@ public void doRReportsTest() _rReportHelper.ensureFieldSetExpanded("Shared Scripts"); _ext4Helper.checkCheckbox(R_SCRIPTS[0]); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT2(DATA_BASE_PREFIX, "mouseid"), R_SCRIPT2_TEXT1)); + sleep(1_000); getArtifactCollector().dumpPageSnapshot("Debug_06"); _rReportHelper.clickSourceTab(); _rReportHelper.selectOption(ScriptReportPage.StandardReportOption.shareReport); _rReportHelper.selectOption(ScriptReportPage.StandardReportOption.runInPipeline); saveReport(R_SCRIPTS[1]); + sleep(1_000); getArtifactCollector().dumpPageSnapshot("Debug_07"); log("Check that R script worked"); @@ -446,22 +454,26 @@ public void doRReportsTest() _rReportHelper.ensureFieldSetExpanded("Shared Scripts"); _ext4Helper.checkCheckbox(R_SCRIPTS[0]); _ext4Helper.checkCheckbox(R_SCRIPTS[1]); - getArtifactCollector().dumpPageSnapshot("Debug_08"); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT3(DATA_BASE_PREFIX, "mouseid"), R_SCRIPT2_TEXT1)); + sleep(1_000); + getArtifactCollector().dumpPageSnapshot("Debug_08"); saveReport(R_SCRIPTS[2]); log("Test editing R scripts"); signIn(); // Reset session to make sure R report isn't cached navigateToFolder(getProjectName(), getFolderName()); clickReportGridLink(R_SCRIPTS[0]); + sleep(1_000); getArtifactCollector().dumpPageSnapshot("Debug_09"); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX), R_SCRIPT1_TEXT1)); resaveReport(); + sleep(1_000); getArtifactCollector().dumpPageSnapshot("Debug_10"); log("Check that edit worked"); navigateToFolder(getProjectName(), getFolderName()); clickReportGridLink(R_SCRIPTS[1]); + sleep(1_000); getArtifactCollector().dumpPageSnapshot("Debug_011"); waitAndClick(Locator.lkButton("Start Job")); @@ -471,6 +483,8 @@ public void doRReportsTest() waitForPipelineJobsToComplete(2, false); // go back to the report and confirm it is visible clickReportGridLink(R_SCRIPTS[1]); + sleep(1_000); + getArtifactCollector().dumpPageSnapshot("Debug_012"); waitForElement(Locator.tagWithName("img", "resultImage")); assertTextPresent(R_SCRIPT2_TEXT2); assertTextNotPresent(R_SCRIPT2_TEXT1); From 06940f955828d4df3383ebd000ea19b4a4d10b25 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Thu, 12 Mar 2026 15:38:10 -0700 Subject: [PATCH 05/15] More debug stuff. --- .../labkey/test/tests/DataReportsTest.java | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/org/labkey/test/tests/DataReportsTest.java b/src/org/labkey/test/tests/DataReportsTest.java index 35df513255..20f0ac1eb5 100644 --- a/src/org/labkey/test/tests/DataReportsTest.java +++ b/src/org/labkey/test/tests/DataReportsTest.java @@ -474,17 +474,52 @@ public void doRReportsTest() navigateToFolder(getProjectName(), getFolderName()); clickReportGridLink(R_SCRIPTS[1]); sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_011"); + getArtifactCollector().dumpPageSnapshot("Debug_11"); + log("URL 01: " + getURL().toString()); waitAndClick(Locator.lkButton("Start Job")); WebElement pipelineLink = waitForElement(Locator.linkWithText("click here")); waitForElement(Locator.byClass("x4-window").containing("Start Pipeline Job").hidden()); + sleep(1_000); + getArtifactCollector().dumpPageSnapshot("Debug_12"); + log("URL 02: " + getURL().toString()); clickAndWait(pipelineLink); waitForPipelineJobsToComplete(2, false); + sleep(1_000); + getArtifactCollector().dumpPageSnapshot("Debug_13"); + log("URL 03: " + getURL().toString()); + + + + + // go back to the report and confirm it is visible - clickReportGridLink(R_SCRIPTS[1]); +// clickReportGridLink(R_SCRIPTS[1]); + +// Locator link = getReportGridLink(R_SCRIPTS[1], true); +// goToManageViews(); + clickAdminMenuItem("Manage Views"); + waitForElement(Locator.xpath("//*[starts-with(@id, 'dataviews-panel')]")); + _extHelper.waitForLoadingMaskToDisappear(WAIT_FOR_JAVASCRIPT); + + sleep(1_000); + getArtifactCollector().dumpPageSnapshot("Debug_14"); + log("URL 04: " + getURL().toString()); + + waitForElement(Locator.linkWithText(R_SCRIPTS[1]), WAIT_FOR_JAVASCRIPT); + Locator link = Locator.linkWithText(R_SCRIPTS[1]); + sleep(1_000); + getArtifactCollector().dumpPageSnapshot("Debug_15"); + log("URL 05: " + getURL().toString()); + + clickAndWait(link, WAIT_FOR_JAVASCRIPT); + _extHelper.waitForLoadingMaskToDisappear(WAIT_FOR_JAVASCRIPT); + + sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_012"); + getArtifactCollector().dumpPageSnapshot("Debug_16"); + log("URL 06: " + getURL().toString()); + waitForElement(Locator.tagWithName("img", "resultImage")); assertTextPresent(R_SCRIPT2_TEXT2); assertTextNotPresent(R_SCRIPT2_TEXT1); From 552371284c5cf318a7463fb704342acda567ab7b Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Fri, 13 Mar 2026 11:53:19 -0700 Subject: [PATCH 06/15] ANd yet more debug stuff. --- .../labkey/test/tests/DataReportsTest.java | 29 ++++++++++++++++++- src/org/labkey/test/util/RReportHelper.java | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/org/labkey/test/tests/DataReportsTest.java b/src/org/labkey/test/tests/DataReportsTest.java index 20f0ac1eb5..633b9d19d2 100644 --- a/src/org/labkey/test/tests/DataReportsTest.java +++ b/src/org/labkey/test/tests/DataReportsTest.java @@ -465,7 +465,31 @@ public void doRReportsTest() clickReportGridLink(R_SCRIPTS[0]); sleep(1_000); getArtifactCollector().dumpPageSnapshot("Debug_09"); - assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX), R_SCRIPT1_TEXT1)); + log("Script: function: " + R_SCRIPT1_EDIT_FUNC); + log("Script: database: " + DATA_BASE_PREFIX); + log("Script: R_SCRIPT1: " + R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX)); +// assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX), R_SCRIPT1_TEXT1)); + + + + _rReportHelper.clickSourceTab(); + + setCodeEditorValue("script-report-editor", R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX)); + sleep(1_000); + getArtifactCollector().dumpPageSnapshot("Debug_09_A"); + + _rReportHelper.clickReportTab(); + sleep(1_000); + getArtifactCollector().dumpPageSnapshot("Debug_09_B"); + + String html = _rReportHelper.getReportText(); + log("_rReportHelper.getReportText(): " + html); + log("expected text: " + R_SCRIPT1_TEXT1); + log("checkScriptOutput: " + _rReportHelper.checkScriptOutput(html, R_SCRIPT1_TEXT1, true)); + + + + resaveReport(); sleep(1_000); getArtifactCollector().dumpPageSnapshot("Debug_10"); @@ -516,6 +540,9 @@ public void doRReportsTest() _extHelper.waitForLoadingMaskToDisappear(WAIT_FOR_JAVASCRIPT); + + + sleep(1_000); getArtifactCollector().dumpPageSnapshot("Debug_16"); log("URL 06: " + getURL().toString()); diff --git a/src/org/labkey/test/util/RReportHelper.java b/src/org/labkey/test/util/RReportHelper.java index cf9d788431..c33d886458 100644 --- a/src/org/labkey/test/util/RReportHelper.java +++ b/src/org/labkey/test/util/RReportHelper.java @@ -160,7 +160,7 @@ public boolean executeScriptDirectly(String script, String expectedLines, boolea return checkScriptOutput(scriptOutput, expectedLines, failOnError); } - private boolean checkScriptOutput(String scriptOutput, String expectedLines, boolean failOnError) + public boolean checkScriptOutput(String scriptOutput, String expectedLines, boolean failOnError) { if (failOnError && doesScriptProduceError(scriptOutput)) return false; From d6fc4b2d0f5d3bea4fe7e6cceafc1f2c90317fb0 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Fri, 13 Mar 2026 17:26:24 -0700 Subject: [PATCH 07/15] Narrowing down debug work. --- .../labkey/test/tests/DataReportsTest.java | 65 +++++++++---------- 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/src/org/labkey/test/tests/DataReportsTest.java b/src/org/labkey/test/tests/DataReportsTest.java index 633b9d19d2..98dc990320 100644 --- a/src/org/labkey/test/tests/DataReportsTest.java +++ b/src/org/labkey/test/tests/DataReportsTest.java @@ -319,28 +319,19 @@ public void doRReportsTest() log("Execute bad scripts"); _rReportHelper.clickReportTab(); - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_00"); assertTextPresent("Empty script, a script must be provided."); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_ORIG_FUNC, DATA_BASE_PREFIX) + "\nbadString", R_SCRIPT1_TEXT1)); - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_01"); - // horrible hack to get around single versus double quote difference when running R on Linux or Windows systems. assertTextPresent("Error: object ", "badString", R_SCRIPT1_TEXT1, R_SCRIPT1_TEXT2, R_SCRIPT1_PDF); assertElementPresent(Locator.xpath("//img[starts-with(@id,'" + R_SCRIPT1_IMG + "')]")); log("Execute and save a script"); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_ORIG_FUNC, DATA_BASE_PREFIX), R_SCRIPT1_TEXT1)); - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_02"); log("Check that the script executed properly"); assertTextPresent(R_SCRIPT1_TEXT1, R_SCRIPT1_TEXT2, R_SCRIPT1_PDF); assertElementPresent(Locator.xpath("//img[starts-with(@id,'" + R_SCRIPT1_IMG + "')]")); - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_03"); saveReport(R_SCRIPTS[0]); verifyReportPdfDownload("study", 4500d); @@ -377,8 +368,6 @@ public void doRReportsTest() waitForText(WAIT_FOR_PAGE, "Console output"); assertTextPresent("null device", R_SCRIPT1_TEXT1, R_SCRIPT1_TEXT2, R_SCRIPT1_PDF); assertElementPresent(Locator.xpath("//img[starts-with(@id,'" + R_SCRIPT1_IMG + "')]")); - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_04"); assertTextNotPresent("Error executing command"); verifyReportPdfDownload("study", 4500d); popLocation(); @@ -397,8 +386,6 @@ public void doRReportsTest() navigateToFolder(getProjectName(), getFolderName()); clickAndWait(Locator.linkWithText(DATA_SET)); createRReport(AUTHOR_REPORT, R_SCRIPT2(DATA_BASE_PREFIX, "mouseId"), true, true, new String[0]); - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_05"); if (!TestProperties.isPrimaryUserAppAdmin()) { stopImpersonating(); @@ -410,14 +397,10 @@ public void doRReportsTest() _rReportHelper.ensureFieldSetExpanded("Shared Scripts"); _ext4Helper.checkCheckbox(R_SCRIPTS[0]); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT2(DATA_BASE_PREFIX, "mouseid"), R_SCRIPT2_TEXT1)); - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_06"); _rReportHelper.clickSourceTab(); _rReportHelper.selectOption(ScriptReportPage.StandardReportOption.shareReport); _rReportHelper.selectOption(ScriptReportPage.StandardReportOption.runInPipeline); saveReport(R_SCRIPTS[1]); - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_07"); log("Check that R script worked"); _rReportHelper.clickReportTab(); @@ -455,23 +438,25 @@ public void doRReportsTest() _ext4Helper.checkCheckbox(R_SCRIPTS[0]); _ext4Helper.checkCheckbox(R_SCRIPTS[1]); assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT3(DATA_BASE_PREFIX, "mouseid"), R_SCRIPT2_TEXT1)); - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_08"); saveReport(R_SCRIPTS[2]); log("Test editing R scripts"); signIn(); // Reset session to make sure R report isn't cached navigateToFolder(getProjectName(), getFolderName()); clickReportGridLink(R_SCRIPTS[0]); + + // Trying to debug windows failures on TC. sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_09"); + getArtifactCollector().dumpPageSnapshot("Debug_01"); log("Script: function: " + R_SCRIPT1_EDIT_FUNC); log("Script: database: " + DATA_BASE_PREFIX); log("Script: R_SCRIPT1: " + R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX)); -// assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX), R_SCRIPT1_TEXT1)); + // Trying to debug windows failures on TC. + // Moved the code behind the call to _rReportHelper.executeScript into this test to make loggin less obnoxious for other tests. +// assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX), R_SCRIPT1_TEXT1)); _rReportHelper.clickSourceTab(); setCodeEditorValue("script-report-editor", R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX)); @@ -491,34 +476,45 @@ public void doRReportsTest() resaveReport(); + + // Trying to debug windows failures on TC. sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_10"); + getArtifactCollector().dumpPageSnapshot("Debug_02"); log("Check that edit worked"); navigateToFolder(getProjectName(), getFolderName()); clickReportGridLink(R_SCRIPTS[1]); + + // Trying to debug windows failures on TC. sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_11"); + getArtifactCollector().dumpPageSnapshot("Debug_03"); log("URL 01: " + getURL().toString()); + waitAndClick(Locator.lkButton("Start Job")); WebElement pipelineLink = waitForElement(Locator.linkWithText("click here")); waitForElement(Locator.byClass("x4-window").containing("Start Pipeline Job").hidden()); + + // Trying to debug windows failures on TC. sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_12"); + getArtifactCollector().dumpPageSnapshot("Debug_04"); log("URL 02: " + getURL().toString()); + clickAndWait(pipelineLink); waitForPipelineJobsToComplete(2, false); + + // Trying to debug windows failures on TC. + clickAndWait(Locator.linkWithText("COMPLETE")); + click(Locator.linkWithText("Show full log file")); sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_13"); + getArtifactCollector().dumpPageSnapshot("Debug_05"); log("URL 03: " + getURL().toString()); - - - + // Trying to debug windows failures on TC. + // Moving code for the next few lines to make logging less obnoxious. // go back to the report and confirm it is visible -// clickReportGridLink(R_SCRIPTS[1]); + clickReportGridLink(R_SCRIPTS[1]); // Locator link = getReportGridLink(R_SCRIPTS[1], true); // goToManageViews(); @@ -527,24 +523,21 @@ public void doRReportsTest() _extHelper.waitForLoadingMaskToDisappear(WAIT_FOR_JAVASCRIPT); sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_14"); + getArtifactCollector().dumpPageSnapshot("Debug_06"); log("URL 04: " + getURL().toString()); + //clickReportGridLink waitForElement(Locator.linkWithText(R_SCRIPTS[1]), WAIT_FOR_JAVASCRIPT); Locator link = Locator.linkWithText(R_SCRIPTS[1]); sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_15"); + getArtifactCollector().dumpPageSnapshot("Debug_07"); log("URL 05: " + getURL().toString()); clickAndWait(link, WAIT_FOR_JAVASCRIPT); _extHelper.waitForLoadingMaskToDisappear(WAIT_FOR_JAVASCRIPT); - - - - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_16"); + getArtifactCollector().dumpPageSnapshot("Debug_08"); log("URL 06: " + getURL().toString()); waitForElement(Locator.tagWithName("img", "resultImage")); From 77b01cc911954190b2a47c8f10f7136073216645 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Tue, 24 Mar 2026 14:57:16 -0700 Subject: [PATCH 08/15] Reverting debug work. --- .../labkey/test/tests/DataReportsTest.java | 86 +------------------ 1 file changed, 2 insertions(+), 84 deletions(-) diff --git a/src/org/labkey/test/tests/DataReportsTest.java b/src/org/labkey/test/tests/DataReportsTest.java index 98dc990320..cfa691e780 100644 --- a/src/org/labkey/test/tests/DataReportsTest.java +++ b/src/org/labkey/test/tests/DataReportsTest.java @@ -437,109 +437,27 @@ public void doRReportsTest() _rReportHelper.ensureFieldSetExpanded("Shared Scripts"); _ext4Helper.checkCheckbox(R_SCRIPTS[0]); _ext4Helper.checkCheckbox(R_SCRIPTS[1]); - assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT3(DATA_BASE_PREFIX, "mouseid"), R_SCRIPT2_TEXT1)); + assertTrue("Script didn't execute as expeced", _rReportHelper.executeScript(R_SCRIPT3(DATA_BASE_PREFIX, "mouseid"), R_SCRIPT2_TEXT1)); saveReport(R_SCRIPTS[2]); log("Test editing R scripts"); signIn(); // Reset session to make sure R report isn't cached navigateToFolder(getProjectName(), getFolderName()); clickReportGridLink(R_SCRIPTS[0]); - - // Trying to debug windows failures on TC. - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_01"); - log("Script: function: " + R_SCRIPT1_EDIT_FUNC); - log("Script: database: " + DATA_BASE_PREFIX); - log("Script: R_SCRIPT1: " + R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX)); - - - - // Trying to debug windows failures on TC. - // Moved the code behind the call to _rReportHelper.executeScript into this test to make loggin less obnoxious for other tests. -// assertTrue("Script didn't execute as expected", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX), R_SCRIPT1_TEXT1)); - _rReportHelper.clickSourceTab(); - - setCodeEditorValue("script-report-editor", R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX)); - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_09_A"); - - _rReportHelper.clickReportTab(); - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_09_B"); - - String html = _rReportHelper.getReportText(); - log("_rReportHelper.getReportText(): " + html); - log("expected text: " + R_SCRIPT1_TEXT1); - log("checkScriptOutput: " + _rReportHelper.checkScriptOutput(html, R_SCRIPT1_TEXT1, true)); - - - - + assertTrue("Script didn't execute as expeced", _rReportHelper.executeScript(R_SCRIPT1(R_SCRIPT1_EDIT_FUNC, DATA_BASE_PREFIX), R_SCRIPT1_TEXT1)); resaveReport(); - // Trying to debug windows failures on TC. - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_02"); - log("Check that edit worked"); navigateToFolder(getProjectName(), getFolderName()); clickReportGridLink(R_SCRIPTS[1]); - - // Trying to debug windows failures on TC. - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_03"); - log("URL 01: " + getURL().toString()); - waitAndClick(Locator.lkButton("Start Job")); WebElement pipelineLink = waitForElement(Locator.linkWithText("click here")); waitForElement(Locator.byClass("x4-window").containing("Start Pipeline Job").hidden()); - - // Trying to debug windows failures on TC. - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_04"); - log("URL 02: " + getURL().toString()); - clickAndWait(pipelineLink); waitForPipelineJobsToComplete(2, false); - - // Trying to debug windows failures on TC. - clickAndWait(Locator.linkWithText("COMPLETE")); - click(Locator.linkWithText("Show full log file")); - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_05"); - log("URL 03: " + getURL().toString()); - - - // Trying to debug windows failures on TC. - // Moving code for the next few lines to make logging less obnoxious. // go back to the report and confirm it is visible clickReportGridLink(R_SCRIPTS[1]); - -// Locator link = getReportGridLink(R_SCRIPTS[1], true); -// goToManageViews(); - clickAdminMenuItem("Manage Views"); - waitForElement(Locator.xpath("//*[starts-with(@id, 'dataviews-panel')]")); - _extHelper.waitForLoadingMaskToDisappear(WAIT_FOR_JAVASCRIPT); - - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_06"); - log("URL 04: " + getURL().toString()); - - //clickReportGridLink - waitForElement(Locator.linkWithText(R_SCRIPTS[1]), WAIT_FOR_JAVASCRIPT); - Locator link = Locator.linkWithText(R_SCRIPTS[1]); - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_07"); - log("URL 05: " + getURL().toString()); - - clickAndWait(link, WAIT_FOR_JAVASCRIPT); - _extHelper.waitForLoadingMaskToDisappear(WAIT_FOR_JAVASCRIPT); - - sleep(1_000); - getArtifactCollector().dumpPageSnapshot("Debug_08"); - log("URL 06: " + getURL().toString()); - waitForElement(Locator.tagWithName("img", "resultImage")); assertTextPresent(R_SCRIPT2_TEXT2); assertTextNotPresent(R_SCRIPT2_TEXT1); From d936456b1799fe16474f720b569abbe201e190c6 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Tue, 24 Mar 2026 17:13:21 -0700 Subject: [PATCH 09/15] Try renaming rather than deleting the directory on Windows. --- src/org/labkey/test/TestFileUtils.java | 20 ++++++++++++++++++ .../AssayTransformMissingParentDirTest.java | 21 +++++++++++-------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/org/labkey/test/TestFileUtils.java b/src/org/labkey/test/TestFileUtils.java index d73ad973a1..e2dd84f3ab 100644 --- a/src/org/labkey/test/TestFileUtils.java +++ b/src/org/labkey/test/TestFileUtils.java @@ -38,6 +38,7 @@ import org.bouncycastle.openpgp.operator.jcajce.JcePBEDataDecryptorFactoryBuilder; import org.bouncycastle.util.io.Streams; import org.jetbrains.annotations.NotNull; +import org.junit.Assert; import org.labkey.api.util.FileUtil; import org.jetbrains.annotations.Nullable; import org.openqa.selenium.NotFoundException; @@ -445,6 +446,25 @@ public static void deleteDir(File dir) } } + public static void renameDir(Path sourceDir, String newDirName) + { + LOG.info("Renaming " + sourceDir + " to " + newDirName); + checkFileLocation(sourceDir.toFile()); + Assert.assertTrue(sourceDir + " does not exists.", sourceDir.toFile().exists()); + + try + { + String separator = File.separator; + Path newDir = Paths.get(sourceDir.toString().substring(0, sourceDir.toString().lastIndexOf(separator)) + separator + newDirName); + Files.move(sourceDir, newDir); + LOG.info("Rename successful."); + } + catch (IOException e) + { + LOG.info("WARNING: Exception renaming directory -- " + e.getMessage()); + } + } + private static void checkFileLocation(File file) { try diff --git a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java index 2887ed479e..814fb4a362 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -1,11 +1,11 @@ package org.labkey.test.tests.assay; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.SystemUtils; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; import org.labkey.api.util.FileUtil; -import org.labkey.test.BaseWebDriverTest; import org.labkey.test.Locator; import org.labkey.test.TestFileUtils; import org.labkey.test.categories.Assays; @@ -19,6 +19,8 @@ import java.io.File; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.Instant; /** * Issue 54156: Regression test to ensure a reasonable error message is shown when an assay design references @@ -49,18 +51,19 @@ public void testMissingParentDirectoryRegression() throws Exception getArtifactCollector().dumpPageSnapshot("TransformScript_Added"); assayDesignerPage.clickSave(); - // Now delete the parent dir to ensure we handle it reasonably - TestFileUtils.deleteDir(parentDir.toFile()); - - int count = 1; - while (!FileUtils.isDirectory(parentDir.toFile()) && count <= 5) + // Now delete, or rename, the parent dir to ensure we handle it reasonably + if (SystemUtils.IS_OS_WINDOWS) + { + // Deleting directories on Windows is not always reliable, try renaming as an alternative. + String newName = "Not-Here-" + Instant.now().getEpochSecond(); + TestFileUtils.renameDir(parentDir, newName); + } + else { - sleep(1_000); TestFileUtils.deleteDir(parentDir.toFile()); - count++; } - Assert.assertFalse(String.format("Directory %s not deleted.", parentDir.toString()), + Assert.assertFalse(String.format("Directory %s is still present.", parentDir), FileUtils.isDirectory(parentDir.toFile())); // Attempt to import data and verify a reasonable error message is shown From 438d0b1e5884275b2749aa3b8738056ba29b14f7 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Wed, 25 Mar 2026 12:10:49 -0700 Subject: [PATCH 10/15] Reverting another debug statement. Change test to just do a rename and not a delete. --- src/org/labkey/test/TestFileUtils.java | 18 +++++++++++++++--- .../AssayTransformMissingParentDirTest.java | 15 ++++----------- src/org/labkey/test/util/RReportHelper.java | 2 +- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/org/labkey/test/TestFileUtils.java b/src/org/labkey/test/TestFileUtils.java index e2dd84f3ab..e9d4a1baa3 100644 --- a/src/org/labkey/test/TestFileUtils.java +++ b/src/org/labkey/test/TestFileUtils.java @@ -446,16 +446,28 @@ public static void deleteDir(File dir) } } + /** + * Rename a directory. + * @param sourceDir the directory to rename + * @param newDirName the new name for the directory + */ public static void renameDir(Path sourceDir, String newDirName) { - LOG.info("Renaming " + sourceDir + " to " + newDirName); + LOG.info("Renaming {} to {}", sourceDir, newDirName); + + // Check if the directory is outside the test enlistment. checkFileLocation(sourceDir.toFile()); + Assert.assertTrue(sourceDir + " does not exists.", sourceDir.toFile().exists()); try { + // Get the separator appropriate for the given OS. String separator = File.separator; - Path newDir = Paths.get(sourceDir.toString().substring(0, sourceDir.toString().lastIndexOf(separator)) + separator + newDirName); + int lastIndex = sourceDir.toString().lastIndexOf(separator); + Path newDir = lastIndex <= 0 ? + Paths.get(separator + newDirName) : + Paths.get(sourceDir.toString().substring(0, lastIndex) + separator + newDirName); Files.move(sourceDir, newDir); LOG.info("Rename successful."); } @@ -472,7 +484,7 @@ private static void checkFileLocation(File file) if (!FileUtils.directoryContains(getLabKeyRoot(), file)) { // TODO: Consider throwing IllegalArgumentException - LOG.info("DEBUG: Attempting to delete a file outside of test enlistment: " + getLabKeyRoot()); + LOG.info("DEBUG: Attempting to delete / rename a file outside of test enlistment: " + getLabKeyRoot()); } } catch (IOException ignore) { } diff --git a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java index 814fb4a362..a2a8fb0458 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -51,17 +51,10 @@ public void testMissingParentDirectoryRegression() throws Exception getArtifactCollector().dumpPageSnapshot("TransformScript_Added"); assayDesignerPage.clickSave(); - // Now delete, or rename, the parent dir to ensure we handle it reasonably - if (SystemUtils.IS_OS_WINDOWS) - { - // Deleting directories on Windows is not always reliable, try renaming as an alternative. - String newName = "Not-Here-" + Instant.now().getEpochSecond(); - TestFileUtils.renameDir(parentDir, newName); - } - else - { - TestFileUtils.deleteDir(parentDir.toFile()); - } + // Now rename the parent dir to ensure we handle it reasonably. Deleting directories on Windows is not always + // timely, renaming the directory will have the same effect. + String newName = "Not-Here-" + Instant.now().getEpochSecond(); + TestFileUtils.renameDir(parentDir, newName); Assert.assertFalse(String.format("Directory %s is still present.", parentDir), FileUtils.isDirectory(parentDir.toFile())); diff --git a/src/org/labkey/test/util/RReportHelper.java b/src/org/labkey/test/util/RReportHelper.java index c33d886458..cf9d788431 100644 --- a/src/org/labkey/test/util/RReportHelper.java +++ b/src/org/labkey/test/util/RReportHelper.java @@ -160,7 +160,7 @@ public boolean executeScriptDirectly(String script, String expectedLines, boolea return checkScriptOutput(scriptOutput, expectedLines, failOnError); } - public boolean checkScriptOutput(String scriptOutput, String expectedLines, boolean failOnError) + private boolean checkScriptOutput(String scriptOutput, String expectedLines, boolean failOnError) { if (failOnError && doesScriptProduceError(scriptOutput)) return false; From 98d027221f533fe372ba4a5dce19a885e5d8402d Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Wed, 25 Mar 2026 12:27:17 -0700 Subject: [PATCH 11/15] Implementing code review feedback from claude. --- src/org/labkey/test/TestFileUtils.java | 25 ++++++------------- .../AssayTransformMissingParentDirTest.java | 6 ++--- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/org/labkey/test/TestFileUtils.java b/src/org/labkey/test/TestFileUtils.java index e9d4a1baa3..07e1cd0e07 100644 --- a/src/org/labkey/test/TestFileUtils.java +++ b/src/org/labkey/test/TestFileUtils.java @@ -451,30 +451,21 @@ public static void deleteDir(File dir) * @param sourceDir the directory to rename * @param newDirName the new name for the directory */ - public static void renameDir(Path sourceDir, String newDirName) + public static void renameDir(Path sourceDir, String newDirName) throws IOException { LOG.info("Renaming {} to {}", sourceDir, newDirName); // Check if the directory is outside the test enlistment. checkFileLocation(sourceDir.toFile()); - Assert.assertTrue(sourceDir + " does not exists.", sourceDir.toFile().exists()); + Assert.assertTrue("Directory does not exist: " + sourceDir, sourceDir.toFile().exists()); - try - { - // Get the separator appropriate for the given OS. - String separator = File.separator; - int lastIndex = sourceDir.toString().lastIndexOf(separator); - Path newDir = lastIndex <= 0 ? - Paths.get(separator + newDirName) : - Paths.get(sourceDir.toString().substring(0, lastIndex) + separator + newDirName); - Files.move(sourceDir, newDir); - LOG.info("Rename successful."); - } - catch (IOException e) - { - LOG.info("WARNING: Exception renaming directory -- " + e.getMessage()); - } + Path newDir = sourceDir.getParent() != null + ? sourceDir.getParent().resolve(newDirName) + : Paths.get(newDirName); + Files.move(sourceDir, newDir); + + LOG.info("Rename successful."); } private static void checkFileLocation(File file) diff --git a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java index a2a8fb0458..286435dfbb 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -1,7 +1,6 @@ package org.labkey.test.tests.assay; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.SystemUtils; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -19,8 +18,7 @@ import java.io.File; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; -import java.time.Instant; +import java.util.UUID; /** * Issue 54156: Regression test to ensure a reasonable error message is shown when an assay design references @@ -53,7 +51,7 @@ public void testMissingParentDirectoryRegression() throws Exception // Now rename the parent dir to ensure we handle it reasonably. Deleting directories on Windows is not always // timely, renaming the directory will have the same effect. - String newName = "Not-Here-" + Instant.now().getEpochSecond(); + String newName = "Not-Here-" + UUID.randomUUID(); TestFileUtils.renameDir(parentDir, newName); Assert.assertFalse(String.format("Directory %s is still present.", parentDir), From d5b909a98ce142b42aa6a49dac354d11c39c6092 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Wed, 25 Mar 2026 12:50:55 -0700 Subject: [PATCH 12/15] More claude code review feedback. --- src/org/labkey/test/TestFileUtils.java | 7 +++++-- .../assay/AssayTransformMissingParentDirTest.java | 10 +++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/org/labkey/test/TestFileUtils.java b/src/org/labkey/test/TestFileUtils.java index 07e1cd0e07..d56fc3253c 100644 --- a/src/org/labkey/test/TestFileUtils.java +++ b/src/org/labkey/test/TestFileUtils.java @@ -450,8 +450,9 @@ public static void deleteDir(File dir) * Rename a directory. * @param sourceDir the directory to rename * @param newDirName the new name for the directory + * @return return the path to the renamed directory */ - public static void renameDir(Path sourceDir, String newDirName) throws IOException + public static Path renameDir(Path sourceDir, String newDirName) throws IOException { LOG.info("Renaming {} to {}", sourceDir, newDirName); @@ -465,7 +466,9 @@ public static void renameDir(Path sourceDir, String newDirName) throws IOExcepti : Paths.get(newDirName); Files.move(sourceDir, newDir); - LOG.info("Rename successful."); + LOG.info("Renamed {} to {}", sourceDir, newDir); + + return newDir; } private static void checkFileLocation(File file) diff --git a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java index 286435dfbb..17106223f3 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -46,17 +46,20 @@ public void testMissingParentDirectoryRegression() throws Exception assayDesignerPage.goToBatchFields().removeAllFields(true); // add by path so the absolute path is stored; this allows reproducing the missing parent dir scenario assayDesignerPage.addTransformScript(transformFile); - getArtifactCollector().dumpPageSnapshot("TransformScript_Added"); assayDesignerPage.clickSave(); - // Now rename the parent dir to ensure we handle it reasonably. Deleting directories on Windows is not always + // Rename the parent dir to ensure we handle it reasonably. Deleting directories on Windows is not always // timely, renaming the directory will have the same effect. String newName = "Not-Here-" + UUID.randomUUID(); - TestFileUtils.renameDir(parentDir, newName); + Path renamedDir = TestFileUtils.renameDir(parentDir, newName); Assert.assertFalse(String.format("Directory %s is still present.", parentDir), FileUtils.isDirectory(parentDir.toFile())); + // Delete the renamed directory as a cleanup step. Since the directory has been renamed, the slow delete on Windows + // will not cause the test to fail. + TestFileUtils.deleteDir(renamedDir.toFile()); + // Attempt to import data and verify a reasonable error message is shown String importData = """ VisitID\tParticipantID\tComment @@ -94,6 +97,7 @@ public void testMissingParentDirectoryRegression() throws Exception // Verify we land on the run details page and can see the run name (no transform needed) new AssayRunsPage(getDriver()).clickAssayIdLink("fixedAssayImport"); + } } From 8c258c91cf382a7e8ccbaf2f6a19a4c63fbd5130 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Thu, 26 Mar 2026 16:25:11 -0700 Subject: [PATCH 13/15] Code review feedback. --- src/org/labkey/test/TestFileUtils.java | 3 ++- .../test/tests/assay/AssayTransformMissingParentDirTest.java | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/org/labkey/test/TestFileUtils.java b/src/org/labkey/test/TestFileUtils.java index d56fc3253c..892ae635b8 100644 --- a/src/org/labkey/test/TestFileUtils.java +++ b/src/org/labkey/test/TestFileUtils.java @@ -478,7 +478,8 @@ private static void checkFileLocation(File file) if (!FileUtils.directoryContains(getLabKeyRoot(), file)) { // TODO: Consider throwing IllegalArgumentException - LOG.info("DEBUG: Attempting to delete / rename a file outside of test enlistment: " + getLabKeyRoot()); + LOG.info("DEBUG: Attempting to delete / rename a file, {}, outside of test enlistment {}.", + file, getLabKeyRoot()); } } catch (IOException ignore) { } diff --git a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java index 17106223f3..8c968a5b38 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -53,9 +53,6 @@ public void testMissingParentDirectoryRegression() throws Exception String newName = "Not-Here-" + UUID.randomUUID(); Path renamedDir = TestFileUtils.renameDir(parentDir, newName); - Assert.assertFalse(String.format("Directory %s is still present.", parentDir), - FileUtils.isDirectory(parentDir.toFile())); - // Delete the renamed directory as a cleanup step. Since the directory has been renamed, the slow delete on Windows // will not cause the test to fail. TestFileUtils.deleteDir(renamedDir.toFile()); From b5e19ed032d957e956028763f5b33211b6da9252 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Thu, 26 Mar 2026 16:30:14 -0700 Subject: [PATCH 14/15] Remove unused imports. --- .../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 8c968a5b38..717bab20ca 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -1,7 +1,5 @@ package org.labkey.test.tests.assay; -import org.apache.commons.io.FileUtils; -import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; import org.labkey.api.util.FileUtil; @@ -94,7 +92,6 @@ public void testMissingParentDirectoryRegression() throws Exception // Verify we land on the run details page and can see the run name (no transform needed) new AssayRunsPage(getDriver()).clickAssayIdLink("fixedAssayImport"); - } } From c7a960bc61e05554de0055c7d578194a7628d92a Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Thu, 26 Mar 2026 16:37:59 -0700 Subject: [PATCH 15/15] Adding back assert that folder has been renamed. --- .../test/tests/assay/AssayTransformMissingParentDirTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java index 717bab20ca..137b6844a1 100644 --- a/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java +++ b/src/org/labkey/test/tests/assay/AssayTransformMissingParentDirTest.java @@ -1,5 +1,7 @@ package org.labkey.test.tests.assay; +import org.apache.commons.io.FileUtils; +import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; import org.labkey.api.util.FileUtil; @@ -51,6 +53,9 @@ public void testMissingParentDirectoryRegression() throws Exception String newName = "Not-Here-" + UUID.randomUUID(); Path renamedDir = TestFileUtils.renameDir(parentDir, newName); + Assert.assertFalse(String.format("Directory %s is still present.", parentDir), + FileUtils.isDirectory(parentDir.toFile())); + // Delete the renamed directory as a cleanup step. Since the directory has been renamed, the slow delete on Windows // will not cause the test to fail. TestFileUtils.deleteDir(renamedDir.toFile());