View
234
Download
3
Category
Preview:
Citation preview
8/13/2019 JMeter Training Material
1/69
JMeterA Performance Testing Tool
Date:05/01/2010
8/13/2019 JMeter Training Material
2/69
May 13, 20092
Introduction
Definition
JMeter is an Apache Jakarta project that can be used as a load testing tool for
analysing and measuring the performance of a variety of services, with a focus on
web applications.
Why JMeter
JMeter can be used as a unit test tool for JDBC database connection, FTP,
LDAP, WebServices, JMS, HTTP and generic TCP connections. JMeter can also
be configured as a monitor, although this is typically considered an ad-hoc
solution in lieu of advanced monitoring solutions.
8/13/2019 JMeter Training Material
3/69
May 13, 20093
Introduction -Features
100% pure Java Open Source Desktop application.
Designed for performance/functional/load/stress testing.
Extensible- write your own tests.
Pluggable sampler allows unlimited testing capabilities.
Simulate heavy load (application, server and network).
Gives instant visual feedback.
Distributed testing.
Various protocols- HTTP, JDBC, LDAP, SOAP, JMS, FTP.
Multi-platform.
Full multi-threading framework.
Test plans can be stored in XML and can be version controlled.
Caching and offline analysis/ replaying of test results
8/13/2019 JMeter Training Material
4/69
May 13, 20094
JMeter License
JMeter comes under Apache Software License Version 2.0
The Apache Licenseis a free-software license authored by the Apache Software
Foundation (ASF).
The Apache License (versions 1.0, 1.1, and 2.0) requires preservation of the
copyright notice and disclaimer, but it is not a copyleft license.
This means it allows use of the source code for the development of proprietary
software as well as free and open source software.
The complete license details for JMeter can be found here:
http://jakarta.apache.org/jmeter/license.html
8/13/2019 JMeter Training Material
5/69
May 13, 20095
Elements of Test Plan
Thread Group
Logic Controllers
Samplers
Configuration elements
Pre-processor elements
Post-processor elements
Timers
Listeners
Assertions
8/13/2019 JMeter Training Material
6/69
May 13, 20096
Execution Order
Timers
Preprocessors
Samplers
Post-processors
Assertions
Listeners
8/13/2019 JMeter Training Material
7/69
May 13, 20097
Functions and Variables
JMeter functions are special values that can populate fields of any Sampler or other
element in a test tree. A function looks like ${__functionName(var1,var2,var3)}.
A function with no parameter looks like ${__functionName}.
If a function parameter contains a comma, then be sure to escape this with "\",
otherwise JMeter will treat it as a parameter delimiter. Example ${__time(EEE\, dMMM yyyy)}.
Variables are referenced as ${VARIABLE}.
Variable and functions are all case-sensitive.
8/13/2019 JMeter Training Material
8/69
May 13, 20098
What can functions do ?
Two kinds of functions:
user-defined static values (or variables). built-in functions.
User-defined static values allow the user to define variables to be replaced with their
static value when a test tree is compiled and submitted to be run.
This replacement happens once at the beginning of the test run.
Variables cannot be nested.
With built-in functions users can compute new values at run-time based on previous
response data.
These new values are generated fresh for every request throughout the course of thetest.
8/13/2019 JMeter Training Material
9/69
May 13, 20099
Where can functions and variables be used?
Functions and variables can be written into any field of any test component (apart
from the TestPlan). Some fields do not allow random strings because they are expecting numbers, and
thus will not accept a function. However, most fields will allow functions.
Functions which are used on the Test Plan have some restrictions.
JMeter thread variables will have not been fully set up when the functions areprocessed, so variable names passed as parameters will not be set up, and variable
references will not work, so split() and regex() and the variable evaluation functions
won't work.
The following functions should work OK on the test plan - intSum, longSum,
machineName, BeanShell, javaScript, jexl, random, time, property functions, log
functions.
8/13/2019 JMeter Training Material
10/69
May 13, 200910
Functions
__functionless
__counter __threadNum
__intSum
__longSum
__StringFromFile
__machineName
__javaScript
__Random
__CSVRead
__property
8/13/2019 JMeter Training Material
11/69
May 13, 200911
Functions condt...
_P
_log
__logn
__BeanShell
__split
__Xpath
__setProperty
__time
__jexl
__V
8/13/2019 JMeter Training Material
12/69
May 13, 200912
Functions condt...
__evalVar
__eval
__char
__unescape
__unescapeHtml
__escapeHtml
8/13/2019 JMeter Training Material
13/69
May 13, 200913
Pre-defined Variables
Most variables are set by calling functions or by test elements such as User Defined
Variables.
In user define variable the user has full control over the variable name
Some variables are defined internally by JMeter.
These are listed below.
Cookiename - contains the cookie value JMeterThread.last_sample_ok - whether or not the last sample was OK
true/false
START variable
8/13/2019 JMeter Training Material
14/69
May 13, 200914
Building a Web test plan
Adding Users
Adding Default HTTP Request Properties
Add HTTP Request
Add listener to view store the Test Result
8/13/2019 JMeter Training Material
15/69
May 13, 200915
Building a Web test plan Adding Users
8/13/2019 JMeter Training Material
16/69
May 13, 200916
Building a Web test plan Adding Default HTTPRequest Properties
8/13/2019 JMeter Training Material
17/69
May 13, 200917
Building a Web test plan Adding HTTP Request
8/13/2019 JMeter Training Material
18/69
May 13, 200918
Building a Web test plan -Add listener to view store theTest Result
8/13/2019 JMeter Training Material
19/69
May 13, 200919
Building a Advanced Web test plan
Handling User Sessions With URL Rewriting
Using a Header Manager
8/13/2019 JMeter Training Material
20/69
May 13, 200920
Building a Advanced Web test plan - Handling UserSessions With URL Rewriting
Web application uses URL rewriting rather than cookies to save session information.
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
and add it to each request.
If the request already has a value, it will be replaced. 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.
8/13/2019 JMeter Training Material
21/69
May 13, 200921
Building a Advanced Web test plan - Handling UserSessions With URL Rewriting condt
A test plan is shown using URLrewriting.
The URL Re-writing modifier is added
to the SimpleController, thus assuring
that it will only affect requests under
that SimpleController.
8/13/2019 JMeter Training Material
22/69
May 13, 200922
Building a Advanced Web test plan - Handling UserSessions With URL Rewriting condt
Request Parameters
8/13/2019 JMeter Training Material
23/69
May 13, 200923
Building a Advanced Web test plan - Using a HeaderManager
The HTTP Header Manager customizes information JMeter sends in the HTTP
request header .
This header includes properties like "User-Agent", "Pragma", "Referer" etc.
The HTTP Header Manager ( like the HTTP Cookie Manager) should probably be
added at the Thread Group level, unless different headers for the different HTTP
Request objects in test is specified.
8/13/2019 JMeter Training Material
24/69
May 13, 200924
Building a Database Test Plan
Adding Users
Adding JDBC Requests
Adding a Listener to View/Store the Test Results
8/13/2019 JMeter Training Material
25/69
May 13, 200925
Building a Database Test Plan Adding User
A Thread Group with Default Value
8/13/2019 JMeter Training Material
26/69
May 13, 200926
Building a Database Test Plan Adding User condt
JDBC User Thread Group
8/13/2019 JMeter Training Material
27/69
May 13, 200927
Building a Database Test Plan Adding JDBC Requests
JDBC Configuration JMeter creates a database
connection pool with theconfiguration settings asspecified in the Control Panel.The pool is referred to in JDBCRequests in the 'Variable
Name' field. Several differentJDBC Configuration elementscan be used, but they musthave unique names. EveryJDBC Request must refer to aJDBC Configuration pool. More
than one JDBC Request canrefer to the same pool.
8/13/2019 JMeter Training Material
28/69
May 13, 200928
Building a Database Test Plan Adding JDBC Requestscondt
JDBC Request
8/13/2019 JMeter Training Material
29/69
May 13, 200929
Building a Database Test Plan Adding JDBC Requestscondt
JDBC Request for Kodak stock
8/13/2019 JMeter Training Material
30/69
8/13/2019 JMeter Training Material
31/69
May 13, 200931
Building a Database Test Plan Adding a Listener toView/Store the Test Results
Graph results Listener
8/13/2019 JMeter Training Material
32/69
May 13, 200932
Building an FTP Test Plan
Adding Users
Adding Default FTP Request Properties
Adding FTP Requests Adding a Listener to View/Store the Test Results
8/13/2019 JMeter Training Material
33/69
B ildi FTP T t Pl
8/13/2019 JMeter Training Material
34/69
May 13, 200934
Building an FTP Test Plan -Adding Default FTP RequestProperties
FTP Request Defaults
B ildi FTP T t Pl
8/13/2019 JMeter Training Material
35/69
May 13, 200935
Building an FTP Test Plan -Adding Default FTP RequestProperties condt
FTP Defaults for our Test Plan
8/13/2019 JMeter Training Material
36/69
May 13, 200936
Building an FTP Test Plan -Adding FTP Requests
FTP Request for O'Reilly mSQL Java README file
8/13/2019 JMeter Training Material
37/69
May 13, 200937
Building an FTP Test Plan -Adding FTP Requests condt
FTP Request for O'Reilly mSQL Java tutorial file
B ildi FTP T t Pl Addi Li t t
8/13/2019 JMeter Training Material
38/69
May 13, 200938
Building an FTP Test Plan -Adding a Listener toView/Store the Test Results
Spline Visualizer Listener
8/13/2019 JMeter Training Material
39/69
May 13, 200939
Building an LDAP Test Plan
Adding Users
Adding Login Config Element
Adding LDAP Request Defaults Adding LDAP Requests
Inbuilt Add Test
Inbuilt Modify Test
Inbuilt Delete Test
Inbuilt Search Test
Adding a Listener to View/Store the Test Results
8/13/2019 JMeter Training Material
40/69
May 13, 200940
Building an LDAP Test Plan -Adding Users
Thread Group with Default Values
Building an LDAP Test Plan Addi L i C fi
8/13/2019 JMeter Training Material
41/69
May 13, 200941
Building an LDAP Test Plan -Adding Login ConfigElement
Login Config Element for our Test Plan
Building an LDAP Test Plan Addi LDAP R t
8/13/2019 JMeter Training Material
42/69
May 13, 200942
Building an LDAP Test Plan Adding LDAP RequestDefaults
LDAP Defaults for our Test Plan
8/13/2019 JMeter Training Material
43/69
May 13, 200943
Building an LDAP Test Plan Adding LDAP Requests
Four LDAP request can be added.
Inbuilt Add Test
Inbuil Modify Test
Inbuilt Delete Test
Inbuilt Search Test
JMeter sends requests in the order that you add them to the tree
B ildi LDAP T t Pl
8/13/2019 JMeter Training Material
44/69
May 13, 200944
Building an LDAP Test Plan Adding LDAP Requestscondt
LDAP Request for Inbuilt Add test
LDAP Request for Inbuilt Modify test
B ildi LDAP T t Pl Addi LDAP R t
8/13/2019 JMeter Training Material
45/69
May 13, 200945
Building an LDAP Test Plan Adding LDAP Requestscondt
LDAP Request for Inbuilt Delete test
LDAP Request for Inbuilt Search test
Building an LDAP Test Plan Adding a Listener to
8/13/2019 JMeter Training Material
46/69
May 13, 200946
Building an LDAP Test Plan Adding a Listener toView/Store the Test Results
View result in Table Listener
8/13/2019 JMeter Training Material
47/69
May 13, 200947
Building an Extended LDAP Test Plan
Adding Users
Adding LDAP Extended Request Defaults
Adding LDAP Requests Adding a Thread bind Request
Adding a search Request
Adding a Compare Request
Adding a Single bind/unbind
Adding an Add Request
Adding a Modify Request Adding a Delete Request
Adding a Rename Request (moddn)
Adding an unbind Request
Adding a Listener to View/Store the Test Results
8/13/2019 JMeter Training Material
48/69
May 13, 200948
Building an Extended LDAP Test Plan -Adding Users
Thread Group with Default Values
Building an Extended LDAP Test Plan - Adding LDAP
8/13/2019 JMeter Training Material
49/69
May 13, 200949
Building an Extended LDAP Test Plan - Adding LDAPExtended Request Defaults
LDAP Defaults for our Test Plan
Building an Extended LDAP Test Plan - Adding LDAP
8/13/2019 JMeter Training Material
50/69
May 13, 200950
Building an Extended LDAP Test Plan - Adding LDAPRequest
Nine LDAP request can be added.
Adding a Thread bind Request
Adding a search Request
Adding a Compare Request
Adding a Single bind/unbind
Adding an Add Request
Adding a Modify Request
Adding a Delete Request
Adding a Rename Request (moddn)
Adding an unbind Request
JMeter sends requests in the order that you add them to the tree.
Building an Extended LDAP Test Plan Adding LDAP
8/13/2019 JMeter Training Material
51/69
May 13, 200951
Building an Extended LDAP Test Plan - Adding LDAPRequest condt
Adding a Thread bind Request
Building an Extended LDAP Test Plan Adding LDAP
8/13/2019 JMeter Training Material
52/69
May 13, 200952
Building an Extended LDAP Test Plan - Adding LDAPRequest condt
Adding a Search Request
Building an Extended LDAP Test Plan Adding LDAP
8/13/2019 JMeter Training Material
53/69
May 13, 200953
Building an Extended LDAP Test Plan - Adding LDAPRequest condt
Adding a Compare Request
Building an Extended LDAP Test Plan - Adding LDAP
8/13/2019 JMeter Training Material
54/69
May 13, 200954
Building an Extended LDAP Test Plan Adding LDAPRequest condt
Adding a Single bind/unbind
Building an Extended LDAP Test Plan - Adding LDAP
8/13/2019 JMeter Training Material
55/69
May 13, 200955
Building an Extended LDAP Test Plan Adding LDAPRequest condt
Adding an Add Request
Building an Extended LDAP Test Plan - Adding LDAP
8/13/2019 JMeter Training Material
56/69
May 13, 200956
Building an Extended LDAP Test Plan Adding LDAPRequest condt
Adding a Modify Request
Building an Extended LDAP Test Plan - Adding LDAP
8/13/2019 JMeter Training Material
57/69
May 13, 200957
Building an Extended LDAP Test Plan Adding LDAPRequest condt
Adding a Delete Request
8/13/2019 JMeter Training Material
58/69
Building an Extended LDAP Test Plan - Adding LDAP
8/13/2019 JMeter Training Material
59/69
May 13, 200959
Building an Extended LDAP Test Plan Adding LDAPRequest condt
Adding an unbind Request
Building an Extended LDAP Test Plan - Adding a
8/13/2019 JMeter Training Material
60/69
May 13, 200960
Building an Extended LDAP Test Plan Adding aListener to View/Store the Test Results View result Tree Listener
Building a WebService Test Plan
8/13/2019 JMeter Training Material
61/69
May 13, 200961
Building a WebService Test Plan
Adding Users
Adding WebService Requests
Adding a Listener to View Store the Test Results
Building a WebService Test Plan Addi U
8/13/2019 JMeter Training Material
62/69
May 13, 200962
Building a WebService Test Plan -Adding Users
Jakarta Users Thread Group
Building a WebService Test Plan - WebService
8/13/2019 JMeter Training Material
63/69
May 13, 200963
gRequests
Building a WebService Test Plan - Building a
8/13/2019 JMeter Training Material
64/69
May 13, 200964
Building a WebService Test Plan Building aWebService Test Plan
Graph Results Listener
Case Study
8/13/2019 JMeter Training Material
65/69
May 13, 200965
y
Create and run a Database test plan to test Mysql database server.
OR
Create and run a FTP test plan to test a FTP site.
Advantages
8/13/2019 JMeter Training Material
66/69
May 13, 200966
Advantages
It is free
Easy to install and use
Compared to other load and performance testing tools, it is not only for web
application, but also for other servers or objects
Test results can be shown in different formats
Highly extensible
Tips
8/13/2019 JMeter Training Material
67/69
May 13, 200967
Tips
Use timers to avoid hammering the server
Limit the Number of Threads Hardware will limit the number of threads you can effectively run. A faster machine
makes JMeter work harder since it returns request quicker.
User variables
Create a text file containing the user names and passwords.
Add a CSV DataSet configuration element. Name the variables USER and PASS.Use ${USER} and ${PASS} within samplers.
Reducing resource requirements
Use non-GUI mode.
Use as few Listeners as possible.
Reduce samplers by looping (by thread and by controller), and use variables (CSVData Set) to vary the sample.
Use CSV output rather than XML.
References
8/13/2019 JMeter Training Material
68/69
May 13, 200968
References
JMeter has 2 types of mailing list
The JMeter User List
The JMeter Developer List
To subscribe to any mailing list
http://jakarta.apache.org/site/mail2.html
8/13/2019 JMeter Training Material
69/69
Recommended