Sunday, September 11, 2005

JMeter in Web Application Testing

JMeter in Web Application Testing

Last week I was discussing with Kartik on performing JMeter performance testing on the Ripple product. They were facing some difficulties in HTTP session handling in their JMeter test plan. This conversation allowed me to refresh my knowledge on this powerful testing framework. So I thought of making a note about JMeter on my blog. This will be a quick and short overview on some of the general JMeter capabilities.

When considering the non functional testing we often hear people talking about different types of tests. Some of those are “Load testing”, “Performance Testing” or “Stress Testing” on the application under test. First of all it is important to know the meaning and differences of these terms used in application testing.

a) Load testing is applying a heavy load on the application and monitors the behavior of it under a heavy load.

b) Performance testing may be carried out to ensure the application responses within acceptable timing on the requests it’s getting.

c) Stress testing is for ensuring fault tolerance capability of the application. For an example we may restart the database while application is in operation and check whether the application can recover under such a condition.

Let's have a quick look at JMeter. JMeter can be readily used in Load and performance testing. The test scripts we may create are called ‘Test Plans’. We can have create several test plans to test our application. These test plans can be used even as automated tests by running JMeter in non graphical mode.

There are several types of elements in a JMeter test plan. JMeter uses ‘Samplers’ to produce requests. It has ‘Logic controllers’ so we can control our test flow with them (e.g. to repeat a request). ‘Listeners’ are used to capture test results. Delays may be introduced by its ‘Timer’ elements.

Session handling is an important activity in any practical test plan. For general cookie based sessions we may use a Cookie manager to keep our cookie based session information across the requests. But when URL-Rewriting is used in session management we have to use “HTTP URL-Rewriting Modifier’ to keep session information across requests.

For me one of the most interesting elements in JMeter is its assertions. For an example returning HTTP 200 by our server doesn’t always mean that the request has been served successfully. That may be a user friendly error message returned by the server when a critical error occurred. We need to be more specific and probably wants to check the returned html to validate the server response. This is made possible with ‘Assertions’ in JMeter.

When configuring our test plan sometimes we face difficulties in simulating the exact browser behavior with JMeter. One handy tool that would help here is ‘TCPMON’ tool comes with Axis utilities. We can capture and compare http communications of JMeter with the communications of browser easily with this tool.

It is really interesting seeing JMeter as a part of a automated testing environment together with JUnit and HTTPUnit test frameworks…

18 comments:

creed said...

A beginners tutorial to JMeter at http://javaboutique.internet.com/tutorials/JMeter/index-1.html

88Pro said...

I came accross this handy tool which works on top of httpunit.

http://webtest.canoo.com/manual/samples.html

However the test cases are specified in XML format instead of classes. I have not tried it out myself but if it works it makes a very good case for the QA members to automate some of their tests like the smoke test.

I see many time once a deployment is done, a request to QA goes to do a smoke test and all they need to do is run a script in most of the web applications.

Anonymous said...

good content.. for starter still more information is required, can u give some example links..........
VASEEM

Hasith Yaggahavita said...

check this

http://javaboutique.internet.com/tutorials/JMeter/

Anonymous said...

I am using Jmeter for performance testing. I need to check queues to make sure that all the process in the queue is completed. Also checked that the total number of users are present in the table on a specified page. Is this possible in Jmeter as I cannot seem to find a solution?

Anonymous said...

More detailed not about the Proxy server settings configuration would be better, as even after trying out different options it is not working

Hasith Yaggahavita said...

If you need to use JMeter for browser traffic sniffing, here are the steps:
1) Open Jmeter
2) Right click 'workbench' and select Add->Non Test Elements->HTTP Proxy server
3) Observe the listner port of the proxy server is 8080. Because some applications often make use of this port lets change it to 8083.
4) Click 'Start' to start the proxy server
5)Open IE browser and go to Tools->Internet Options->Connections->LAN Settings thewn specify 'localhost' as the Address and '8083' as the Port.
6) Now on the address bar of the browser type the webpage address you want to access. e.g. http://hasith.net/.
7) Observer the 'HTTP Request Samplers' automatically created for you on the JMeter tree view.

Hasith Yaggahavita said...

"I am using Jmeter for performance testing. I need to check queues to make sure that all the process in the queue is completed. Also checked that the total number of users are present in the table on a specified page. Is this possible in Jmeter as I cannot seem to find a solution?"

Have you tried writing your own custom samplers and assertions on this purpose?

Anonymous said...

Hi Hasith,

If you need to use JMeter for browser traffic sniffing, here are the steps:

I followed your steps but not created
Http Request Sampler

Anonymous said...

If you want to know how to do parametrization,follow the links


http://jmeterworld.wordpress.com/2008/12/16/simple-parameterization-in-jmeter/
http://jmeterworld.wordpress.com/2008/12/15/parametrization-method1/

Anonymous said...

Hi I am learning to use Jmeter.
I got jakarta-jmeter-2.3.1
I am trying to use monitors.after searching i followed how to connect to the tomcat server and other related stuff. my problem is every time i get dead process only in the monitor results graph. does the status will be detected automatically by the tool once we connect to the tomcat... or do we need to do any changes in the code..................plz help

Anonymous said...

Hi I am learning to use Jmeter.
I got jakarta-jmeter-2.3.1
I am trying to use monitors.after searching i followed how to connect to the tomcat server and other related stuff. my problem is every time i get dead process only in the monitor results graph. does the status will be detected automatically by the tool once we connect to the tomcat... or do we need to do any changes in the code..................plz help

gaurav said...

HI, I am using jmeter2.3.2 in which i doing parameterization using CSV Data set config element and in my CSV file I have provided 5 user/passwords. I have recorded the login script through badboy then exported it into jmeter.
My problem is that when I am proving up to 1-9 users it is running them without giving error.
If I am providing 10 user in main thread group it is generating error in listeners.(If I am providing 9 user then it is taking 5 user that I have provided in CSV file and 4 blank user I don't know why?)
Please somebody help.

Anonymous said...

I am new to JMeter.

Is there an easy
solution to the '401' red warnings especially when testing *.gifs & CSS/images??

I know you can exclude pattern all *.gifs but is there an easy way to test images without getting these '401' red status warnings???

Please help.
Thanks,
Shakeel

Hasith Yaggahavita said...

Hi all,

I'm not hands-on with JMeter these days. Therefore some of very specific JMeter questions are out of my current knowledge scope.

I'm sorry if I disappoint you by not answering some of the questions. I will try my best to answer wherever I can.

Thanks for your understanding!
Hasith

Anonymous said...

Hi,
I am using jMeter to load test my Https server.
I'm using linux m/c which doesn't have UI access. I have to use non-gui commands to run the jMeter.
I have installed jre 1.5, Do I need to install JSSE still ??

I have client certificate in .cer file, How do I specify the jMeter to use this file.
Can you tell me the steps to follow. It will be great help

Thanks
WhiteA

Hasith Yaggahavita said...

SSL support is available in JRE 1.4 and above. You done need to install JSSE separately.

Refer below link to learn how to test with SSL enabled applications.

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#SSL_Manager

Dzmitry said...

Also an article about how to build test-plan for database testing