Skip to content

Commit 4f42872

Browse files
committed
Allow trigger scripts to customize their own timeout
1 parent 6a4b986 commit 4f42872

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var console = require("console");
2+
3+
function beforeInsert(row, errors) {
4+
// This is intended to force a timeout exception:
5+
if (this.extraContext.scriptTimeout && !!this.extraContext.simulateScriptTimeout) {
6+
console.log("Simulating script timeout!")
7+
java.lang.Thread.sleep(100 + (this.extraContext.scriptTimeout * 1000))
8+
}
9+
}

src/org/labkey/test/tests/SimpleModuleTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ protected void doVerifySteps() throws Exception
288288
doTestCustomLogin();
289289
doTestFkLookupFilter();
290290
doTestMetadataOverrideForCustomQuery();
291+
doTestScriptTimeout();
291292
}
292293

293294
@LogMethod
@@ -346,6 +347,19 @@ private void doTestMetadataOverrideForCustomQuery()
346347

347348
}
348349

350+
@LogMethod
351+
public void doTestScriptTimeout() throws Exception
352+
{
353+
InsertRowsCommand insertCmdM = new InsertRowsCommand("vehicle", "Manufacturers");
354+
Map<String, Object> rowMapM = new HashMap<>();
355+
rowMapM.put("Name", "I_Should_Not_Succeed");
356+
insertCmdM.addRow(rowMapM);
357+
insertCmdM.setExtraContext(Map.of("scriptTimeout", 3, "simulateScriptTimeout", true));
358+
RowsResponse respM = insertCmdM.execute(createDefaultConnection(), getProjectName());
359+
360+
// TODO: test result
361+
}
362+
349363
private int getRowCount(String schemaName, String tableName)
350364
{
351365
pushLocation();

0 commit comments

Comments
 (0)