You are on page 1of 108

.

A Basic Walkthrough

How Jmeter Works

How To Install
Install Java
Download Jmeter

Directory Structure

What is our Input/Output

Test Elements

Thread Group
Controllers
Samplers
Timers
Assertions
Configuration Elements
Pre-Processor Elements
Post-Processor Elements

Execution order of Test Elements

Configuration elements

Pre-Processors

Timers

Sampler

Post-Processors (unless SampleResult is null)

Assertions (unless SampleResult is null)

Listeners (unless SampleResult is null)

Test Plan
Bluiding A Test Paln in Jmeter

Test Plan

Name : Name of Test Plan


Comment : Desription of Test Plan
User Define Variables : Specify Custome Variables
Run thread group consecutively : Run 2nd thread after completion of
1st and so on.
Functional Test Mode : Help to do functional testing.
Add Directory : For Adding Extenal Jar file

Thread Group

Introduction
Thread group elements are the beginning points of any test plan.
All controllers and samplers must be under a thread group.
Other elements, e.g. Listeners, may be placed directly under the test
plan.
Thread group element controls the number of threads JMeter will
use to execute your test.
controls for a thread group allow you to set:
number of threads
ramp-up period
number of times to execute the test.

Ramp Up Periode
Each thread will execute the test plan in its entirety and completely
independently of other test threads.
Ramp Up Periode : If 10 threads are used, and the ramp-up period
is 100 seconds, then JMeter will take 100 seconds to get all 10
threads up and running. Each thread will start 10 (100/10) seconds
after the previous thread was begun.
Loop Count Defines the number of times to execute the test.

Action to be taken after sampler error


Continue : Continue the test even after a sampler error.
Start Next Thread group :Start execute next thread gruop after is
any sampler error occurs.

Stop Thread : Stop executing test immediate if error occurs.


Sheduler Configuration
You can configure the start and end time of running the test.

Other Thread Group Elements


jp@gc - Stepping Thread Group.
jp@gc - Ultimate Thread Group.
setUp Thread Group.
tearDown Thread Group.
bzm - Arrivals Thread Group.

bzm - Free-Form Arrivals Thread Group.


bzm - Concurrency Thread Group.

Stepping Thread Group

This is a custom Thread Group.


Preview Graph.
Increase and Decrese load by portions.
Initial threads can be delayed.

Ultimate Thread Group

Infinite number of schedule records.


Separate ramp-up time, shutdown time, flight time for each shedule
record
Load preview graph

Concurrency Thread Group


Maintain the level of concurrency.
Unlike standard Thread Group, it won't create all the threads upfront,
so extra memory won't be used

Arrivals Thread Group

This TG also use to achive the concurrency

Free-Form Arrivals Thread Group

Provide idea of "arriving users" .


free-form schedule capabilities.

SetUp and TearDown Thread


setUp Thread Group

tearDown Thread Group

A special type of ThreadGroup


that can be utilized to perform
Pre-Test Actions. The behavior
of these threads is exactly like a
normal Thread Group element.
The difference is that these type
of threads execute before the
test proceeds to the executing of
regular Thread Groups.

A special type of ThreadGroup


that can be utilized to perform
Post-Test Actions. The behavior of
these threads is exactly like a
normal Thread Group element.
The difference is that these type
of threads execute after the test
has finished executing its regular
Thread Groups.

Configuration Element
Configuration elements can be used to set up defaults and
variables for later use by samplers these elements are
processed at the start of the scope in which they are found,
i.e. before any samplers in the same scope.

List

CSV Data Set Config


FTP Request Defaults
DNS Cache Manager
HTTP Authorization Manager
HTTP Cache Manager
HTTP Cookie Manager
HTTP Request Defaults
HTTP Header Manager
Java Request Defaults
JDBC Connection Configuration
Login Config Element
LDAP Request Defaults
LDAP Extended Request Defaults
TCP Sampler Config
User Defined Variables
Random Variable
Counter
Simple Config Element

CSV Data Set Config

We can achive parameterization using this element.


Use under the the targeted sampler with POST request.

Test Plan for CSV Data Set Config

HTTP Cookie Manager

The cookie manager stores and sends cookies just like a web browser.

If you have an HTTP Request and the response contains a cookie, the
Cookie Manager automatically stores that cookie and will use it for all future
requests to that particular web site.

HTTP Cache Manager


