Load testing Seam-Booking with JMeter

There are some interesting  blog posts on how to do load tests of seam applications with JMeter. Since a few days, I had to train a customer in doing load tests. We had a pilot project, that already had a testable application with its own JMeter tests scripts, however, because of lack of time, the application was not ready, and I had to fallback on another solution.

My favorite demo application is Seam Booking application which is a “bogus” Hotel Reservation Web Application developed with Seam (using JSF, Seam and Hibernate). The application is pretty and nice to use. It uses Ajax and just like all JSF applications it rely on javax.faces.viewState’s that are exchanged along pages. Because it uses Seam, there is also a “Conversation ID” that is hold from pages to others.

The perfbench project

I was very happy to see that an existing project is already doing as Seam load test through a performance comparison between presentation frameworks. However, the scripts were pretty old, and I performed a few modification to make them work.

Adapt booking.jmx to Seam 2.2

There are only minor changes, mainly on 2 pages:

  • The main.seam page does not refer anymore to a main form, instead it is named “searchCriteria”. First step, was to modify the request’s parameters to match this new name.
  • On book.seam page , CreditCardNameDecorate:* attributes have been renamed to creditCardNameDecorate (with a lower case c). Second step, is to rename all the form’s attributes related to this decorator.

Missing Ajax call to validate the booking

Even after performing these changes, it is impossible to make the JMeter test plan perfom correctly. It always end with the following error message:

[code]Caused by: javax.faces.application.ViewExpiredException: viewId:/confirm.seam – View /confirm.seam could not be restored.[/code]

An important detail about seam, all the application’s pages submitted via a POST are followed by a redirect to avoid double submit issues. This can be confusing, because every POST leads to an HTTP 302 error: Moved temporarily. In fact, this redirect gives the location of the next page in navigation and provides the updated cid through url.

After investigation, using firebug and Results Tree Listeners in JMeter, I realized that the “POST booking details” step was not performing correctly. Indeed, instead of returning an HTTP 302 code like all the other posts, it was only doing a GET on a the book.seam view. Then, the confirm.seam view was failing because of an incoherent “cid”.

So, I finally ended to look deeper in Seam Booking Code to determine why the redirection does not occur at this time. This is due to the following code in the WEB-INF/pages.xml:

d="true">
  Book hotel: #{hotel.name}
  
    
    
  

An Ajax call is probably missing in the JMeter test case that performs the hotelBooking validation. Anyway, simply commenting out the condition around the redirection solves my problem.

  


Finally, here is the resulting booking.jmx file to load test Seam Booking.

Interesting links

http://kalgtech.blogspot.com/2009/10/load-testing-seam-application-using.html
http://ptrthomas.wordpress.com/2009/01/14/seam-jsf-vs-wicket-performance-comparison/
http://ptrthomas.wordpress.com/2009/09/14/perfbench-update-tapestry-5-and-grails/
http://seamframework.org/Community/JMeterSeamCidProblem
http://blog.milamberspace.net/index.php/jmeter-pages/jmeter-test-de-charges-dun-site-web-mode-demploi/jmeteriser-son-scenario-fonctionnel