Groovy support for JMeter

| | bookmark | email | 11 comments
After watching the excellent presentation on performance testing given by Goranka Bjedov (QA Engineer at Google), my interest on JMeter increased exponentially. Planning for some testing of InfoQ upcoming features (oh yes, we have some surprises on our bag for this beginning of the year) I have giving it a try.
It took me a while to identify the elements involved while creating a scenario (by the way: JMeter name for scenarios: Test plan is not quite correct) and the components to be used, but the online documentation is not so bad.
However, while playing around I have felt the need to create some monitoring scripts (n.b. I am still working on this part). JMeter offers support for BSF and BSH out of the box, but having in mind the release of Groovy 1.0 I thought to try to add Groovy support to JMeter.
So, last night, armed with the Groovy intro chapter from The Definitive Guide to Grails and Groovy in Action [note], I have started my attempt. The task wasn't easy, but not because of some obvious reasons: different parts of JMeter are using different approaches (like being contributed by completely unrelated people that never looked at the existing code), so deciding how should I write it took me a while. However, in a couple of hours I am having an working version: 2 main classes that are reused for different UI parts and respectively for Groovy integration, an interface to allow extensions and a couple of almost empty classes for each component : PreProcessor, PostProcessor, Listener and Sampler. Total size: 12 classes, aprox. 300 usefull LOC, cca. 500 TLOC. The UI is not so nice but follows the existing JMeter UI (I haven't done any GUI work in the last couple of years so I am a bit rusty [smile/]). After doing this job, I think most pieces are pretty reusable so integrating other scripting solution like JRuby or even the JDK6 scripting support would be a very easy task.
I am thinking to contribute this code to either JMeter or a Groovy module, but I still need to decide. Meanwhile, let me know if you are interested in this integration.

PS: I am still wondering how can I get my hands on any of the Manning books. I have pinged them a couple of times, submitted a complaint but never heard back from them.

Update: thanks to Dierk Koenig (author of Groovy in Action) and Olivia (from Manning) the above problem seems to start having a solution. Thanks.