1

This question may seem weird, so here is why we need it. Our test infrastructure relies on Fitnesse framework with different fixtures. One of the fixtures is running a groovy script like that:

cmd /c groovy_runner.bat myScript.groovy Param1 ParamN

groovy_runner.bat:

set JAVA_OPTS="-Xmx1024M"
set groovyCP="<list of jars>"
groovy -cp %groovyCP% %*

So, we have a process tree like java (Fitnesse) => cmd (cmd /c groovy_runner.bat) => java ("C:\Program Files\Java\jre6\bin\java.exe" "-Xmx128m" -Dprogram.name="" -Dgroovy.home="C:\groovy-2.1.3\bin.." -Dgroovy.starter.conf="C:\groovy-2.1.3\bin..\conf\groovy-starter.conf" -Dscript.name="c:\Scripts\WebDriver\myScript.groovy" "-Xmx1024M" -classpath "C:\groovy-2.1.3\bin..\lib\groovy-2.1.3.jar" org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --conf "C:\groovy-2.1.3\bin..\conf\groovy-starter.conf" --classpath "" myScript.groovy Param1 ParamN

And sometimes groovy script hangs. Currently, we don't understand the reason why it hangs, but just wanted to know if it possible to somehow restrict the time the groovy script may be running. Say, is it possible to somehow specify in the groovy script or groovy config files that it is expected to run no more than 15 minutes, otherwise it has to be forcibly stopped?

Is it doable?

Thanks, Racoon

Racoon
  • 951
  • 3
  • 14
  • 32
  • 3
    `TimedInterrupt` annotation should be a good choice here. Take a look here: http://stackoverflow.com/questions/10417146/is-there-a-groovy-equivalent-of-the-ruby-timeout-module Remember that this is AST transformation which adds time checks in loops and method invocations and it may affect performance - if it's important it may be better to write another script which kills your groovy script. – Paweł Piecyk Feb 17 '15 at 19:22

1 Answers1

1

I don't know of any way to do this within Groovy's config. Better would be write another script, which waits fifteen minutes and then kills the first one if it exists.

David Seiler
  • 9,557
  • 2
  • 31
  • 39