Skip to content

Commit bba2a97

Browse files
committed
coverage for Issue 50774
1 parent d2f55d4 commit bba2a97

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

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

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.labkey.test.pages.admin.UsageStatisticsPage;
1414
import org.labkey.test.pages.assay.AssayImportPage;
1515
import org.labkey.test.pages.assay.AssayRunsPage;
16+
import org.labkey.test.pages.pipeline.PipelineStatusDetailsPage;
1617
import org.labkey.test.params.FieldDefinition;
1718
import org.labkey.test.params.assay.GeneralAssayDesign;
1819
import org.labkey.test.util.RReportHelper;
@@ -219,6 +220,74 @@ public void testEnableTransformForUpdate() throws Exception
219220
assaysWithTransformScripts > 0);
220221
}
221222

223+
// Issue 50774
224+
@Test
225+
public void testCancelAsyncAssayTransformJob() throws Exception
226+
{
227+
String transformCancelFile = "importCancelTransform.R";
228+
String importCancelTransformAssay = "importCancelTransformAssay";
229+
String transformContent = """
230+
library(Rlabkey);
231+
232+
run.props = labkey.transform.readRunPropertiesFile("${runInfo}");
233+
234+
run.data.file = labkey.transform.getRunPropertyValue(run.props, "runDataFile");
235+
run.output.file = run.props$val3[run.props$name == "runDataFile"];
236+
error.file = labkey.transform.getRunPropertyValue(run.props, "errorsFile");
237+
238+
# sleep a bit before writing the table, give the test time to cancel the job before it is complete
239+
labkey.setDebugMode(TRUE);
240+
print("before");
241+
Sys.sleep(4);
242+
print("after");
243+
labkey.setDebugMode(FALSE);
244+
245+
if (file.exists(run.data.file)) {
246+
run.data = read.delim(run.data.file, header=TRUE, sep="\\t", check.names = FALSE);
247+
run.data$M2 = 111;
248+
run.data$TransformType = "${transformOperation} testing";
249+
write.table(run.data, file=run.output.file, sep="\\t", na="", row.names=FALSE, quote=FALSE);
250+
}
251+
252+
""";
253+
File transformFile = TestFileUtils.writeTempFile(transformCancelFile, transformContent);
254+
var protocolResponse = new GeneralAssayDesign(importCancelTransformAssay)
255+
.setDataFields(List.of(new FieldDefinition("M2", FieldDefinition.ColumnType.Decimal),
256+
new FieldDefinition("TransformType", FieldDefinition.ColumnType.String),
257+
new FieldDefinition("Comment", FieldDefinition.ColumnType.String)), true)
258+
.createAssay(getProjectName(), createDefaultConnection());
259+
goToProjectHome();
260+
261+
var assayDesignerPage = ReactAssayDesignerPage.beginAt(this, getProjectName(), protocolResponse.getProtocolId(),
262+
"general", getURL().toString());
263+
assayDesignerPage.addTransformScript(transformFile, true);
264+
assayDesignerPage.setBackgroundImport(true);
265+
assayDesignerPage.clickSave();
266+
267+
StringBuilder importDataBuilder = new StringBuilder("VisitID\tParticipantID\tComment\n");
268+
for (int i=1; i<=10; i++)
269+
importDataBuilder.append(String.format("%d\t%d\tComment-%d\n", i, i, i));
270+
271+
clickAndWait(Locator.linkWithText(importCancelTransformAssay));
272+
new AssayRunsPage(getDriver()).getTable().clickHeaderButton("Import Data");
273+
clickButton("Next");
274+
var importPage = new AssayImportPage(getDriver());
275+
importPage.setNamedInputText("name", "cancelTransformTestImport");
276+
importPage.setNamedTextAreaValue("TextAreaDataCollector.textArea", importDataBuilder.toString());
277+
importPage.clickSaveAndFinish();
278+
279+
waitAndClickAndWait(Locator.linkWithText("Assay upload RUNNING"));
280+
PipelineStatusDetailsPage pipelineStatusDetailsPage = new PipelineStatusDetailsPage(getDriver());
281+
pipelineStatusDetailsPage.clickCancel();
282+
283+
pipelineStatusDetailsPage.showLogDetails();
284+
pipelineStatusDetailsPage.assertLogTextContains("INFO : Attempting to cancel as requested",
285+
"INFO : Interrupting job by sending interrupt request.",
286+
"ERROR: The following error was generated by the assay upload",
287+
"INFO : Failed to complete task 'org.labkey.api.assay.pipeline.AssayUploadPipelineTask'");
288+
resetErrors();
289+
}
290+
222291
@Override
223292
protected String getProjectName()
224293
{

0 commit comments

Comments
 (0)