Nothing Special   »   [go: up one dir, main page]

Performative Jmeter Material.

Download as pdf or txt
Download as pdf or txt
You are on page 1of 43
At a glance
Powered by AI
JMeter is an open source tool used for performance and load testing of web applications. It can test HTTP, FTP and other network protocols. It allows recording and simulating user sessions to test server performance under load.

JMeter is mainly used for performance testing but can also be used for load, functional and regression testing. It simulates user load on a server by generating and handling multiple client requests.

The main types of performance testing are load testing, stress testing and capacity testing. Load testing is done under normal conditions. Stress testing is done under abnormal high load conditions. Capacity testing determines the maximum load or capacity of the system.

PERFORMATIVE JMETER MATERIAL

HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY

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.

• Java Based Window Application.


• Support many type of applications like HTTP, Web Service, LDAP, JDBC, Java, FTP etc.
• 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.
How does JMeter works
JMeter simulates a group of users sending requests to a target server, and returns statistics
data/information of the target server/application via tables, graphs, 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.

Load Testing : It is performed in normal conditions like if application is supposed to work on


100 users then we perform load testing from 90-110 users.
The aim of this testing is to find out at what point application performance will start to degrade.

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.

Steps to Install JMeter

Step 1: Check / Install JAVA


Check, Java is installed in your system, should have jvm1.8+, and Environment variable
JAVA_HOME is set.

1
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY

Step 2: Download JMeter : Download zip from http://jmeter.apache.org/download_jmeter.cgi

Step 3: Unzip it.

Step 4: Launch JMeter


Once the unzipping is done go to Jmeter Folder, Bin Directory, click on Jmeter.bat file, Jmeter

will run.

By Default, when we open Jmeter, we find TestPlan and Workspace


1. We use Testplan for our scenario building.
2. We can use Workspace for recording in jmeter.
Note: When we save test plan, it will save content of TestPlan only,if we want to save
Workspace, for that we need to right click on that and go to save As.(it will save Workspace part
as a separate jmx file).

What is Test Plan?

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.

What is Thread Group?


It can be defined as a test case, which can have multiple element which behave as test steps.
1 Each thread group represents one user using the application under test.
2 We can set number of threads here(virtual users).
3 We can set loop count here(number of time test case we want to iterate).
4 We can set ramp up time here(60 threads in 60 seconds—means 1 thread will go on server in
every 1 second).
5 We can schedule, start time and end time for test case execution, as well as startup delay and
execution time as well.
For example, if you set the number of threads as 100, JMeter will create and simulate 100 user
requests to the server under test

2
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY

Jmeter : Elements in Jmeter

Elements Groups in Jmeter.

1 Samplers : Samplers are used to send requests to server.

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.

4 Timers : Timers are used to insert delay in execution.

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.

8 Listerners: are used to display results.

Execution Flow of Different Elements

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

Running and Stopping test plan

To Run Go to Runà Start or Start Remotely (Ctrl+R)

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.

Starting Modes in Jmeter

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.

JVM setting for Jmeter

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.

CLASS PATH FOR JMETER

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

Using Jmeter Behind Proxy Server/Firewall

For that we need to run Jmeter from Command Prompt.

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

How To Use JMeter To Record Test Scenarios

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

Here is a list of the software that this tutorial requires:

• Apache JMeter
• Java 6 or later
• Mozilla Firefox

Start Building a Test Plan

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.

Steps to Record Test Scenarios

1. Go to JMETER_HOME/bin and start JMeter.

1. Select “Test Plan” on the tree.


2. Right click on the “Test Plan” and add a new thread group: Add > Threads (Users) >

Thread Group.

1. Select the Thread Group


2. Right click “Add -> Config Element -> HTTP Request Defaults”

1. In new HTTP Request Defaults element: Server name – enter


“www.thetestingworld.com”

2. Path – leave blank

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

Controller > Recording Controller

1. Next, select WorkBench


