Testing using Apache jMeter Test web applications using Apache Jmeter and BadBoy to stress test and measure performance.

Pubblicato da lentux-informatica il

  •  
  •  
  •  
  •  
  •  

Introduction

Apache jMeter is a popular utility used for performance testing.

It can be used to test a wide variety of applications, including Web Applications, LDAP Servers, FTP Servers etc.

As I had to use it recently to performance test a Struts-based web application, I thought I’d write up a short introduction to using it.


Approfitta di tutte le offerte di Amazon per i tuoi regali di Natale con sconti fino al 60% su moltissimi prodotti!!!


Thread Groups

The first thing you’ll need to know is about Thread Groups.

These contain a variety of requests which a typical user might make (something like a use case). For example, if you were testing a ‘Change Password’ function then the sequence of steps would be Login -> Go to ‘Change Password’ page -> Submit new password.

This would be represented by a thread group. If your application is simple you may not need more than one thread group.

Indeed if it’s more complicated you may want several thread groups to test all the use cases.


Approfitta delle offerte di Natale di Ebay con sconti fino al 60% su moltissimi prodotti e SPEDIZIONE GRATUITA!!!

Overview

Once you’ve created a new Thread Group you’ll need to create some HTTP Requests to model the sequence of pages your user will navigate.

This, of course, will depend on the exact page parameters and so on that you have set up. It’s probably best if I run through an example – I’ll demo how to set up a login test.

How to use

Assume you have a login system set up, so that you have to POST a username and password to http://server/demo/Login.do.

This then sets your session cookie and sends a redirect to /demo/Home.do.

  • Start up JMeter, and create a new Thread Group under ‘Test Plan’
  • Right Click on the Thread Group you have just created, and select: ‘Add -> Config Element -> HTTP Cookie Manager’. This is very important if your application depends on J2EE sessions (which is likely, if you need to test a login).
  • Add another item from the same menu – ‘HTTP Request Defaults’. This lets you set up a series of defaults which apply to every HTTP Request (unless you override them), meaning that you don’t have to type out the server name for each request! In this example, you would set the server name to ‘server’ and leave the rest of the fields as their defaults.
  • Add an HTTP Request (Add -> Sampler -> HTTP Request) to the Thread Group
  • Change the method to POST, and the path to “/demo/Login.do”
  • Add two parameters to the request (underneath “Send parameters with the request”) – username and password. In our example it doesn’t really matter what the username and password are set to!
  • You’ll want to validate that when you login, you are actually taken to the home page. This can be done using ‘assertions’. Right-Click on the HTTP Request, and select ‘Add -> Assertions -> Response Assertion’. Then, on the assertion properties screen, make sure ‘URL Sampled’ is selected and then click on the ‘add’ button at the bottom. Enter the pattern “Home.do” in the “Patterns to test” section.

Conclusion

An important disadvantage of JMeter is that cannot record pages that rely on the Protocol (HTTPS), the only way to bypass this limitation is for example use another tool opensourcce called Badboy.

While Badboy offers some elementary load testing features, to do real stress testing you often need much more.

Rather than trying to offer all of the features of a complete load testing product, Badboy integrates with a free, open source product called JMeter.

JMeter is run by the Apache Software Foundation and is free and open source.

Badboy integrates with JMeter by letting you save your scripts in the JMeter file format so that you can open them and run them in JMeter.

This support means that you can use Badboy to record your scripts to do functional testing, and then save the same script as a JMeter file to do performance testing using the full power of JMeter!




Exporting a script in JMeter format is very simple.

Simply record your script and navigate to File->Export to JMeter.

If you want read my guide concact me.


  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •