Archive

Posts Tagged ‘load testing’

Jmeter: Monitor Results

July 17, 2009 2 comments

Monitor Results is one of the many listeners that Jmeter offers free at its best.
This is a reporting tool that allows us to view the status of our server while the test is being executed.
But note that this listener works only for Tomcat5 or newer versions.

Once you have created/recorded your scripts:

1. Add Listener>Monitor Results
2. Add Sampler>HTTP Request and placed it before all your other samplers
3. Change the Name field to “Server Status”.
4. Enter the IP address or Hostname
5. Enter the port number
6. Set the Path field to “/manager/status” if you’re using Tomcat.
7. Add a request parameter named “XML” in uppercase. Give it a value of “true” in lowercase.
8. Check “Use as Monitor” at the bottom of the sample.
9. Add Config element>HTTP Authorization Manager
10. In the HTTP Authorization Manager, leave the base URL blank
11. Enter your web server’s login(username and password)

These should make your Monitor Results works and allows you to view the Health, Load, Memory and Thread lines as you run your load test. FTW!

Jmeter: Add “Cookie Manager”

June 29, 2009 10 comments

Objective: Create an automated scripts using JMeter that will do the following scenarios in a healthcare system application and use the same scripts to register more patients.

1. admin user login

2. register new patient

3. save registration

4. verify new patient in the patient’s list

5. admin logout

Issue: Changing values of an automated scripts does not add the new value to the database on test playback.

Here’s how we do it:

1. In our JMeter testplan, add a Non-Test Element>Proxy Server in the WorkBench to do the initial recording.

2. Add Constant Timer under your HTTP Proxy with value “S{T}” to capture the actual delay during recording.

3. Start your browser, enable proxy in your browser and start recording.

4. After one action is recorded, JMeter generates a Header Manager which allows you to customize what information JMeter sends in the HTTP request header. Make a copy of the Header Manager from the first sample and paste it as a child of  your thread group before all the HTTP requests, this will serve as the default header manager to be used.  Continue recording until all the scenarios are finished.

5. After recording, update the samples to a more descriptive names just like this:

Recorded scripts

At this point, new user created during recording is successfully added in the database when manually validated. Next steps will help us parameterized and set new values for our new user.

6. To parameterized your login account, go to your thread group, add a Config Element > User Defined Variable. Then set values for login and password that are accepted in the appliication (in my case, login = admin; password=admin)

Login parameterization

7. Update your “login” sample by changing Value to ${Variable_name}

login

8. Now go to your “fill out express registration form” sample and edit new values for last name, first name and middle name.

new user

8. Run playback or hit CTRL-R to add to automatically add the new user values.

Actual: Scripts are successfully run but new user is not added in the user list

Expected: Succesfully run the script and add the new user in the user list

Solution: After futher readings of JMeter forums and wikis, I bumped across this post, and in its one reply suggest to add a Cookie Manager. True enough after adding a Config Element > Cookie Manager, set its Policy to “Compatibility,” and rerun the scripts, the new user value we edited was successfully added in the user list.

cookie manager

Cookie Manager, saves the day!

JMeter 101: Using HTTP Proxy to Record your Test

March 18, 2009 48 comments

HTTP Proxy Server is a non-test element feature of JMeter which enables user to record scripts from a real browser.

1. Add Thread Group in your Testplan

Add Thread Group

2. Add Proxy Server to WorkBench

  • Add Non-test Elements > HTTP Proxy Server

add-proxy1

  • Set “Target Controller” where your recorded scripts will be added

proxy-target

  • Set URL patters to INCLUDE or EXCLUDE

    • .* – all
    • .*\.png – all png images
    • .*\.gif – all gif images
    • .*\.jpg – all jpg images
    • .*\.php
    • .*\.jsp
    • .*\.html
    • .*\.htm
    • .*\.js
  • Click START

proxy-exinclude

3. Set your Browser to use Proxy (I used IE7 browser)

  • Go to Tools > Internet options > Connections > LAN Setting
  • Select “proxy server”
  • Set Address = localhost; Port = 8080

lan

4. Browse your application and record

5. In HTTP Proxy Server, click “Stop” when finished