2. Right click on WorkBench and add the recorder: Add -> Non-Test Elements -> HTTP(S)

Test Script Recorder

1. On HTTP(S) Test Script Recorder, click the “Add” button in “URL Patterns to Include”.

This will create a blank entry; enter “.*\.html” & “.*\.php”.

1. Right click on “HTTP(S) Test Script Recorder” and add a listener: Add -> Listener ->

View Results Tree

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. Start Firefox, but do not close JMeter.


2. From the tool bar, click “Tools > Preferences”. This should bring up the options.
3. Select the “Advanced” tab, and “Network” tab

4. Click “Settings” button near the bottom.

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”.

4. Check “Use this proxy server for all protocols”


Record your navigation

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

1. Click on a few links on pages.

2. Close your browser and bring up the JMeter window.


Expand the thread group and there should be several samplers. At this point, the test plan can be
saved as is. If you forget to add default HTTP Request settings, you will have to manually delete
the server name, and port. In this sample, there aren’t any default request parameters. If a
particular request parameter is required by all pages, the request defaults is where one would add
the entries.

Element reference for JMeter

The different components of JMeter are called Elements. Each Element is designed for a specific
purpose.

The figure below gives the some common elements in JMeter.

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

Timers are used to insert delay in execution.

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

Listeners are used to display results.

Execution Flow of Different Elements

1. Config Element
2. Pre Processors
3. Timers
4. Samplers
5. Post Processors
6. Assertions
7. Listeners
Running and Stopping test plan

To Run, Go to Run- Start or Start Remotely (Ctrl+R)

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?

JMeter gives us a feature to do that. It’s Logic Controllers.

• Logic Controllers determine the order in which Samplers are processed.


• With Logic Controllers, we can manage the order of execution of different elements in test plan.
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.

• Do nothing controller, used for grouping steps.

• This controller only helps in binding the child samples.


Loop Controller

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

Random Order Controller

Same as simple controllers, but elements will execute in random order.

For Example: We have 3 request :

1. HTTP request
2. FTP request
3. JDBC request
In each loop, user requests send sequentially in following order,

HTTP request -> FTP request-> JDBC request

In each loop, user requests send randomly in following order,

FTP request -> HTTP request-> JDBC request

Or

JDBC request -> FTP request-> HTTP request

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

Run Time Controller

The Runtime Controller controls how long its children are allowed to run.

Define time period to which elements of controller will execute.

Throughput Controller

Do not use for controlling throughput

• We can set either percentage or number of times


• So controller element will execute to the given percentage of total available loop.

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.

Once Only Controller

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.

Inter Leave Controller

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 in JMeter

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.

CSV Dataset Config

• 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

http request, we can use this config element.

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.

User Defined Variables

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.

HTTP Cache Manager

It is used to implement browser cache functionality in our test plan.

HTTP Cookie Manager

It is used to store cookies value which are coming from server and automatically send these
cookies with sampler request whenever required.

• Maintain a separate copy of cookies for each thread.


• It save cookie value internally, we can’t view that, to view it, and we need to go to Tree Listener.
• We can add user defined cookies here.

14
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY

Http Authorization Manager

We can use this config element to access restricted pages. Restricted pages are those which need
username and password to open that pages.

Login Config Element

This config element is used to override login sampler.

HTTP header manager

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

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.

Thread Delay is Number of milliseconds to pause.

Uniform Random 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

Gaussian Random Timer

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).

Constant Throughput Timer

This timer is used to control throuhput(request/sec) going to server.

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

We can write Bean shell script to create timer.

BSF Timer

We can write Timer in javascript or other supported scripts.

Pre Processor in JMeter

Pre-processor executes some action before making Sampler Request.

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.

Add Post-Processor Element

Right Click Thread Group -> Add -> Pre Processors.

16
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY

Types of Pre-Processor in JMeter

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

It is used to define variable and value which will be used in sampler.

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.

HTTP URL Re-writing Modifier

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

RegEx User Parameters

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 in JMeter

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.

Add Post-Processor Element

Right Click Thread Group -> Add -> Post Processor -> Result Status Action Handler

Types of Post Processor in JMeter

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.

Regular Expression Extractor

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:

/html/head/title extracts title element from HTML response

/book/page[2] extracts 2nd page from a book

/book/page extracts all pages from a book

Result Status Action Handler Extractor

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.

BSF Post Processor

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

(JMeterProperties class java.util.Properties) e.g. props.get(“START.HMS”);


props.put(“PROP1″,”1234”);

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.

Assertion is to make sure there were no errors in the response.

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

Types of Assertion in JMeter

Following are the different types of assertions available in JMeter.

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.

Some sample expressions:

• //title[text()=’Text to match’] – matches <text>Text to match</text> anywhere in the response


• /title[text()=’Text to match’] – matches <text>Text to match</text> at root level in the response

Compare Assertion

Compare Assertion compare the results/response for different requests/samplers made in the
scope.

Here we can compare content as well as elapsed time.

If elapsed time is 0 t means all response should take same time.

If greater then 0, means response time can differ by given time.

21
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY

We can filter response before assertion.

We can view Compare Assertion result in “COMPARE ASSERTION VISUALIZER”

Size Assertion

Here we can define the expected size in bytes of response.

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

Bean Shell Assertion

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.

Sample Result save Configuration

Listeners can be configured to save different items to the result log files (JTL) by using the
Config popup as shown below.

Listener -Graph

Plot the results on 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

Listener – View Results Tree

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

Log show summary of test result in the text file.

Listener -Graph

Plot the results on 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.

Response Time Graph

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.

View Result in Table

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.

Important Elements in JMeter

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

We use Workbench while recording in JMeter. For details about recording


usehttp://www.thetestingworld.com/recording-in-jmeter/

Certain test elements are only available on the WorkBench:

• HTTP(S) Test Script Recorder


• HTTP Mirror Server
• Property Display
HTTP(S) Test Script Recorder(HTTP Proxy Server)

• We find HTTP proxy server only in Workbench.


• We can setup this server, so that all request that we send from Jmeter, will pass from HTTP
proxy server.

24
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY

• It is mainly used while recording in Jmeter.


HTTP Mirror Server(Workbench -> Non Test Element)

Http mirror server is simple proxy server which send request as a response, so we can check our
request element.

Properties Display(Workbench Non Test Element)

Here it display all system properties as well as jmeter properties

Here we can change value as well.

Debug Sampler

Debug sampler is the part of sampler in jmeter, It add a sampler

With Debug sampler we can view,

• Jmeter Variables
• Jmeter Properties
• System Properties
Result can be seen in View Result Tree Listener

Debug post Processor

Debug Post Processor add a Sub Sampler to each of the sampler of the scope.

It display the properties of last sent request.

Test Action

It is used to stop or pause thread(s) at runtime

SetUp() Thread Group

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

• Use for Pre-test actions.


Tear Down Thread group

Execute After all thread groups, it is used for terminating the values

Use for Post test actions.

DISTRIBUTED TESTING IN JMETER

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.

Few Prerequisites for distributed testing:

1 All system(master & slave) should be in same subnet.

2 Firewall should be off on all systems.

3 Make sure same version of jmeter on all system.

4 IMP : All jmeter server should start on Slave systems.

26
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY

START DISTRIBUTED TESTING

1 Start Jmeter Server on all Slave system( Run Jmeter-Server.bat file)

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.

3 Go to Master Machine, bin directory, open jmeter.properties file in notepad

Search remote_hosts

Enter IP of your slave computer here, separated by comma

remote_hosts=192.168.145.1

4 On Master System, start Jmeter by executing Jmeter.bat file

In Runà Remote Start, we can see all ip address which we added in jmeter properties file

5 Create Jmeter Test Plan,

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 call look like ${__functionName(va1,va2)}

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

Calculation counter generate an incrementing number


