Performative Jmeter Material.
Performative Jmeter Material.
Performative Jmeter Material.
JMETER BASICS
WHAT IS JMETER
Open Source Tool from Apache, mainly for performance testing but JMeter is designed to cover
categories of tests like load, functional, regression, etc.
Performance Testing
In Performance testing, we analyze the system over a period of time under different conditions.
Condition can be Normal and Abnormal
Under Large number of user, Database size constant.
Under constant number of users with increase DB size.
Increase both, number of users and database size.
Stress Testing : It is performed in abnormal conditions, like if application is designed for 100
users, we will apply much more users than 100.
The aim of this type of testing is to find at what point application will break.
Volume testing : In volume testing application is tested under heavy database size.
1
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
will run.
In Jmeter, Test plan can be defined as a Test Suite, which can have multiple test cases(thread
Group) in that.
1 We can have multiple thread group in test plan which we can run in parallel or serial mode.
2 We can Set variables in Test Plan, which will behave as global variables and can be used
anywhere in test plan.
3 We have “Function Testing” check box, if we checked it, JMeter will save the response which
is coming from server but for that we need to use listener and define file path there.( it reduce
performance because it’s going to take time for save the response)
4 Run thread Groups Consecutively: if we set this check box than thread groups in test plan will
run in serial (one after another).
5 We can define class path for jar file which are supposed to use by JMeter, here as well.
2
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
2 Logic Controllers: With the help of logic controllers we can control the flow of execution of
the test plan, otherwise elements of test plan with execute in same order in which they are
placed.
3 Config Elements : Config elements does not send any request to server, their work is to
configure samplers which are going to send requests to server.
5 Preprocessors : is used to do some action, if added with sampler then it execute before
sampler and configure settings.
6 Postprocessors : is used to perform some action, if added with sampler then it will execute
after sampler and user to process response coming from server.
7 Assertions : are use to apply validations on the response coming from the server.
Config Element
Pre Processors
Timers
Samplers
Post Processors
Assertions
Listeners
3
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
To Stop Immediately : Runà Stop ( Ctrl + . ) --- It will stop all threads in 5 sec(default time) or
display pop up if it take more time
To Shutdownà Means thread will perform its task and then will stop(RunàShut Down Ctrl+ ,)
Note : Multiple threads which run will be completely independent to each other.
We can save complete test plan or part of test plan, if we want to save complete test plan then go
to file -- >Save (Ctrl +S)
We can save only element for that right click on that element ad select Save As or go to edit save
as.
We can Add New Elements, either by Right Click + New Element or We can load any element
for that right click where we want to load element and Open
Samplers and Logic Controllers are ordered it will execute in order as they places.
Rest Elements are hierarchical: Means it will execute on behalf of parent added.
In Bin Folder
Jmeter.bat --- > Start Jmeter in GUI Mode, we can create, open, run, update jmeter test plan.
Jmeter-n.cmd --- > Drop jmx file on that file, it will execute jmeter test plan in non GUI mode.
Jmter-n-r.cmd --- > Drop jmx file on that file, it will execute jmeter test plan in non GUI mode
remotely.
Jmeter-t.cmd --- > Drop jmx file on that file, it will open jmeter test plan in GUI mode.
Jmeter-server.bat --- > It will start jmeter server, which can be used for distributed testing.
4
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
JVM_ARGS: We can update the JVM setting by updating this variable in Jmeter.bat file.
In Jmeter we have 2 path where Jmeter look for classes, so we can place Jars on these to paths
Lib Folder : Here we can put all utility jar files, jar file which are required to run jmeter like
JDBC jar, Mymail jar etc.
Lib/Ext : Here we can place all jar file which are related to plugins etc.
If we place our jar file in any other place we can set class path from Test Plan GUI
Jmeter
-H HostName
-P Port
-u username
-a password.
Configuring Jmeter
We have Jmeter.properties file we can update this file as per our requirement.
Eg. Remote_hosts : We can set IP with Port here for remote hosts, we can handle that hosts
using our GUI
In this tutorial, we will teach you how to set up and use the Apache JMeter HTTP(S) Test Script
Recorder to record HTTP requests. Recording HTTP requests is a great way to building test
plans, and can be useful in creating tests that closely mimic a normal user’s behavior.
5
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
This tutorial assumes that you have a basic knowledge of Apache JMeter. If you are new to
JMeter, here is another tutorial that can get you started: How To Use Apache JMeter To Perform
Load Testing on a Web Server.
Prerequisites
• Apache JMeter
• Java 6 or later
• Mozilla Firefox
First, start JMeter. Then let’s start building a test plan. If you already have a test plan that you
would like to start with, skip this section and move on to adding a Recording Controller to your
Thread Group (the next section).
Minimally, we will want to add a Thread Group and HTTP Request Defaults. Let’s get start by
adding a Thread Group.
Thread Group.
6
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
1. Right click on the “Thread Group” and add a recording controller: Add > Logic
1. On HTTP(S) Test Script Recorder, click the “Add” button in “URL Patterns to Include”.
1. Right click on “HTTP(S) Test Script Recorder” and add a listener: Add -> Listener ->
1. Return to HTTP(S) Test Script Recorder, and click the “Start” button at the bottom. This
will start the JMeter proxy server which is used to intercept the browser requests.
Configure your browser to use the JMeter Proxy
At this point, JMeter’s proxy is running. For this exercise, we will use Firefox to view some
pages on the JMeter website.
1. On the new pop-up, check “Manual proxy configuration”. The address and port fields
should be enabled now.
2. Address – enter “localhost” or the IP address of your system
3. Port – enter “8080”.
With your browser, in the “Address” bar at the top, enter thetestingworld.comand hit the “enter”
key.
7
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
The different components of JMeter are called Elements. Each Element is designed for a specific
purpose.
THREAD GROUP
Thread Groups is a collection of Threads. Each thread represents one user using the application
under test. Basically each Thread simulates one real user request to the server.
SAMPLERS
Samplers are used to send requests to server. As we know already that JMeter supports testing
HTTP, FTP, JDBC and many other protocols.
LOGIC CONTROLLERS
With the help of logic controllers we can control the flow of execution of the test plan, otherwise
elements of test plan with execute in same order in which they are placed.
CONFIG ELEMENTS
Config elements does not send any request to server, their work is to configure samplers which
are going to send requests to server.
TIMERS
8
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
PRE-PROCESSORS
Is used to do some action, if added with sampler then it execute before sampler and configure
settings.
POST-PROCESSORS
Is used to perform some action, if added with sampler then it will execute after sampler and user
to process response coming from server.
ASSERTIONS
Are used to apply validations on the response coming from the server.
LISTENERS
1. Config Element
2. Pre Processors
3. Timers
4. Samplers
5. Post Processors
6. Assertions
7. Listeners
Running and Stopping test plan
To Stop Immediately : Run- Stop ( Ctrl + . ) — It will stop all threads in 5 sec(default time) or
display pop up if it take more time
Shutdown Means thread will perform its task and then will stop(Run-Shut Down)
Note : Multiple threads which run will be completely independent to each other.
9
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
We can save complete test plan or part of test plan, if we want to save complete test plan then go
to file –Save (Ctrl +S)
We can save only element for that right click on that element ad select Save As or go to edit save
as.
We can Add New Elements, either by Right Click + New Element or We can load any element
for that right click where we want to load element and Open.
Samplers and Logic Controllers are ordered it will execute in order as they places.
Rest Elements are hierarchical: Means it will execute on behalf of parent added.
Logic Controllers
If you want to control “when” to send a user request to a web server under test, what would you
do?
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.
Loop Controller creates a situation where user request runs either; for limited time or forever.
• For example, if you add one HTTP Request to a Loop Controller with a loop count of two, and
configure the Thread Group loop count to three, JMeter will send a total of 2 * 3 = 6 HTTP
Requests.
10
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
1. HTTP request
2. FTP request
3. JDBC request
In each loop, user requests send sequentially in following order,
Or
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:
The Switch Controller acts like the Interleave Controller in that it runs one of the subordinate
elements on each iteration, but rather than run them in sequence, the controller runs the element
defined by the switch value.
Recording Controller
JMeter can record your testing steps; recording controller is a place holder to store these
recording steps.
11
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
The Runtime Controller controls how long its children are allowed to run.
Throughput Controller
Module Controller
The goal of Module Controller is to add modularity to JMeter.
• We can call other controller(from same thread group or other thread group).
For example : Any web application consists of numbers of functions like; sign – in, sign – out,
and account creation, password change, Simple Controller stores these functions as modules then
Module Controller chooses which module needs to run.Suppose, simulation happens when 50
users sign-in, 100 users sign-out, and 30 users search on website.
Using JMeter, user can create 3 modules where each module simulates each user activity: sign-
in, sign-out, and Search. Module controller selects which module wants to run.
Include Controller
We can call other test plan in current test plan, but other test plan should have only simple
controller with samplers.
The Once Only Logic Controller tells JMeter to process the controller(s) inside it only once per
Thread, and pass over any requests under it during further iterations through the test
plan.Elements will execute only 1 if run in iterations. For each thread it will run only 1 time.
If you add Generative or Logic Controllers to an Interleave Controller, JMeter will alternate
among each of the other controllers for each loop iteration.
12
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
Random Controller
Same as Interleave but for each iteration element will execute randomly.
Transaction Controller
Transaction controller is used to find out time taken by group of samples to execute.
• It is added as individual sample and it shows the time taken by other samplers+ Timers.
• It is similar to transaction points which are used in QTP.
2 Modes
• Parent : can be added as a parent of other samplers but it will not save child
• samplers in CSV, will display in XML
All child elements will display in View Result Tree but will not display in other samplers.
Configuration elements can be used to set up defaults and variables for later use by samplers.
Note that these elements are processed at the start of the scope in which they are found, i.e.
• This config element is use to supply data to JMeter variables from external csv file.
• We can use same CSV file to supply data for all threads or we can have separate file for each
thread
• All thread use separate row data from CSV file, starting from line 1.
• CSV file open only once in first iteration, which then use by all available threads.
• Order of picking data from CSV will depend of order of execution of different threads.
HTTP Request Default
Here we pass server name only once in this config element and then in each sampler we just pass
relative path of each pages of the application.This Config element is mainly used when we want
13
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
to send many request to same server, so rather than giving same server name/ base URL in each
Counter
This element is used to count number of execution, whenever this counter execute in execution
flow, value of counter increase by 1.
• We can set minimum value, max value, increment value, once max value reach it start from min
value again.
• We can define variable name which hold counter value, which can be used other part of script.
Here we can define variable and values which can be used in other part of test plan.
• We can use this config element as a child of sampler to define local variable.
• We can use this config element in thread group to define global variables.
Random Variables
Here we can define variables which will hold randomly generated values.
It is used to store cookies value which are coming from server and automatically send these
cookies with sampler request whenever required.
14
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
We can use this config element to access restricted pages. Restricted pages are those which need
username and password to open that pages.
When request is made by using GET method, form data is encoded with URL header.This
element is used to manager header of HTTP request.
Simple Config element is mainly used for parametrization, we can define variables there with
value and then we can use that variables in our samplers.
Timers in JMeter
If you use just threads, controllers and samplers for load/stress testing of your application, then
JMeter will just bombard your application with incessant requests. This is not the real
environment or characteristic of the real traffic. Neither does it give you control to generate a
given throughput or hit with n clients at the same point of time.
So, in order to simulate real traffic or create extreme load/stress, JMeter provides you Timer
elements.
Constant Timer
If you want to have each thread pause for the same amount of time between requests, use this
timer.
This timer is used to insert random delay between steps, here we define max random value and
constant delay offset, so whenever this timer will execute then delay will be constant + randomly
generated value.
15
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
This timer is same as Uniform timer, difference is that random value generation will depend on
Gaussian theorem so every time the random value will be nearly identical(as per Gaussian
theorem)
deviation so randomly generated value will be near to deviation(it has by default mean =0 and
standard deviation =1).
Synchronizing Timer
This timer is mainly used when we want certain number of user perform any steps
simultaneously so with this timer we can define number of used that we want to stop at particular
point, when the given number of users are reached timer will terminate and all user will perform
next step simultaneously.
BeanShell Timer
BSF Timer
It is used to perform some action, if it is added to any sampler then it will be used to perform
configuration setting for samplers, it will always execute before sampler.
16
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
A Post-Processor executes some action after a Sampler Request has been made. If a Post-
Processor is attached to a Sampler element, then it will execute just after that sampler element
runs. A Post-Processor is most often used to process the response data, often to extract values
from it.
User Parameter
Variable and values can be defined in Test plan and Used Defined Variable (Config Element) but
the difference is that
• Value defined in User parameter will be applicable to current sampler only while user defined
variable and test plan value will be available for all samplers in the scope.
• We can defined value for each thread while in test plan or user defined var we can define a single
value which will be shared by all threads.
• Allows the user to specify values for User Variables specific to individual threads.
HTML Link Parser
This preprocessor parses the response of the server & extract links and the forms.
The sampler on which this pre processer is applied, will be examined to see if it matches any of
the link or the forms which is extracted by preprocessor from previous response, if yes then it
replace the value in URL with value hold by preprocessor.
Consider a simple example: let’s say you wanted JMeter to “spider”(Randomly Clicking links in
JMeter) 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.
This modifier works similarly to the HTML Link Parser, except it has a specific purpose for
which it is easier to use than the HTML Link Parser, and more efficient. For web applications
that use URL Re-writing to store session ids instead of cookies, this element can be attached at
the ThreadGroup level, much like the HTTP Cookie Manager. Simply give it the name of the
session id parameter, and it will find it on the page and add the argument to every request of that
ThreadGroup.
17
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
Allows to specify dynamic values for HTTP parameters extracted from another HTTP Request
using regular expressions. RegEx User Parameters are specific to individual threads.
JDBC Pre-Processor
The JDBC PreProcessor enables you to run some SQL statement just before a sample runs. This
can be useful if your JDBC Sample requires some data to be in DataBase and you cannot
compute this in a setup Thread group.
BSF Pre-Processor
The BSF PreProcessor allows BSF script code to be applied before taking a sample.
Post processor are used to perform some action, if it is added with sampler, it execute after
sampler and mainly used for processing response coming from server.
Right Click Thread Group -> Add -> Post Processor -> Result Status Action Handler
A Post-Processor executes some action after a Sampler Request has been made. If a Post-
Processor is attached to a Sampler element, then it will execute just after that sampler element
runs. A Post-Processor is most often used to process the response data, often to extract values
from it.
Here we can write Perl type regular expression to extract some value from response.
We can pass reference name/variable name where extracted value will be save.
We need to pass template sting, so extracted value will convert to template string and store in
variable.
18
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
Allows the user to extract values from a server response using a Perl-type regular expression. As
a post-processor, this element will execute after each Sample request in its scope, applying the
regular expression, extracting the requested values, generate the template string, and store the
result into the given variable name.
XPath Extractor
Here we can extract value by passing xpath from XML or XHTML document.
This test element allows the user to extract value(s) from structured response – XML or
(X)HTML – using XPath query language.
Example:
Here we can define next action on base of response status, we can stop thread or stop test here.
This test element allows the user to stop the thread or the whole test if the relevant sampler
failed.
The BSF PostProcessor allows BSF script code to be applied after taking a sample.
Before invoking the script, some variables are set up. Note that these are BSF variables – i.e.
they can be used directly in the script.
Variable Description
Log (Logger)can be used to write to the log file
Label the String Label
Filename the script file name (if any)
Parametersthe parameters (as a String)
args[] the parameters as a String array (split on whitespace)
Ctx (JMeterContext) gives access to the context
(JMeterVariables) gives read/write access to variables: vars.get(key);
Vars
vars.put(key,val); vars.putObject(“OBJ1”,new Object()); vars.getObject(“OBJ2”);
19
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
Props
Prev (SampleResult) gives access to the previous SampleResult (if any)
Sampler (Sampler) gives access to the current sampler
OUT System.out e.g. OUT.println(“message”)
Assertions are used for comparing actual result with expected results at run time.
Assertions are mainly used when we perform regression testing using Jmeter.
If we want to add assertion for a particular sampler then add assertion as a child of that sampler
otherwise assertion will apply to all samplers of the scope.
Assertion help verify that your server under test returns the expected results
Response Assertion
The response assertion lets you add pattern strings to be compared against various fields of the
server response.
For example, you send a user request to the website http://www.thetestingworld.com and get the
server response. You can use Response Assertion to verify if the server response contains
expected pattern string (e.g. ” title>Testing World: Best institute of software testing | Testing
World</title> “).
Size Assertion
The Size Assertion tests that each response contains the right number of bytes in it.
You can specify that the size be equal to, greater than, less than, or not equal to a given number
of bytes.
20
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
Duration Assertion
Here we can define expected time in which response should come back from server.
XML Assertion
This assertion is used to check whether the response XML is on correct format or not
HTML Assertion
This assertion is used to check the HTML response which is coming from server is a correct html
syntax or not using Jtidy
• JTidy is a HTML syntax checker. XML Schema AssertionThis assertion is used to validate
response XML to particular given schema.XML Schema is nothing but the format of XML( it is
a .xsd file).
XPath Assertion
With Xpath assertion, we can check weather a particular element(by giving xpath) present in
XML or not.
Compare Assertion
Compare Assertion compare the results/response for different requests/samplers made in the
scope.
21
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
Size Assertion
The Size Assertion tests that each response contains the right number of bytes in it. You can
specify that the size be equal to, greater than, less than, or not equal to a given number of bytes.
BSF Assertion
The BSF Assertion allows BSF script code to be used to check the status of the previous sample
The BeanShell Listener allows the use of BeanShell for processing samples for saving etc
Listener in JMeter
A listener is a component that shows the results of the samples. The results can be shown in a
tree, tables, and graphs or simply written to a log file.
Listeners can be configured to save different items to the result log files (JTL) by using the
Config popup as shown below.
Listener -Graph
Listener -Tables
A listener tables is a component that shows the results of the samples in tables.
22
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
The View Results Tree shows a tree of all sample responses, allowing you to view the response
for any sample. In addition to showing the response, you can see the time it took to get this
response, and some response codes. Note that the Request panel only shows the headers added
by JMeter. It does not show any headers (such as Host) that may be added by the HTTP protocol
implementation.
Listener – Logs
Listener -Graph
Graph Results
The Graph Results listener generates a simple graph that plots all sample times. Along the
bottom of the graph, the current sample (black), the current average of all samples(blue), the
current standard deviation (red), and the current throughput rate (green) are displayed in
milliseconds.
Spline Visualizer
The Spline Visualizer provides a view of all sample times from the start of the test till the end,
regardless of how many samples have been taken.
The Response Time Graph draws a line chart showing the evolution of response time during the
test, for each labelled request. If many samples exist for the same timestamp, the mean value is
displayed.
Aggregate Graph
The aggregate graph is similar to the aggregate report. The primary difference is the aggregate
graph provides an easy way to generate bar graphs and save the graph as a PNG file.
Listener -Table
A listener tables is a component that shows the results of the samples in tables.
23
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
Aggregate Report
The aggregate report creates a table row for each differently named request in your test. For each
request, it totals the response information and provides request count, min, max, average, error
rate, approximate throughput (request/second) and Kilobytes per second throughput.
This visualizer creates a row for every sample result. Like the View Results Tree, this visualizer
uses a lot of memory.
Summary Report
The summary report creates a table row for each differently named request in your test. This is
similar to the Aggregate Report, except that it uses less memory.
Workbench
Workbench is the part of Jmeter, when we open jmeter, we see both test plan and workbench
Workbench is used for temporary storage, whatever we want to put temporary we can cut from
test plan and paste in work bench
When we save test plan, it does not save workbench with it, we need to save workbench data
separately, saved as jmx file
24
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
Http mirror server is simple proxy server which send request as a response, so we can check our
request element.
Debug Sampler
• Jmeter Variables
• Jmeter Properties
• System Properties
Result can be seen in View Result Tree Listener
Debug Post Processor add a Sub Sampler to each of the sampler of the scope.
Test Action
Execute before all available thread group, it is used for initialization of different values,
properties etc.
25
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
Execute After all thread groups, it is used for terminating the values
Distributed testing means apply the load on server from multiple computers, rather than a single
resource.
Practically if we think, in real world scenario, load on server is going from multiple computer but
while testing if we apply load from a single computer so ultimately all user are going to use
single system resources & network so the we can understand that performance will not be exact
to real world.
In Distributed testing, we run jmeter server on multiple computers there computer are
called Slave system.
Server running on multiple computers are handled by a single computer is called Master
System.
Target : is the server to which we are going to send request while working.
26
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
Note : We should have jre installed in our system and after installing server, it
should display view like as we see below.
2 Same like step 1, jmeter server should start on all slave machines.
Search remote_hosts
remote_hosts=192.168.145.1
In Runà Remote Start, we can see all ip address which we added in jmeter properties file
If we want to run it on any particular server then select Run à Remote Startà Select IP
If we want to run it on all servers than select Runà Remote Start All.
6 If we select Remote Start All, then all threads(selected in Thread Group) will be executed in all
server Eg.
If we select 4 threads in thread group and we have 5 slave(jmeter server), then we select Runà
Remote Start All so total 20 users( 4 thread X 5 slave) will execute at a time.
After running test plan from Master, on server(Slave Machine) we can see lines added for start
and end of test plan.
27
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
Functions in Jmeter
Functions are special values in jmeter that can populate field of sampler and any other element.
Function that does not require parameter, need not to place brackets like
${__threadNum}
If Function parameter have comma then we need escape character(\) before that
IF we need to send variable as function parameter, variables can be used like ${variable}
If we use variable which is undefined, it will not make any error, will use variable as data
Properties are not same as variable, properties are global to all threads, variables are local
We can generate functions using Function Helper Dialog Box (under Options)
Type of
Name Comment
function
Return Number of Thread(No Argument is requiredReturn
Information threadNum
Number of Thread(No Argument is required
Return the local machine name, Name the variable in which
Information machineName
return value want to save
Return IP address of the machine, Name the variable in which
Information machineIP
return value want to save
Return current time in various formats, we can pass time format
Information time
and variable in which we want to save this
Information log log (or display) a message (and return the value—Input String)
log (or display) a message (empty return value--- No value
Information logn
returned)
Read a line from a file(dat file) Each time its called, read next
line from file Different threads will call different line, if EOF
Input StringFromFilethen read from 1st line For each time we use this function, file
will open once If we use this function 2 places, same file will be
open on 2 separate places
Input CSVRead read from CSV delimited file
Input XPath Use an XPath expression to read data from an XML file
Scripting
Scripting jexl evaluate a Commons Jexl expression
BSF in JMETER
(BEAN Scripting FRAMEWORK) – we have different BSF elements like sampler etc
which can be used while creating test plan, we can write our own coding there to perform
specific tasks.
1 Java Script, JEXL, XSLt -- already implemented, we just need to select language and
write code.
2 Groovy, java etc : we need to add specific Jar in LIB folder to support that.
29
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
Example of BSF sampler : using Java Script
if (${nitin}>10)
vars.put("result","number is greater");
else
vars.put("result","number is lesser");
WE already have few declared BSF variables that can be used directly while scripting.
30
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
The SampleResult ResponseData is set from the return value of the script. If the script returns
null, it can set the response directly, by using the method SampleResult.setResponseData(data),
where data is either a String or a byte array. The data type defaults to "text", but can be set to
binary by using the method SampleResult.setDataType(SampleResult.BINARY).
The SampleResult variable gives the script full access to all the fields and methods in the
SampleResult. For example, the script has access to the methods setStopThread(boolean) and
setStopTest(boolean).
Unlike the Beanshell Sampler, the BSF Sampler does not set the ResponseCode,
ResponseMessage and sample status via script variables. Currently the only way to changes these
is via the SampleResult methods:
• SampleResult.setSuccessful(true/false)
• SampleResult.setResponseCode("code")
• SampleResult.setResponseMessage("message")
if (${nitin}>10 )
else {
31
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
BSF VARIABLES
BSF Variables
=====================================================================
=
• SampleResult.setSuccessful(true/false)
• SampleResult.setResponseCode("code")
• SampleResult.setResponseMessage("message")
** Now login is recorded, the problem which stuck me is that, when I am running back this
login, it display all sample pass but I was not able to login
So as per my finding that that samplers are passed because, all request are going to server and
server send response as well(even it was not a correct response but we are getting response so its
getting passed)
** How we can see that after login step we are getting correct screen or not? How to do
debug
For that I found my own method, I used a Listener-> Save Response to file, after login sampler I
added this listener, so after the complete script ran, I go to bin directory I find saved response, I
can view that response display the correct screen or not.
32
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
** How can we compare request and response that we are getting at time of recording are
same in running.
While recording, use Listenerà View Result Tree, after recording here we can see request and
response data for each and every sample. We can copy that data, now while running use same
listener here again we will get request and response
** While running script getting failed, what is the reason for that ?
One most common reason what I found is that, request which goes to server want some cookies
data but cookies data are not available so to use that cookie data we can use, Config Elemenetà
Http Cookie manager, we can add this in thread group it will handle all cookies and send data
with further requests.
Http Header manager, let us to customize information of request header, we can use it with each
sampler, in that case all values in Http header manager will merge and sent as a header of any
sampler(request)
If we are using Http header manager at both Thread level and Sampler level, then sampler lever
entries will go with request.
If any value is empty with sampler level in this case value at thread level will go with sampler.
Http cookie manager is used to hold to cookie-value that are coming from server, in case of
browser, browser hold this cookie value which is send with every request but in case of Jmeter,
we don’t use browser so we use that cookie manager which hold these values so any request
which need cookies can pick the value from cookie manager.
33
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
Http Cache manager is used to implement browser cache functionality in Jmeter. Like Http
Cookie manager it is also added at the thread level.
• cache mainly hold response coming from server, when we make a request again to that server it
first check if the latest value is still exist in cache request will pick that resource from cache,
advantage is that page get load fast and reduce network traffic as well.
** What is Http Authorization Manager??
Http Authorization manager is mainly used when we are going to access restricted pages that
need user authorization before access, that kind of page open a login window. To handle that
kind of pages in Jmeter we used Http Authorization manager.
ANSWER: JMeter is one of the Java tools which is used to perform load testing client/server
applications. Apache JMeter is open source software, a 100% pure Java desktop application
designed to load test functional behavior and measure performance of the application. It was
originally designed for testing Web Applications but has since expanded to other
test functions.
• Support Distributed Testing: So that we can distribute load on multiple machine, so that we can
simulate load on server, network or object which are coming from different machine to
implement real world scenario.
• Record & Playback - Record the user activity on the browser and simulate them in web
application using JMeter.
34
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
ANSWER: The protocols supported by JMeter are: Web: HTTP, HTTPS sites 'web 1.0' web 2.0
(ajax, flex and flex-ws-amf)
Directory: LDAP
FTP Service
• JMeter can load and performance test many different server types: Web - HTTP, HTTPS,
SOAP,
• It has full Swing and lightweight component support (precompiled JAR uses packages
javax.swing .* ).
35
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
• JMeter store its test plans in XML format. This means you can generate a test plan using a text
editor.
• It's full multi-threading framework allows concurrent sampling by many threads and
simultaneous sampling of different functions by separate thread groups.
• It is highly extensible.
• Can also be used to perform automated and functional testing of your application.
ANSWER: JMeter acts like a group of users sending requests to a target server. It collects
response from target server and other statistics which show the performance of the application or
server via graphs or tables.
ANSWER: A Test Plan defines and provides a layout of how and what to test. For example the
web application as well as the client server application. It can be viewed as a container for
running tests. A complete test plan will consist of one or more elements such as thread groups,
logic controllers, sample-generating controllers, listeners, timers, assertions,
and configuration elements. A test plan must have at least one thread group.
• ThreadGroup
• Controllers
• Listeners
• Timers
• Assertions
• Configuration Elements
36
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
• Pre-Processor Elements
• Post-Processor Elements
ANSWER: Distributed load testing is the process using which multiple systems can be used for
simulating load of large number of users. The reason of using more than one system for load
testing is the limitation of single system to generate large number of threads (users). In JMeter
we can do distributed load testing using the master slave configuration.
ANSWER: To make the best out of the available resources and in general as a practice,
following practices should be incoroprated in the tests- • Use non-GUI mode: jmeter -n -t
test.jmx -l test.jtl
• Use as few Listeners as possible; if using the -l flag as above they can all be deleted or
disabled.
Don't use "View Results Tree" or "View Results in Table" listeners during the load test, use them
only during scripting phase to debug your scripts.
• Rather than using lots of similar samplers, use the same sampler in a loop, and use variables
(CSV Data Set) to vary the sample. Or perhaps use the Access Log Sampler. [The Include
Controller does not help here, as it adds all the test elements in the file to the test plan.]
37
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
ANSWER: Thread Group elements are the beg inning points of your test plan. As the name
suggests, the thread group elements control the number of threads JMeter will use during the test.
Thread group elements are the beginning points of any test plan.
• Listeners, may be placed directly under the test plan, in which case they will apply to all the
thread groups.
ANSWER: JMeter has two types of Controllers: Samplers Controllers: Samplers allow JMeter to
send specific types of
requests to a server. They simulate a user's request for a page from the target server. For
example, you can add a HTTP Request sampler if you need to perform a POST, GET, DELETE
on a HTTP service.
Logical Controllers: Logic Controllers let you control order of processing of Samplers in a
Thread. Logic Controllers can change the order of request coming from any of their child
elements. Some examples are: For
Controller, While Controller, Loop Controller, IF Controller, Run Time Controller, Interleave
Controller, Throughput Controller, Run Once Controller.
38
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
ANSWER: The Workbench is simply an area to store test elements while you are in the process
of constructing a test. The Workbench is a sandbox for any test or portion of a test that you are
working on. When you are ready to test what you have designed in the Workbench, you can copy
or move the elements into the Test Plan.
It also contains Non- Test Elements Http mirror sever Http Proxy server {which is not available
in the thread group & Test plan }
ANSWER: A configuration element works closely with a Sampler Configuration elements can
be used to set up defaults and variables for later use by samplers.
Note that these elements are processed at the start of the scope in which they are found, i.e.
before any samplers in the same scope.
ts elements:
• CSV Data Set Config: Used to read lines from a file, and split them into variables.
• HTTP Authorization Manager : You can specify one or more user logins for web pages that are
restricted using server authentication
• Java Request Defaults: You can set default values for Java testing
• HTTP Cookie Manager: The Cookie Manager element has two functions:
Manager. However, if you do this, the cookie will be shared by all JMeter threads.
• HTTP Request Defaults: This element lets you set default values that your HTTP Request
controllers use.
• HTTP Header Manager : The Header Manager lets you add or override HTTP request headers
39
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
ANSWER: Listeners let you view the results of Samplers in the form of tables, graphs, trees or
simple text in some log files. They provide visual access to the data gathered by JMeter about the
test cases as a Sampler component of JMeter is executed.
Listeners can be added anywhere in the test, including directly under the test plan. They will
collect data only from elements at or below their level
• Spline Visualizer
• Aggregate Report
• Monitor Results
• Distribution Graph
• BeanShell Listener
QUESTION: What does “contain” and “matches” indicates in the regular expression?
ANSWER: In the regular expression, contains indicates that the regular expression matched at
least some part of the target. While matches means the regular expression matched the whole
target. So, „alphabet‟ is “matched” by „al.*t.‟
40
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
QUESTION: Explain what is timer in JMeter and what are the type’s timer in JMeter?
ANSWER: JMeter thread by default will send requests continuously without any pause. To get a
pause between the request, Timers are used.
• Constant Timer
• Synchronizing Timer
ANSWER: Assertion helps to verify that your server under test returns the expected results.
• Response Assertion
• Duration Assertion
• Size Assertion
• XML Assertion
• HTML Assertion
Example: Customer like to withdraw money from an ATM counter, customer inserts debit or
credit card and wait for the response. If system takes more than 5 min. then according to
requirements system functioning is fail.
41
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
• Load: analogous to volume testing and determine how application deal with large amount of
data.
• Capacity: measure overall capacity and determine at what time response time become
unacceptable.
ANSWER: JMeter functions are special values that can populate fields of any Sampler or other
element in a test tree. A function call looks like this:
${__functionName(var1,var2,var3)}
Configuration elements
• Pre-processors
• Timers
• Samplers
• Post-processors
• Assertions
• Listeners
42
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
QUESTION: Explain how you can capture the script of the authentication window in
JMeter?
• First you have to Thread group in Test plan and then make HTTPProxyServer in Workbench
• After that, set port number in Global Setting box (e.g., 8911) and modify your connection
setting in IE as local host in address 8911 as in port Then you can start http proxy server in
JMeter and run your application for login
43
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING