|
13 | 13 | import org.labkey.test.pages.admin.UsageStatisticsPage; |
14 | 14 | import org.labkey.test.pages.assay.AssayImportPage; |
15 | 15 | import org.labkey.test.pages.assay.AssayRunsPage; |
| 16 | +import org.labkey.test.pages.pipeline.PipelineStatusDetailsPage; |
16 | 17 | import org.labkey.test.params.FieldDefinition; |
17 | 18 | import org.labkey.test.params.assay.GeneralAssayDesign; |
18 | 19 | import org.labkey.test.util.RReportHelper; |
@@ -219,6 +220,74 @@ public void testEnableTransformForUpdate() throws Exception |
219 | 220 | assaysWithTransformScripts > 0); |
220 | 221 | } |
221 | 222 |
|
| 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 | + |
222 | 291 | @Override |
223 | 292 | protected String getProjectName() |
224 | 293 | { |
|
0 commit comments