The HTTP Cache Manager is used to add
caching functionality to HTTP requests
within its scope to simulate browser cache
feature

HTTP Request Defaults

This element lets you set default values that your HTTP Request controllers use. For example, if
you are creating a Test Plan with 25 HTTP Request controllers and all of the requests are being
sent to the same server, you could add a single HTTP Request Defaults element with the "Server
Name or IP" field filled in. Then, when you add the 25 HTTP Request controllers, leave the
"Server Name or IP" field empty. The controllers will inherit this field value from the HTTP Request
Defaults element.

HTTP Header Manager

The Header Manager lets you add or override HTTP request header
We record Header manager along with each HTTP request

Java Request Defaults


The Java Request Defaults component
lets you set default values for Java testing

JDBC Connection Configuration

Use while Building DB Testing to connect with respective DB .

Login Config Element


The Login Config Element lets you add or
override username and password settings
in samplers that use username and
password as part of their setup

LDAP Request Defaults


The LDAP Request Defaults component
lets you set default values for LDAP
testing

LDAP Extended Request Defaults


The LDAP Extended Request Defaults
component lets you set default values for
extended LDAP testing

TCP Sampler Config


The TCP Sampler Config provides default
data for the TCP Sampler
The TCP Sampler opens a TCP/IP
connection to the specified server. It then
sends the text, and waits for a response.
Example:::https://jmeterworld.wordpress.c
om/2009/02/19/tcp-sampler-jmeter/

User Defined Variables


This functionality allows changing
parameters in multiple places of test-plan
The User Defined Variables element lets
you define an initial set of variables, just
as in the Test Plan.

Random Variable

The Random Variable Config Element is used to generate random numeric


strings and store them in variable for use later.

Counter

The counter can be set up so


that it increments
independently for each user i.e.
thread, or it can be a global
counter

JMeter
Preprocessors

What is it

Pre-processor executes some action before making Sampler Request.

Preprocessors are used to modify the Samplers in their scope.

It Helps to create scenario (Parameterization,Correlation and


Synchronization).

Add a Preprocessor

Create HTTP request

Send to server

Google

Correlation

Correlation is an important aspect in creation of performance testing scripts.


It fetches dynamic values from earlier responses and supplies those values
to subsequent requests.

Its a procedure to fetch a dynamic value from earlier responses and using
that value in subsequent steps

Correlation in JMeter can be achieved using Regular Expression


Extractor,HTTP URL Rewriting etc. post-processor.

Why exactly we need correlation ?


Suppose we have recorded a scenario in which

User enters login details and click OK button


Home page opens and user take further actions
Now, if we just playback this script, the test will fail even for a single user.
This is because of the authentication mechanism used. When we login to a
website, session variables are dynamically created. These session
variables are passed to the subsequent requests and help validation and
authentication of the actions performed. So, one cannot just record and
playback the requests having these variables. Here, we need to correlate
the web requests with the dynamic variables. And for correlation, we need
to use the "Regular Expression Extractor" which makes use of regular
expressions.

Parameterization
Using Parameterization we can execute one test plan for more than one user at the
same time. This is a method of generalizing an action for many users.

Suppose, we have to do load test of a search engine, for that we record the search
scenario. Now to do effective load test, we can't just playback the script for say 100
users. We should simulate 100 users that search for 100 different things. Here we
need parameterization, wherein we can have a CSV file that contains 100 different
items. Now instead of the static search item that we had recorded in our script we can
include the search items from the CSV file dynamically.
We will use 'CSV Data Set Config'. to achieve this in JMeter

Synchronization
Coordinating two or more activities, devices, or processes in time.
We need Synchronization to avoid the condition like deadlock.
We can achieve synchronization by using 'Interthread commincation Preprocessor'
and 'Synchroization Timer'

List

BeanShell
BSF
HTML Link Parser
HTTP URL Rewriting Modifier
Regex user Parameter
User parameter
JDBC
Interthread Communication .
JSR233
Raw Data Source

Beanshell
We wrire arbitary code which execute before sample request we can use it
for parameterization

Process a ramdom number

BSF

We will use javascript to send value to sampler

Test Plan

HTML Link Parser


HTML Link Parser is a preprocessor which parses the HTML
response got to extract data[links, values] and use it dynamically.

Step 1: Create Thread Group under the Test plan .

Step 2: Using proxy setting Record the Form/page[Eg :


SignUp.aspx] which you want to test .

Step 3: Then Add the SignUp.aspx pages[Both Method : Get and


Method :Post ] as child to the Thread Group .

Step 4: Create a CSV file for the fields like User ID , Password ,
e-Mail , Name. Add a CSV Data Config[Config element] to use
the values in Jmeter from the CSV file .

Step 5: Add the SignUp.aspx[Method : GET] Under the Thread Group . So that HTML
Link Parser can fetch the value from the HTTP response .

Step 6: Add the Signup.aspx[Method : POST] as the next HTTP request in the same
Thread Group.

Step 7: Add the HTTP Link Parser as the child of the


HTTP .request[Signup.aspx[Method : POST].

Step 8: Set the Variable in the Send parameter as Request in


theSignUp.aspx[Method : POST] panel accordingly the CSV file we have already
created .

Step 9: Now its time to use the value we parsed using the HTML Link Parser .
Just put [.*] excluding the braces as the Value to the Dropdown field name in the
SignUp.aspx[Method : POST] Panel.

Step 10 : Add a Listener [Preferably View Result in Tree ]. Then Execute/Run the Test
plan .
Consider a simple example: let's say you wanted JMeter to "spider" through website
under test, parse link(check all links on the page) and return the HTML. You would
add some action such as "HTML link parser" to your controller before creating an
HTTP request.

HTTP URL Rewriting Modifier

We can achive correlation

If your web application uses URL rewriting rather than cookies to


save session information, then you'll need to do a bit of extra work to
test your site.

To respond correctly to URL rewriting, JMeter needs to parse the


HTML received from the server and retrieve the unique session ID.
Use the appropriate HTTP URL Re-writing Modifier to accomplish
this Simply enter the name of your session ID parameter into the
modifier, and it will find it and add it to each request

If "Cache Session Id?" is checked, then the last found session id will
be saved, and will be used if the previous HTTP sample does not
contain a session id.

Example
There is a sample
request contains
parameters in url,
what url rewiting do
extract parameter
form url and process
the request as using
session argument
name

Regex user Parameter

Regular Expression Extractor in JMeter is used to fetch values from source


code and use it in subsequent requests. It is one of the most used
components in JMeter as it allows simple ways to handle dynamic requests

Lets create a test plan

Run your script for single user. It may pass or fail.

In View Result Tree listener, go to the response data from where we need to fetch quantity
information. Lets assume the quantity information in response data is <input type=text
name=quantity value=2>. We would be fetching value 2 from this response using regular
expression.

Add Regular Expression Extractor post-processor under this request. We need to now write a
regular expression to fetch quantity value. It can be written as <input type=text name=quantity
value=(.+?)>.

Supply the above expression in Regular Expression field of Regular Expression Extractor postprocessor. Provide other details as well. Template as $1$, Match No. as 1, Default Value as Not
Found, Reference Name as Quantity. Refer this link to know more about all these fields in
Regular Expression Extractor.

Thats it. You can now pass quantity information in subsequent requests using Reference Name
Eg. ${Quantity}.

If you are facing any issue while fetching value, try debugging your regular expression

User Parameter

Allows the user to specify values for User Variables specific to individual threads.
allows you to specify a series of values for any User Variable
Data driven testing with Jmeter user parameters
Based on your requirements, you can select either CSV config element or User
Parameter pre-processor element for data driven testing. If you have large number of
variables to be parameterized, CSV config is the best option.

Example

Add 2 parameters using "user parameter" preprocesser.

Send those paremeter with HTTP login request.

Interthread Communication

Interthread Communication is what where two or more threads are sharing


some information.
There are 4 functions for inter-thread communication in JP@GC: fifoPut,
fifoGet, fifoPop, fifoSize.
fifoPut puts a value into queue and returns stored value. fifoPut parameters:
Name of FIFO queue
String to put into queue
fifoPop gets the string value from FIFO and removes that item from the
queue. If the item not exists, fifoPop will block and wait until some thread
will make fifoPut into queue. There is timeout for such waits, by default it is
unlimited, and can be changed by setting
kg.apc.jmeter.functions.FifoTimeout property into value of seconds. If the
timeout has been exceeded, "INTERRUPTED" value is returned.

fifoGet differs from fifoPop, it does not wait for data, just returns empty string if
no data present in queue. Also it does not remove values from the queue.
fifoSize returns the number of items in the queue.

fifoPop, fifoGet and fifoSize parameters:

Name of FIFO queue


Variable name to store value

Timers

By default, JMeter sends the request without pausing between each request. In that
case, JMeter could overwhelm your test server by making too many requests in a
short amount of times This may not be what you want. We can add a timer element
which will allow us to define a period to wait between each request.

Timers allow JMeter to delay between each request which a thread makes. Timer can solve
the server overload problem.Also, in real life visitors do not arrive at a website all at the
same time, but at different time intervals. So Timer will help mimic the real time behavior.
We use Timers to implement the THINK TIME

List

Constant Timer

Gaussian Random Timer

Uniform Random Timer

Constant Throughput Timer

Synchronizing Timer

Poisson Random Time

JSR223 Time

BeanShell Time

BSF Time

Constant Timer

A constant Timer will introduce a fixed delay between consecutive


requests of the same thread.

Uniform Random Timer

Uniform random timer delays


each user request for a
random amount of time

Gaussian Random Timer

Gaussian Random Timer is same as Uniform Random


Timer except that in the latter the variation after constant
offset has a liner distribution, where in the former, the
variation around constant offset has a gaussian curve
distribution.

Constant Throughput Timer

This timer allows us to keep total throughput constant.Although the Timer is called the Constant
Throughput timer, the throughput value does not need to be constant. This value can be changed
during a test.

Synchronizing Timer

Synchronizing Timer will synchronize requests of multiple threads. it


will add delays between requests such that all threads fire at the
same time thus creating heavy load bursts on your application

Poisson Random Time

This timer pauses each thread request for a random


amount of time, with most of the time intervals
ocurring near a particular value. The total delay is
the sum of the Poisson distributed value, and the
offset value.

BSF Timers
Bean Scripting Framework is a set of Java
classes that is provides scripting
language support within Java applications,
and access to Java objects and methods
from scripting languages)