Calculation intSum add int numbers

Calculation longSum add long numbers


28
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY
Calculation Random generate a random number

Scripting BeanShell run a BeanShell script

javaScript process JavaScript (Mozilla Rhino)

Scripting
Scripting jexl evaluate a Commons Jexl expression

Properties property read a property


Properties P read a property (shorthand method)
Properties setProperty set a JMeter property

Variables split Split a string into variables


Variables V evaluate a variable name
Variables eval evaluate a variable expression
Variables evalVar evaluate an expression stored in a variable

String regexFunction parse previous response using a regular expression


String char generate Unicode char values from a list of numbers
String unescape Process strings containing Java escapes (e.g. \n & \t)
String unescapeHtml Decode HTML-encoded strings
Encode strings using HTML encoding
String escapeHtml

BSF in JMETER

BSF : Bean Scripting Framwework ( http://commons.apache.org/bsf/index.html)

(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.

It support number of scripting language like,

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.

• log - the Logger


• Label - the Sampler label
• FileName - the file name, if any
• Parameters - text from the Parameters field
• args - the parameters, split as described above
• SampleResult - pointer to the current SampleResult
• sampler - pointer to current Sampler
• ctx - JMeterContext
• vars - JMeterVariables - e.g. vars.get("VAR1"); vars.put("VAR2","value");
vars.remove("VAR3"); vars.putObject("OBJ1",new Object());
• props - JMeterProperties - e.g. props.get("START.HMS"); props.put("PROP1","1234");
• OUT - System.out - e.g. OUT.println("message")

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")

BSF SAMPLER USING GROOVY

Step 1: - Download Jar for Groovy


from http://www.java2s.com/Code/Jar/GHI/Downloadgroovyjar.htm

Step 2: - Put the downloaded jar in lib folder.

Step 3: - Restart jmeter

Step 4: Write Groovy coding

if (${nitin}>10 )

vars.put("nitin","number is greater than 10 ")

else {

vars.put("nitin","number is less than 10 ") }

31
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY

BSF VARIABLES

BSF Variables

=====================================================================
=

OUT.println("messgage")-- it will display message on jmeter screen(Black jmeter cmd


screen)

SampleResult.setResponseData("HELLO") -- It is used to set response which will come against


the BSF sampler

In case of Bean shell, we can set

• SampleResult.setSuccessful(true/false)
• SampleResult.setResponseCode("code")
• SampleResult.setResponseMessage("message")

In case of groovy etc in BSH we can use only : SampleResult.setResponseData(data)

** 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

data, we can compare this data with previously saved data.

For data comparison we can use software Beyond Compare

** 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.

** What is HTTP Header Manager ?

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.

It is mainly used to create default header.

** What is HTTP Cookie manager ??

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.

Cookie manager is mainly used with thread level

We can define our own cookies as well

33
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY

** What is HTTP Cache manager??

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.

Important Questions and Answers in Jmeter

QUESTION: What is JMeter?

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.

• Java Based Window Application.

• Support many type of applications like HTTP, Web

Service, LDAP, JDBC, Java, FTP etc.

• 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

QUESTION: What are the protocols supported by JMeter?

ANSWER: The protocols supported by JMeter are: Web: HTTP, HTTPS sites 'web 1.0' web 2.0
(ajax, flex and flex-ws-amf)

Web Services: SOAP / XML-RPC

Database via JDBC drivers

Directory: LDAP

Messaging Oriented service via JMS

Service: POP3, IMAP, SMT P

FTP Service

QUESTION: List some of the features of JMeter.

ANSWER: Following are some of the features of JMeter:

• It‟s an open source software.

• It has simple and intuitive GUI.

• JMeter can load and performance test many different server types: Web - HTTP, HTTPS,
SOAP,

• Database via JDBC, LDAP, JMS, Mail - POP3

• It is platform-independent tool. On Linux/Unix, JMeter can be invoked by clicking on JMeter


shell script.

• On Windows it can be invoked by starting the jmeter.bat file.

• 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.

QUESTION: Explain how JMeter works?

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.

QUESTION: What is a Test Plan in JMeter?

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.

QUESTION: List some of the test plan elements in JMeter.

ANSWER: Following is a list of some of the test plan elements:

• 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

QUESTION: What is distributed load testing? How can it be achieved in JMeter?

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.

QUESTION: How can we reduce the resource requirement in JMeter?

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.]

• Don't use functional mode

• Use CSV output rather than XML

• Only save the data that you need

• Use as few Assertions as possible

37
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING
PERFORMATIVE JMETER MATERIAL
HIMACHALAPATHI REDDY RAVIKUMAR REDDY NAGARAJU REDDY

QUESTION: What is Thread Group?

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.

• All controllers and samplers must be under a thread group.

• Listeners, may be placed directly under the test plan, in which case they will apply to all the
thread groups.

• The controls for a thread group allow you to:

• Set the number of threads

• Set the ramp-up period

• Set the number of times to execute the test

QUESTION: What are Controllers and its types?

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

QUESTION: What is Work bench?

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 }