To verify if recording was successful, you should be able to see HTTP requests generated under your “Target Controller”

More Tricks:

Add a Constant Timer to the HTTP Proxy Server node to record your think-time (right-click on the “HTTP Proxy Server” node and choose “Add,” “Timer,” and then “Constant Timer.”)

Next change the “Thread Delay” on the timer to “${T}” to tell the proxy server to record your time rather than to add a constant time for each request.

JMeter 101: Analyze your Test Results

March 18, 2009 1 comment

To help you analyze your testing efforts, JMeter provides different types of Listeners. Listeners are JMeter components that show the results of the samples. The results can be shown in the form of a tree, tables, graphs or simply a log file.

Here are some of the listeners that I’ve tried:

1. Graph Full Results / Graph Result

2. Aggregate Graph

3. Aggregate Result

4. Summary Result

5. View Result in Table

6. View Result Tree

JMeter 101: Write your first load test script

March 18, 2009 4 comments

Going through this session, assumes that you have successfully set-up JMeter distribution(latest version is 2.3.2) in your box, but if not, it’s never too late you can still check it out on my previous post – JMeter 101: Introduction.

Using the friendly GUI of Jmeter, lemme me help you explore and write your first load test script.

1. Go to “bin” folder of your JMeter distribution, double click “jmeter.bat” file

2. Simulate users by adding a Thread Group.

Add Thread Group

Add Thread Group

thread-group

  • Set Number of threads(users) = 5, => the number of concurrent users we want to simulate
  • Set Ramp-up Period(in seconds) = 10,  => the amount of time it will take to create the threads/users

In this example, Jmeter will create a thread every 2 seconds (10/5). If ramp-up period is set to “0″ or blank, Jmeter will create all the threads immediately.

  • Set Loop count = 1, => the number of times to execute the test


3. Simulate web requests by adding Sampler > HTTP Request

Add HTTP Request

Add HTTP Request

http-request2

  • Set a descriptive HTTP request name
  • Set Server name or IP = http://www.yahoo.com
  • Set Path = “/”, which is Yahoo Homepage

4. To help us analyze the results, add the following listeners

Add Listener

Add Listener

  • Listener > Aggregate Report
  • Listener > View Result Tree

5. Save your script with .jmx extension

6. Go to Run > Start (ctrl + R)

JMeter 101: Introduction

March 18, 2009 3 comments

I. What is Jmeter?

Apache JMeter is a 100% pure Java desktop application designed to load test functional behavior and measure performance. JMeter may be used to test performance both on static and dynamic resources . It can be used to simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load types.

II. Why choose Apache Jmeter?

There are wide load testing tools to choose from. There are open source tools like Open STA, http_load, The Grinder, Siege including Jmeter. And commercial tools like LoadRunner, WebLoad etc. But why would we pick Jmeter from this list? Lemme help you decide…

  1. Jmeter is FREE! – no monthly charges
  2. Easy to install and use – 100% JAVA with friendly GUI
  3. Feature rich
  • Record from browser
  • Load test data from files
  • Add logic, variables and functions
  • Run distributed testing from multiple machines
  • Variety of protocols: Web – HTTP, HTTPS; SOAP; Database via JDBC; LDAP; JMS; Mail – POP3

III. What are the requirements of Jmeter?

  1. Java Virtual Machine – JMeter requires a fully compliant JVM 1.4 or higher
  2. Operating System
  • Unix (Solaris, Linux, etc)
  • Windows (98, NT, XP, etc)
  • OpenVMS Alpha 7.3+

IV. Where to get Jmeter?

Download from http://jakarta.apache.org/site/downloads/downloads_jmeter.cgi

I choose the binary version of 2.3.2 release for my Windows XP box.

V. How to run JMeter?

  1. Unzip Jmeter distribution file to desired path
  2. Go to “bin” directory
  3. Run Jmeter file
  • Windows : double click jmeter.bat
  • Mac : double click ApacheJmeter.jar
  • Unix : double click jmeter.sh OR run ./jmeter from the command line

From Jmeter’s friendly GUI, we can now create, record and configure scripts for our load test.

For comprehensive tutorials visit http://jakarta.apache.org/jmeter/

Follow

Get every new post delivered to your Inbox.