During test run executions, there is a possibility of tests hanging indefinitely.
User must be able to set time outs for tasks(at least for tasks of type: Test)
No provision to set timeouts.
We queue tests to run in our lab vm's and we have seen situations wherein the lab machines couldn't pick up new tests because of some issues in the tests that got picked up previously and since there is no time outs that can be applied similar to ant's limit task.
Ideally Gradle should also save some thread dump that could be analysed to find what thread got stuck.
Are there any thoughts on this?
We also would like to have timeouts which end a test task "orderly", i.e. publishing everything it has up to now (like junit reports and profiling).
In contrast to #2476 we want this on the Test-task level, not on single tests.
The motivation for this is that our CI system would kill the build if it runs into a (CI imposed) timeout.
This leaves us with no information and a potentially unusable CI node (no cleanup has been done, etc). For most nodes we use stateless nodes, like docker containers, but for some exotic (and usually most problematic) platforms we cannot afford to have throw-away containers (or they are simply not available).
Unfortunately the Test task class is quite closed and does not allow us to inject a custom TestExecutor (similar to RestartEveryNTestClassProcessor) which could handle the timeout stuff.
Probably this is a bit out of scope of this issue, because it's quite specific to the Test task.
In related issue 2476, @oehme recommends using a JUnit5 extension to implement per-test timeout.
I believe this issue should be used to track implementing the concept of timeouts at a higher level, as the title suggests, rather than being test specific as the original post body suggests.
Sometimes for reasons we may or may not have much control over the build has to shell out, via Exec, JavaExec, the worker API, or another mechanism, to other code which may deadlock or just have a while(true)
thrown in to mess with you.
It would be very helpful if Gradle as the orchestrator could provide a timeout+thread dump mechanism to help control & mitigate poorly behaved code that may be involved in a build.
If all Task
s exposed an "after" or "timeout" extension it could look something like this:
task( name: 'fooexec', type: Exec) {
commandLine 'sleep', '60' // 1 minute
after(10, TimeUnit.SECONDS) {
throw new TimeoutException('Sleeping for 1 minute should only take 10 seconds!')
}
}
Most helpful comment
Ideally Gradle should also save some thread dump that could be analysed to find what thread got stuck.