Monday, December 1, 2008

Java TOAST - A New Java Multi-threaded Test Automation Tool

I've been working on a Java test scripting tool which I have been using to help automate running of crash recovery tests for the JBossTS Web Service Transactions code. The tool is provisionally called Java TOAST (Thread Orchestration Automation Scripting Tool) and I'm planning to submit a presentation on it to Java One. I have also made the code available under the LGPL.

The tool uses the Java agent package (java.lang.instrumentation) and the ASM bytecode manipulation library to insert side effects or synthetic throws/returns at chosen 'trigger' points in application or JVM method code. Side effects are scripted using a simple event condition action language and the conditions and actions can include arbitrary invocations of Java code including reference to objects in context at the trigger point. Rules can be used to force 'wrong' or 'unexpected' behaviours to occur and to trace subsequent execution and propagate further side effects which ensure that it follows the desired path.

The tool is particularly oriented towards dealing with the problems involved in convincing non-deterministic, multi-threaded code to run in a reliable and repeatable manner. So, the rule language provides a suite of builtins which can be invoked from conditions or actions to orchestrate thread execution. These builtins implement operations such as delays, waits and notifies, countdowns, rendezvous, etc and can be used to make sure that events in the thread's life cycle happen with the desired timings or orderings. However, the tool is more general than this. So, even if you are just interested in running a simple single-threaded test it provides a very flexible means of scripting errant and aberrant behaviours in arbitrary application and/or JVM code and managing and tracing subsequent execution.

If anyone wants to take a look at the tool and or give it a road test the sources are in the JBossTS repository. There is a README which explains the basics plus how to compile and run the tool and a more complete user guide.
.
Post a Comment