QUESTION: What is Configuration element?

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:

o It stores and sends cookies just like a web browser.

o Second, you can manually add a cookie to the Cookie

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

QUESTION: What are Listeners?

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

Some of the JMeter Listeners are

• Spline Visualizer

• Aggregate Report

• View Result Tree

• View Result in Table

• Monitor Results

• Distribution Graph

• BeanShell Listener

• Summary Report and so on

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.

Some of the Timers used are:

• Constant Timer

• Gaussian Random Timer

• Synchronizing Timer

QUESTION: Explain what is Assertion in JMeter?

What are the types of assertion?

ANSWER: Assertion helps to verify that your server under test returns the expected results.

Some commonly used Assertion in JMeter are:

• Response Assertion

• Duration Assertion

• Size Assertion

• XML Assertion

• HTML Assertion

QUESTION: Why Performance Testing is performed?

ANSWER: Performance Testing is performed to evaluate application performance under some


load and stress condition. It is generally measured in terms of response time for the user activity.
It is designed to test the whole performance of the system at high load and stress condition.

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

Type of Performance Testing:

• Load: analogous to volume testing and determine how application deal with large amount of
data.

• Stress: examine application behavior under peak bursts of activity.

• Capacity: measure overall capacity and determine at what time response time become
unacceptable.

QUESTION: What are JMeter Functions?

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)}

QUESTION: Mention the execution order of Test Elements?

ANSWER: The test plans elements execution order is:

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?

ANSWER: Normally, you can capture script by recording.

• 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

Jmeter interview questions


1. Which version of jmeter are you used?
2. How to record script record in jmeter?
3. What are the controllers are used in jmeter?
4. What are the difference between simple controller and transaction controller?
5. What is throughput controller ? what is it use?
6. What are the timers have you use?
7. How to uses rendezvous point in jmeter?
8. What is assertion? And what kind of assertions you use in your script?
9. What Is listener?
10. What type of listners have you used?
11. What is aggregate report? What are the parameters are there in the aggregate report?
12. What are the challenges you faced in jmeter?
13. How do you do the parametrization in the jmeter?
14. How do you do the correlation in the jmeter?
15. What are the challenges you faced will doing webservices script in jmeter?
16. What is beanshell? What situation you used?
17. What is the difference between pre-processor and post-processor?
18. What is the command for non-gui execution mode?
19. What is the intention of running in non-gui mode?
20. While executing am getting out of memory?
21. What is ultimate thread group? What is the benefits of ultimate thread group?
22. I am getting some error like authorization issue? How you mange that?
23. Why you recommend jmeter tool for your application?
24. What is the extension of jmeter?
25. What is the extension for the test result file extension?
26. How will you retrieve data(Results) you are executing non-gui mode?

43
PERFORMATIVE INSTITUTE FOR PERFORMANCE TESTING

You might also like