Logic Controllers

List

Simple
Loop
Once Only
Interleave
Random
Random Order
Throughput
Runtime
If
While
Switch
ForEach
Module
Include
Transaction
Recording

Simple controller

Simple Controller is a container,


holds user request. It does not
provide any customization,
randomization or change of
loop count, etc as other logic
controllers do.

This controller only helps in


binding the child samples.

Loop Controller

Loop Controller makes the user request run


specified number of times or run forever
If we put a HTTP request under the Loop
controller then the specific sample will be
loop to the server for the same number of
time. We can do ENDURANCE TEST using
this Logic controller.
TIP : Difference between the LOOP in the
Thread group and Loop controller is that the
scope for former is the thread group
completely but the later is specific to the
HTTP request which are child to that.
Loop Controller creates a situation where
user request runs either; for limited time or
forever, which is better explained in the
figure,

Once Only Controller

The Once Only Controller will make its child samplers run only once
per thread i.e. only in the first loop.

Interleave Controller
Interleave Controller will make one of
samplers contained in it run in each loop
of the thread and but the samplers in each
loop will be in sequential order.

Random Controller
Random Controller makes all the user requests
run in random order in each loop period.

Random Order Controller


The Random Order Controller is much like
a Simple Controller in that it will execute
each child element at most once, but the
order of execution of the nodes will be
random

Throughput Controller

Runtime Controller
Runtime Controller's function is same as
its name. You can set time in Runtime
Controller to stop jmeter requests
execution after defined time

If Controller
The If Controller allows the user to control
whether the test elements below it (its children)
are run or not

While Controller
The While Controller runs its children until
the condition is false

Switch Controller
Under Swicth controller you will execute
only specified sample

ForEach Controller

Module Controller
JMeter Module
Controller allows
switching between
pieces of the test plan
The goal of Module
Controller is to add
modularity to JMeter.

Include Controller
The include controller is designed to use
an external jmx file
It is created to utilize an external test plan.
This controller permits you to utilize
multiple test plans in JMeter.

Transaction Controller

The Transaction Controller generates an additional sample which


measures the overall time taken to perform the nested test elements.
a Logic Controller which generates a virtual sample to measure
transaction times.

Generate additional total sample after nested samples


Generate parent sample containing nested samples

Allows to aggregate results for many samplers


Useful for Ajax
Can be used as an alternative for downloading embedded
elements

Recording Controller
The Recording Controller is a place holder
indicating where the proxy server should record
samples to

