How to test GWT Apps with JMeter

1,565 views
Skip to first unread message

c

unread,
Mar 31, 2008, 11:14:50 AM3/31/08
to Google Web Toolkit
I've been working through this for the last couple of days, and since
the solution was scattered around the web, I thought it might be
useful to share my experience.

JMeter
This is a load testing application from the Apache guys and it's
great. It can be found at http://jakarta.apache.org/jmeter. I won't
go into test plans as there's plenty of stuff out there about it.

The problem is Ajax type interactions. It works fine with simple http
requests (and plenty of others including SOAP), but once you need to
send stuff to GWT it gets complicated. Luckily there's a solution.

Creating an entry point
My issue was that my GWT app (as I guess is usual), has plenty of
interaction with the server. Each one of those interactions would
have to be a JMeter sampler, which would get unwieldy

I picked up a useful hint from someone who simply extended their
module by creating a test module. The extension could simply have one
extra test method which then called the relevant GWT methods in the
main application.

If you're using Spring, then it's even easier. You can simply create a
new module with one test method and pass the main application GWT hook
(the one which implements your RemoteService interface) in as a bean.

So in summary this is what I had (with Spring):
TestApplicationInterface extends ApplicationInterface ->
testGWTMethod(Map params)
Same for the Async.
TestApplicationImpl implements ApplicationInterface ->
testGWTMethod(Map params)
and is passed ApplicationImpl as a bean.
TestApplication.gwt.xml -> inherits from Application.gwt.xml and has a
TestEntryPoint
TestEntryPoint -> which onModuleLoad() called up the service and
called testGWTMethod()
test.html -> which basically just called the script (actually this is
not needed for JMeter, but is to check it on your browser).


Testing with the browser
I made sure everything worked by running it through the browser, and
inevitably debugging silly mistakes with the GWT hosted mode.

Configuring JMeter
JMeter has one cool function called Http Proxy Server. The idea is
that it acts as a proxy for your browser and can record anything you
do. Very useful to pick up the XmlHttpRequest content. This is what
you need to do to configure it:-
1. Add an Http Proxy to you Workbench. So select 'Workbench', then
'Edit>Add>Non-test elements>Http Proxy Server
2. Give it a port number (like 8090)
3. Get into your browser preferences (For the Firefox lot:
Edit>Preferences... Advanced tab... Network tab... Select Http Proxy
and enter 'localhost' and '8090' in the port or the port you gave in
2. above)
4. Back to JMeter. (You may need to make sure you have at least one
Thread Group). Click Start on the Http Proxy Server.
5. Back to Firefox. Load the test.html page (or whichever page wraps
your GWT entrypoint).
6. Back to JMeter. You'll see a whole list of Http Request objects
appear. (Probably best to stop your proxy and reset in Firefox unless
you want screeds of calls captured).

Using in a test plan
I found I only needed to use one HttpRequest sampler, which was the
one that made the call to my GWT test method. It was obvious by the
URL I had given it as the service entry point. The sampler had a few
things:-
1. The path and encoding were all set up correctly.
2. The GWT serialized data was the first parameter with no parameter
name. Even better, I could use the JMeter variable insertion on it $
{VARIABLE_NAME} where the variable had previously been defined, and
parts of the serialized data was dynamically changed.
3. There was a sub-node called 'Browser derived headers'. That was
great, it included all the headers needed for the call. Note here:-
If there is another header object in the test plan, I found that it
overrode these values. GWT did not like the Content-type coming in
anything but text/plain. I had to disable the other header
definitions.

Hope this helps anyone else figuring their way through this. I'm just
beginning on the testing, so we'll see if once this hurdle is passed,
the results are useful.
Reply all
Reply to author
Forward
0 new messages