Tip

Recording and running software load tests with JMeter

Mike Kelly

    Requires Free Membership to View

In this tip we will take a look at recording performance tests using JMeter. In a previous tip on Running your first load test with JMeter, we looked at manually adding a Sampler for Yahoo Search. However, you may find that for more complicated test scenarios, you'll want the ability to record tests. This will help you save time when creating Samplers for your test plans. One easy way is to create multiple Samplers and record with them simultaneously.

Author's note:
This tip was written using JMeter 2.3.4 running on Java 1.5.0_20. The version of FireFox used in 3.0.14. The application used in this article is Yahoo Search since it's a publically available application. The example uses a very low load to simply illustrate how JMeter works. If you would like to test with larger loads, do not use Yahoo. Instead, please use your own application.

Setting up a JMeter proxy

If you're not familiar with setting up a proxy, a quick explanation might be in order. A proxy simply acts as an intermediary for client requests to the various servers from which you've requested resources. By setting up a JMeter proxy, you're allowing JMeter to record the requests made and use the information derived to create a test plan.

If you're following along with this example, you'll want to start with a new test plan. To do this, add a proxy by right-clicking on WorkBench. Next click Add -> Non-Test Elements -> HTTP Proxy Server (as shown in figure 1 below).

Once the HTTP Proxy Server is added, select it in the left navigation tree, change the port from "8080" to "9090" and ensure the checkbox labeled "Retrieve All Embedded Resources from the HTML Files" is checked. Your settings should look similar to those shown in figure 2 below.

Next you'll need to set up your browser to point to a proxy server. For FireFox, you can find these settings by opening Preferences, selecting the Advanced icon, then the Network tab, and clicking the "Settings…" button. This should open a proxy configuration screen similar to the one shown in figure 3 below.

Select the "Manual proxy configuration" radio button and enter an HTTP Proxy of localhost on port 9090. When finished, click OK and close FireFox preferences.

More JMeter tips
Running your first load test with JMeter
JMeter is a highly recommended tool for load testing open source Java applications, as it supports technologies from HTTPS - SOAP. Learn how run your first JMeter test in this tip.



 

Recording information using the proxy

You should now be set up to record a test using JMeter. To start recording your tests, you'll want to start the JMeter proxy. To do this, navigate to the HTTP Proxy Server in JMeter and click the Start button at the bottom of the screen. This will start up the server.

At this point, JMeter will record anything you do in the browser you configured. Sometimes it's helpful to have two browsers opened. I'll often record tests using FireFox, and then also have an Internet Explorer or Safari browser open on the side so I can look stuff up without recording the transactions in JMeter.

For this tip's example, we'll be testing Yahoo Search. Open a FireFox browser and navigate to http://search.yahoo.com/. Once that page loads, search for "software testing." When the search results are returned, navigate back to JMeter and take a look at what's been recorded. As shown in figure 4 below, you should see a number of recorded Samplers under the WorkBench.

This should be enough for our example, so let's stop the proxy server. To do this, navigate to the HTTP Proxy Server in JMeter and click the Stop button at the bottom of the screen. You're no longer recording. If you're completely done, you'll also want to reset the proxy settings in your browser back to what they were before you set them to the manual configuration.

Making sense of what was recorded

As you look at the list of recorded HTTP requests, you'll want to figure out what you're looking at. At the end of each item name, you'll see a file extension indicating what's being requested. For example, the first few files from Yahoo included a couple of javascript files (.js), a cascading style sheet (.css), and a portable network graphic (.png). These files give you the basic search functionality for the initial page we loaded.

After that, you'll see a number of "gossip-us-sayt" requests. The purposes of those requests might not be immediately obvious, but if you dig in just a bit by selecting one of them, you'll see that the server name these requests go to is " sugg.us.search.yahoo.net". That's the server that provides the spelling suggestions while you're typing (as shown below in figure 5).

After that series of requests, you'll find more javascript images and actual search results coming back. Those files represent the search results page.

At this point, you can move each of these elements from the WorkBench into your Test Plan. You can take all the Samplers recorded or you can select individual Samplers to move up. This allows you to record a series of Samplers, and then mix and match them as needed to create custom scenarios.

As a quick example, add a Thread Group to your test plan and move the first six recorded Samplers up under that Thread Group. Once those have been added, add a View Results Tree Listener as well (as shown in figure 6).

You can now run this test. If you do so (just run one thread for one loop), you'll see six responses come back successfully in the View Results Tree Listener. If navigate those results and look at the response data, you should find the content required to load the Yahoo Search page. The easiest example to recognize is the png file in the third result set shown in figure 7 below.

At this point, you can now customize those Samplers as needed to create the test scenarios necessary to generate your target load.
 

This was first published in November 2009

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.