Showing posts with label jmeter. Show all posts
Showing posts with label jmeter. Show all posts

Monday, November 18, 2013

JMeter Tutorial - Writing a Test Plan

In this tutorial, we will write a very simple test plan.

Here are the specs of the Test Application we will run JMeter against:

  • large instance on EC2
  • Ubuntu LTS12.04
  • Tomcat 7
  • Java and Spring


Setting up JMeter on Windows

We will be setting up JMeter on Windows simply because it's easier. Read User Load Testing Simulation - Installing Apache JMeter on Windows 2012 Base.


Creating a Thread Group

Start JMeter by clicking on bin/ApacheJMeter.jar in your install location. You will see in the Tree hierarchy that it has a Test Plan item and a WorkBench item.

Right click on Test Plan -> Add -> Threads (Users) -> Thread Group

The Thread Group tells JMeter how many users and requests it should simulate.

In the Thread Group panel, fill in the following:

Name: Web Users
Number of Threads (users): 10
Ramp-Up Period (in seconds): 0
Loop Count: 5

The above will generate 5 requests for each of the 10 users. Total number of requests is 50.

The Ramp-Up Period defines the time delay which each JMeter will start the user. If Ramp-Up Period is 10 and Number of Threads is 10 then the delay between each user is 1 second. In the above, we have Ramp-Up Period = 0, meaning that all the users will start at the same time.


Add Default HTTP Request Information

Since most requests we are going to make will share some common properties (like IP and port), we will set up some default HTTP Request Information.

Right click on Web Users -> Add -> Config Element -> HTTP Request Defaults.

Fill in your server name (or IP) and port number.


Add Cookies

We will add HTTP Cookies.

Right click on Web Users -> Add -> Config Element -> HTTP Cookie Manager


Adding a HTTP Request

This is where your simulated users will request. We will add a login request. You will need to figure out what are your site's username and password parameters (In my case, it's username and password)

Right click on Web Users -> Add -> Sampler -> HTTP Request

Fill in the following:

Name: Login
Server Name of IP: /
Method: POST

In parameters, click Add.

Add Name=username, Value={your_username}
Add Name=password, Value={your password}

You can add a GET a request similarly as well.


Adding the Graph Results Listener

To observe response time, we can add the Graph Results Listener.

Right click on Web Users -> Add -> Listener -> Graph Results.


Running the Test Plan

In the menu bar, click on Run -> Start

Friday, June 14, 2013

User Load Testing Simulation - Installing Apache JMeter on Windows 2012 Base

Apache JMeter is good for load testing web applications. Our goal of this post is to install JMeter on a EC2 instance.  The reason why we are using Windows is that JMeter has a GUI. It is less work to use it on Windows than Ubuntu.

Specs:

  • Windows 2012 Base
  • m1.large EC2 instance
  • Java Open JDK 1.7

Make a security group called JMeter.  Open the following ports

  • port 3389 for RDP for 0.0.0.0\0
  • all ports for ICMP for the JMeter Group
  • all ports for the JMeter Group

First spin a Windows 2012 Base instance. Use m1.large. Choose a region that your web application machines are located.  Attach to the JMeter security group. Label the instance JMeter Master.

The machine will be generating a password. You will need to wait a bit before you can RDP into the machine.

Once you RDP into the machine, lower the Internet security so you can use the browser.

Go to control panel and turn off all the firewalls. We will

Download the latest JDK. Follow the install wizard.

Download Apache JMeter, and unzip it to a folder (ex. C:\tools\apache-jmeter-2.9).

Download the JMeter Plugins.

Unzip the JMeter Plugins and put the JMeterPlugins.jar into the JMETER_INSTALL_DIRECTORY\lib\ext directory.

Change the following properties in bin\jmeter.properties.
jmeter.save.saveservice.thread_counts=true
If you want to use more than one machine to generate load testing requests, you can change the remote hosts attribute in jmeter.properties and declare the hosts in hosts files. We will set up extract two machines: slave1, slave2

Change the remote_hosts property from
remote_hosts=127.0.0.1
to
remote_hosts=slave1:1099,slave2:1099
Edit C:\Windows\System32\drivers\etc\hosts
127.0.0.1 slave1
127.0.0.1 slave2
Create a test plan.

Create a AMI in the EC2 console.

Start an instance using this AMI. Label this the JMeter Slave.

Try to ping each other and make sure the JMeter Master and Slave can connect to each other. If not, remember to open ICMP in your security group.

Log into the JMeter Slave. Start jmeter-server.bat in the bin folder.

Log into the JMeter Master.

In the hosts file, change slave 1's IP to that of the JMeter Slave.

Start JMeter. Open your test plan. Run -> Remote Start -> slave 1:1009.

You should be able to see the test results.