In this course we will learn Jmeter from scratch step by step.
We will learn the basics in a very easy way and you will be able to use JMeter for all types of performance and functional testing.
After this course you can work with JMeter for personal and enterprise projects.
LET’S GET STARTED…
INTRODUCTION | GETTING STARTED
Step 1 : Check java is installed on your system
java -version
How to install java on windows
https://youtu.be/FqpmH8MVO6A?list=PLhW3qG5bs-L_qj1L5hnHvJYeFpQ_g4UuU
How to install java on mac
https://youtu.be/NSvtis2fGlA?list=PLhW3qG5bs-L_qj1L5hnHvJYeFpQ_g4UuU
Step 2 : Download Jmeter from internet
http://jmeter.apache.org/download_jmeter.cgi
Step 3 : Unzip and keep Jmeter folder at any location
Step 4 : Start Jmeter
Windows - jmeter/bin - jmeter.bat
| Mac - open terminal - jmeter/bin - sh jmeter.sh
Step 1 - Start Jmeter
Step 2 - Create a TestPlan
Step 3 - Create a Thread Group (Users)
Step 4 - Add a Sampler (Http)
Step 5 - Add Listeners
Step 6 - To Run the Test
Assertions = checks on the Response
1. Response Assertion
2. Duration Assertion
3. Size Assertion
4. HTML Assertion
5. XML Assertion
6. XPATH Assertion
listener = elements that gather information about the performance test
used to view results / metrics of the test
latency = time to first byte
1. View Results in Table
2. View Results Tree
3. Aggregate Report
4. Graph Results
5. Summary Report
6. Simple Data Writer
NEXT STEPS WITH
1. Tools available for recording Jmeter ui test
- Badboy software (Windows)
- Blazemeter - Chrome Plugin - (Windows and Mac)
2. Record a Test
3. Export as Jmeter (.jmx) Script
4. Open the script in Jmeter
5. Add listeners
6. Run and validate
Step 1 - Add mysql jdbc jar to Jmeter lib folder | Restart Jmeter
https://dev.mysql.com/downloads/connector/j/
Step 2 - Add Thread Group
Step 3 - Add JDBC Conn Config | Provide the details of our DB
JDBC URL Format
Useful Tip:
The general format for a JDBC URL for connecting to a MySQL server is as follows, with items in square brackets ([ ]) being optional:
jdbc:mysql://[host1][:port1][,[host2][:port2]]...[/[database]] »
[?propertyName1=propertyValue1[&propertyName2=propertyValue2]...]
Here is a simple example for a connection URL:
jdbc:mysql://localhost:3306/sakila?profileSQL=true
Ref : https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html
Step 4 - Add JDBC Request
Step 5 - Add Listeners
Step 6 - Run and validate
Why to execute non-gui mode ?
-gui - consumes more resources / memory
-gui - not recommended for heavy load testing
-command line - can be integrated with other systems -Jenkins/CI …
Step 1 : Goto command line - goto jmeter - bin
Step 2 : Command :
jmeter -n -t (location of your jmeter test script) -l (location of the result file)
-n - non gui mode
-t - location of jmeter script
-l - location of result file
jmeter -h - to get help on jmeter commands
jmeter -? - to get information on jmeter command options
Step 1 : Add a FTP Request Sampler
Step 2 : Add FTP connection parameters
https://www.swfwmd.state.fl.us/data/ftp/
Server: ftp.swfwmd.state.fl.us
User Name: Anonymous
(use your email address as password)
Step 3 : Test a FTP GET and validate (get file from ftp server to local system)
Step 4 : Test a FTP PUT and validate (transfer file from local to ftp server)
(FileZilla client is used in this demo for physical validation of file transfer.
You can use other FTP clients like WinSCP)
An Update:
JMeter ver 3.2 onwards - SOAP/XML-RPC Request has been removed as part of Bug 60727. Use HTTP Request element as a replacement.
See Building a WebService Test Plan http://jmeter.apache.org/usermanual/build-ws-test-plan.html
API = Application Programming Interface
example-
Restaurant - table — WAITER — kitchen
real world example - makemytrip.com
WebServices - client — API — server
REST | SOAP
How to test REST API
————————————
Step 1 : Add HTTP Request Sampler
OR
Add SOAP/XML-RPC Request Sampler
Step 2 : Add REST API details
(http://openweathermap.org/appid)
api.openweathermap.org/data/2.5/forecast/city?id=524901&APPID=1111111111
http://api.openweathermap.org/data/2.5/weather?q=NewDelhi&appid=5ad76b332e2fa27ea9859353e5fdd69d
api.openweathermap.org
/data/2.5/weather/
q=NewDelhi
appid=5ad76b332e2fa27ea9859353e5fdd69d
Step 3 : Run and Validate
How to test SOAP API
————————————
Step 1 : Add SOAP/XML-RPC Request Sampler
Step 2 : Add details of the Soap API Request
(http://www.webservicex.net/New/Home/ServiceDetail/56)
Step 3 : Run and Validate
to watch before this video : How to create a Database Test Plan
Step 1 : Add a Response Assertion
Step 2 : Add variable names in JDBC Request
Col1,Col2,Col3,Col4
Col1 Col2 Col3 Col4
=== === === ===
ID Name Age Country
1 Raghav 30 India
2 Tom 40 New Zealand
Col4_2 = NewZealand
Col2_2 = Tom
Step 3 : In Response Assertion add Jmeter Variable and Pattern to Test
Step 4 : Add Listener Assertion Results
Step 5 : Run and validate
REPORTS | PLUGINS |CSV DATA DRIVEN TESTS | FUNCTIONS AND VARIABLES
(This feature will work in jmeter 3.0 and later ver.)
Step 1 : Create Test Plan and save it (and close).
Step 2 : Open command line and change dir to jmeter/bin
Step 3 : Execute command:
to create report at the end of the test
—————————————————————
jmeter -n -t “location of the jmeter script” -l “location of result file”
-e -o “location of the output folder”
create report from a standalone csv file
——————————————————————
jmeter -g “location of csv file” -o “location of output folder”
Step 4 : Analyse HTML (Dashboard) Reports
Manage Plugins - Quick & Easy
Install new plugins
Remove old plugins
Upgrade existing plugins
Information on plugins
Step 1 : Download jmeter plugin manager jar and add to jmeter/lib/ext folder
(Restart Jmeter)
Step 2 : Find Plugin Manager under options Menu
Step 1 : Add config element - CSV Data Set Config
Step 2 : Add details in CSV Data Set Config
Step 3 : Update value fields: ${variable_name}
Step 4 : Run and validate
functions : any method that can populate a field in any other element of a test plan
syntax : ${__functionName}
${__functionName(var1, var2, …..)}
variable : container that can store a value which can be referenced by any other element within the thread. (local to a thread)
syntax : ${variableName}
function - caseSensitive | camelCasing
Functions:
—————
1. log - ${__log(“message”)}
2. time -
3. threadNum
4. intSum
Options - Jmeter Function Helper
FREQUENTLY USED ELEMENTS IN JMETER
This plugin is deprecated and should not be used. Use Concurrency Thread Group instead.
https://www.youtube.com/watch?v=_YsZn1VwZYY
What is a real-world performance test
Think Time - simulate actual user actions with timings/delays
Pacing - controlled ramp-up and down of virtual users
- control timing between iterations
- achieve x iterations in y mins/sec
Step 1 - Add Plugin - Stepping Thread Group
Step 2 - Setup load with required settings
Step 3 - Run and validate
Purpose - to pause thread (v.user) for some time
- to add delay between threads
- to avoid over flooding the server and achieve real time behaviour by pacing the load
(to simulate v. user’s THINK TIME)
Constant Timer
Uniform Random Timer
Random Delay Max
Constant Delay Offset
formula:
0.X * Random Delay Max + Constant Delay Offset
X : 0-9
example:
0.X * 100 + 0
0 - 99 milli sec
(To upload files with different names to FTP)
Step 1 : add CSV Data Set Config
Step 2 : create a csv file and provide its location in CSV Data Set Config
Step 3 : parametrize FTP PUT request to take value from csv file
Step 4 : Run and Validate
Today we will learn:
HOW TO RUN A TEST FOR SPECIFIC DURATION
Thread Group - Forever - Scheduler - Duration
HOW TO RUN PERFORMANCE TEST SEQUENTIALLY
Test Plan - Run Thread Group Consecutively
HOW TO ADD WEBSITES SEQUENTIALLY TO A PERFORMANCE TEST
Thread Group - Forever - Scheduler - Duration + Startup Delay
_______________________________________________
HOW TO RUN A TEST FOR SPECIFIC DURATION
Thread Group - Forever - Scheduler - Duration
Step 1 : Thread Group - make loop count = forever
Step 2 : Select Scheduler checkbox
Step 3 : Add duration (sec)
———————————————————————————
HOW TO RUN PERFORMANCE TEST SEQUENTIALLY
Test Plan - Run Thread Group Consecutively
Step 1 : Test Plan - select Run Thread Groups consecutively
———————————————————————————
HOW TO ADD WEBSITES SEQUENTIALLY TO A PERFORMANCE TEST
Thread Group - Forever - Scheduler - Duration + Startup Delay
Step 1 : Add duration (max) to first thread group - 30 sec
Step 2 : To consecutive thread groups add delay
example (for a 30 sec test plan):
1st Thread Group : delay = 0 sec | duration = max duration of the test = 30 sec
2nd Thread Group : delay = 10 sec | duration = max - delay = 30 - 10 = 20 sec
3rd Thread Group : delay = 20 sec | duration = max - delay = 30 - 20 = 10 sec
___________________________________________________________
Today we will learn:
What is Correlation
Why is it required
How to use Regular Expression Extractor
Step 1 : Create a Test Plan where you want to do dynamic referencing in JMeter
Step 2 : Add Regular Expression Extractor in the Step from where response value(s) needs to be extracted
Step 3 : Refer the extracted value (referred by Reference Name) into a subsequent step
Step 4 : Run and validate
references : http://regexr.com/
Today we will learn :
1. What are JMeter Templates
2. How to use Templates
3. How to create your own Template
____________________________________________
1 What are JMeter Templates
Reusable project scripts
User can select any template and it will generate a Test Plan with basic and necessary components
____________________________________________
2 How to use Templates
File - Templates - select a template and start building over it.
____________________________________________
3 How to create your own Template
Step 1 : save your test plan as .jmx file
Step 2 : place the .jmx inside jmeter/bin/templates
Step 3 : edit templates.xml file to add your template
Step 4 : restart JMeter and check
____________________________________________
templates.xml
template
isTestPlan=”true” : template will create a new test plan
isTestPlan=”false” : templat will be merged into existing test plan
name : Name of the template
fileName : location of .jmx file
description : description will be displayed in html
DEBUG AND MORE...
Today we will learn :
1. What is Test Script Recorder
2. How to record your test with it
helpful tips
__________________________________________
1 What is Test Script Recorder
is a workbench element
used to record user actions on browser
__________________________________________
2 How to record with Test Script Recorder
Step 1 : Add Test Script Recorder in WorkBench
WorkBench - Non-Test Elements - HTTP(S) Test Script Recorder
Step 2 : In a Thread Group add
Logic Controller - Recording Controller
Step 3 : Add the values in Test Script Recorder parameters
Step 4 : Set Browser Proxy Configuration
Step 5 : Install the certificate in your browser (if required)
Step 6 : Start Recording
Step 7 : Run and validate
__________________________________________
Helpful Tips:
Use JMeter’s inbuilt Recording template
You can use the in-built template - Recording
to start quickly
to save time and effort
___________________________________________
References : http://jmeter.apache.org/usermanual/component_reference.html#HTTP(S)_Test_Script_Recorder
Today we will learn:
1. How to create test for file upload
2. How to record test for file upload
____________________________________
1 How to create test for File Upload
Step 1 : Create a Test Plan - Thread Group - HTTP Request
Step 2 : Add values in HTTP Request sampler
Step 3 : Add File Upload details
Step 4 : Add Listeners to view results
Step 5 : Run and Validate
____________________________________
2 How to record test for File Upload
Step 1 : Add Template - Recording
Step 2 : Provide a port number (e.g. 8181)
Step 3 : Set browser to listen to this port
Step 4 : Start Recording
Step 5 : Filter the samples you need from recorded samples
Step 6 : Run and Validate
__________________________________________
Helpful Tips:
In case you face any issues..
Check the following :
Method is POST
Use multipart/form-data for POST Box is checked
File location | Parameter | Mime Type are correct
Check the logs for any other error
In case you face any issues in recording the scenario...
Watch :
https://youtu.be/amEHuq8auTU?list=PLhW3qG5bs-L-zox1h3eIL7CZh5zJmci4c
___________________________________________
References :
http://www.tinyupload.com/
http://www.freeformatter.com/mime-types-list.html
Today we will learn:
1. How to create test for file download
Step 1: Add Thread Group - HTTP Request sampler
Step 2 : Add values in HTTP Request sampler
Step 3 : Add Listeners to view results
Step 4 : Add Listener - Save Responses to a file
Step 5 : Add values to this Listener
Step 6 : Run and Validate
______________________________________
Helpful Tips
How to avoid overwriting downloaded files.
in a multi-user test
Use function : ${__threadNum} as Prefix
___________________________________________
References :
ftp://speedtest.tele2.net/
Today we will learn
1. How to debug and fix errors
2. How to use Debug Sampler
____________________________
Step 1 : Analyse with Listener - View Results Tree
Step 2 : Analyse information in Log Viewer
Step 3 : Add Listner - Debug Sampler
____________________________
Helpful Tips
How to use Debug PostProcessor
Enable Debug for elements
Using external plugins for Debugging
___________________________________________
References:
How to use Plugin Manager:
https://youtu.be/KQfoBOK37ms?list=PLhW3qG5bs-L-zox1h3eIL7CZh5zJmci4c
Step 1 : add blazemeter plugin to chrome browser
Step 2 : start blazemeter plugin and login to blazemeter
Step 3 : Record your scenario - Stop Recording - Export .jmx
In case you find jmx option disabled export as json and use this link to convert to jmx
http://converter.blazemeter.com/
Step 4 : Import imx file in JMeter
Step 5 : Add listeners
Step 6 : Run and validate
JMeter and Selenium
TIPS & TRICKS
View logs by clicking on log viewer
Can also be accessed from Options - Log Viewer
Set different log levels from options menu
ERROR
WARN
INFO
DEBUG
TRACE
Log file in jmeter/bin :
jmeter.log
log4j2.xml
Since 3.2, JMeter logging is not configured through properties file(s) such as jmeter.properties any more, but it is configured through a Apache Log4j 2 configuration file
References : http://jmeter.apache.org/usermanual/get-started.html#logging
How to use Step by Step Debugger
Plugin Manager - Step-by-Step Debugger
Run - Step-by-Step Debugger
Step 1 : Goto jmeter bin folder
Step 2 : Open jmeter.properties file
Step 3 : Find the line
#jmeter.save.saveservice.timestamp_format=yyyy/MM/dd HH:mm:ss.SSS
Uncomment and edit the format as required
Step 4 : Restart JMeter
How to use Step by Step Debugger - https://www.youtube.com/watch?v=7JI3GD0ifTw
References:
https://reqres.in/
https://codebeautify.org/jsonviewer
What is JSON Extractor
How to use JSON Extractor
How to refer multiple values
How to refer json extracted values
________________________________________________________________
1. How to set thread(users) / ramp-up period etc from command line
2. Run and validate
Useful TIPS
${__P(User,1)}
References : https://jmeter.apache.org/usermanual/functions.html
________________________________________________________________
Today we will learn:
Adding timestamp to result file names so that a new file is generated every time
Syntax:
${__time(MM-dd-yyyy-HH-mm-ss,)}
References : https://jmeter.apache.org/usermanual/functions.html
Today we will learn:
1. How to use Concurrency Thread Group
2. How to control threads
References:
Stepping Thread Group is deprecated
https://jmeter-plugins.org/wiki/SteppingThreadGroup/
https://jmeter-plugins.org/wiki/ConcurrencyThreadGroup/
Step 1 : Add JMeterPlugins-Standard lib
https://jmeter-plugins.org/downloads/old/
Step 2 : Run your test and get jtl file
Step 3 : Use JMeterPluginsCMD.bat to generate aggregate csv result file from jtl file
syntax:
JMeterPluginsCMD.bat --generate-csv "location of csv file" --input-jtl "location of jtl file" --plugin-type AggregateReport
Use JMeterPluginsCMD tool with Plugin Type = AggregateReport
References:
https://jmeter-plugins.org/wiki/JMeterPluginsCMD/
https://jmeter-plugins.org/downloads/old/
Today we will learn:
1. How to get count of child nodes/objects from a json response
2. How to assert the count
Useful TIPS
References
Json Extractor - https://www.youtube.com/watch?v=3w0x6u4-6ng
https://reqres.in/
https://reqres.in/api/users?page=2
https://jsoneditoronline.org/
https://codebeautify.org/jsonviewer
Today we will learn:
1. How to refer values from csv file
2. How to run the test equal to the count of rows in csv file
Step 1: Create a ThreadGroup
Step 2 : Add a WhileController
Step 3 : Add a sampler (as child of WhileController)
Step 4 : Add CSV data set config (as child of WhileController)
Step 5 : Add values. Keep
Recycle on EOF = FALSE
Stop Thread on EOF = FALSE
Step 6 : Refer the variable in sampler request
Step 7 : Add a listener. Run and validate
Today we will learn
1. How to refer current time stamp in JMeter
2. How to get timestamp in required format
3. How to get shifted time in required format
References : https://help.sumologic.com/Send-Data/Sources/04Reference-Information-for-Sources/Timestamps%2C-Time-Zones%2C-Time-Ranges%2C-and-Date-Formats
Today we will learn:
1. How to run specific threads in the test plan from command line
jmeter -n -t "C:UsersRaghav PalDesktopJmeterTestTest1.jmx" -l "C:UsersRaghav PalDesktopJmeterTestresult.csv" -Jusers1=2 -Jusers2=0
SERVER HEALTH CHECK
How to monitor server Health |
PerfMon
Today we will learn:
- How to add PerfMon plugin in JMeter
- How to start PerfMon server
- How to monitor server health with JMeter PerfMon plugin
Response
Time
Avg Time
Connect Time
Size
Bytes
Server - machine where your test application is hosted
CPU, Memory, Disk I/O, Network
10000 users
9000 users, high CPU usage
Suggest hardware infrastructure
Step 1 : Add perfmon plugin in JMeter
1. Download and add to JMeter lib and ext folder https://jmeter-plugins.org/wiki/PerfMon/
2. Plugins Manager
Step 2 : On server
Download perform server agent https://github.com/undera/perfmon-agent/blob/master/README.md
Step 3 : Start the perfmon server agent
Mac/linux - terminal > sh startAgent.sh
Windows - startAgent.bat
Check client can talk to server via port 4444
Step 4 : Create JMeter test to monitor Server Health
Step 5 : Run and Validate
_____________________________________________________
REMOTE TESTING | Master-Slaves
JMeter on Linux
JMeter | Install on AWS Linux
Amazon AWS Linux
Step 1 : Check java is installed
Step 2 : Get JMeter
wget http://www-eu.apache.org/dist//jmeter/binaries/apache-jmeter-4.0.tgz
Step 3 : Extract jmeter
tar -xf apache-jmeter-4.0.tgz
Step 4 : Run a sample test
References
https://jmeter.apache.org/download_jmeter.cgi
_____________________________________