Liteners

A listener is a component that shows the


results of the samples.

List

Agreegate Graph
Agreegate Report
Assersion Results
Beanshell
BSF
Comparision Assersion Visulizer.
Backend
Generate Summary Results
Graph Results
Active Threads Overtime
Autostop
Bytes Throughput Overtime
Composite Graph
Transaction Throughput vs Threads
Transaction/ Sec
Mailer Visulizer
Monitor Results
Summary Report
View Result in Table

Console Status Logger


DBMon Samples Collector
Flexible File Writer
Graph Generator
Hits/sec
JMXMon samples Collector
Page Data Extraxtor
PerfMon Mertic Collector
Responce Code /sec
Response Latencies over time
Response Time Distribution
Response Time Overtime
Response Time Percentiles
Response Time vs Threads
Response Time Graph
Save Response to a file
Simple Data Writer
JSR223 Listener
View Result in Tree

Result Metric for Performence Tesing

Throuthput
Latency
Response Time
Elapsed time
Connect Time
Median
90% Line (90th Percentile)
Standard Deviation
Resource Utilization
Hits
Users
Errors
Bandwidth

Metric Definations

Throughput - Throughput is calculated as requests/unit of time. The


time is calculated from the start of the first sample to the end of the
last sample.

Latency - Time to taken to recive first byte of a request.


A latency is the duration between the end of the request and the
beginning of the server response.

Response Time - Time to taken to recive last byte of a request.

Users - Represents the number of active users at a certain minute


of the test.

Hits - Number of hits per second.

Metric Definations

Resource Utilization - Resource usage (processor, memory, network I/O, disk I/O)
on the server.

Connect Time. JMeter measures the time it took to establish the connection,
including SSL handshake. Note that connect time is not automatically subtracted from
latency.

Median is a number which divides the samples into two equal halves. Half of the
samples are smaller than the median, and half are larger. [Some samples may equal
the median.] This is a standard statistical measure. same as the 50th Percentile

90% Line (90th Percentile) is the value below which 90% of the samples fall. The
remaining samples too at least as long as the value. This is a standard statistical
measure.

Standard Deviation is a measure of the variability of a data set. This is a standard


statistical measure.

View Result Tree

It use to see what request is


sending and what is the exact
resonse by a sampler.

Along with it also shows the


response time and latency of that
sampler.

It also provide to test your


regex,xpath and css/JQuery.

Avoid during load test ,use only in


case of script verification.

View Result in Table

Shows the results of test plan in


tabular format

Along with latency and size of


each sampler

Summary Report & Agrregate Report


Show results inTabular View

Error %.
Throughput.
Min,Max & Average response.
Average Bandwidth.
Median
Standerd Deviation.

Save Response to a file


It will create a file of the response Data.
The primary use for this is in creating functional tests.
The file extension is created from the document type.
Very usefull to test file download scenario.

Response Time

Response Time vs Threads

Response Times Distribution


Shows number of responses(samples)
againts response time.

Response Times Percentiles


Shows response time againts
percentage thread.

Response Codes per Second


as name suggested
Response Time Graph

Shows response time againts active


threads.

Response Time Overtime


Shows response time againts overtime.

Response Latencies over time

Shows response Latencies againts


time.

Work as Response Time Overtime


graph

Others

Active Threads Over Time


Shows number of active VUser during test run.

Transaction Throughput vs Threads


Shows trasaction/sec agains users.
maximum possible number of transactions based on number of

users accessing the application.

Transactions per Second


Number of transactions per second for each sampler.
Display succesfull and fail transactions.

Server Hits per Second


Display the hits generated by the test plan to the server per second

Bytes Throughput Over Time


Display the amount of bytes sent and received by JMeter during the load test

Assersion Results.
Shows the faliure of any request along with it's label.

Comparision Assersion Visulizer.


Shows the results of any Compare Assertion elements.

Autostop.
AutoStop used when you want to stop test on some runtime criteria.
average response time
average latency
error rate.

Graph Liteners

Agreegate Graph
Display average response time vs thread

Graph Results
Shows average response time alogwith median throughput and deviation.

Composite Graph
Shows several different graphs composed to one

Graph Generator

Monitoring Liteners
DBMon Samples Collector
JMXMon samples Collector
PerfMon Mertic Collector

Scripting Liteners
Beanshell
BSF
JSR223 Listener

You might also like