Thursday, 3 September 2009

Using JMeter with GWT

I have tried to use JMeter to load test a GWT application. I recorded the script, but when I replayed it, all the GWT calls failed. I couldn't find much to help on the internet. Eventually I came up with the following solution

  1. Create a top level thread group. 
  2. Create a child simple controller and add samplers to fetch all the GWT files
  3. Create a second child simple controller. To this add a HTTP Header Manager. In this, add an entry for "Content-Type" with a value of "text/x-gwt-rpc; charset=utf-8". To this controller add all the GWT rpc calls
  4. For any further http traffic calls, add more simple controllers to contain the samplers
The header manager ensures that all http samplers at that level, send the given headers. In this case is corrects the content type for all GWT RPC calls, allowing them to work. You still need to split GWT RPC calls from "normal" http traffic by keeping each in their own controller.

With that done, the jmeter script worked as required. Now I just have to fix the application code ;-)

Update: if you record the interactions, some client posts may contain thestring \\. Java tries to interpret this, so you will have to update this to be \\\\. I found this easiest to do by saving the jmeter script, opening a test editor and then using search/replace

2 comments:

  1. Hello Chris,
    I am new on this blog, I have to test an application builded in GWT that contains forms, so,I have to fullfill this forms to perfom the test.
    How should I configure JMeter.
    thanks in adavence

    ReplyDelete
  2. The way I did it was

    1) setup jmeter as a proxy
    2) record a simple interaction with the server
    3) replay the script in jmeter
    4) find where it fails, and update the script to parse out any values required e.g. session id etc
    5) repeat from step 3) until it works
    6) repeat from step 2) adding more and more complex interactions

    It can be done. It is not easy. It might take some time, but when it works, you can perform some really useful load testing against the gwt app. Good luck

    ReplyDelete