You are on page 1of 19

School of Information Technology & Engineering

MTech Software Engineering(Int)


WINTER 2020-2021

Software Testing (SWE2005)

Software Testing Tool: Apache Jmeter


Review-2

N.Siva Sai Akhilesh 19MIS0309

Faculty Name: SENTHIL KUMAR. M


Intoduction:
JMeter is an software that can be used to execute performance testing, load
testing and functional testing of your web applications.Apache JMeter may be
used to test performance both on static and dynamic resources, Web dynamic
applications.It can be used to simulate a heavy load on a server, group of
servers, network or object to test its strength or to analyze overall performance
under different load types. JMeter is mainly used for testing Web application or
FTP application but currently, it is applicable in functional testing, JDBC
database connections, Web services, generic TCP connections and OS native
processes. You can perform various testing activities like Performance, Load,
Stress, Regression and Functional testing, in order to get accurate performance
metrics against your web server.

How does JMeter perform Testing?


Let’s have a look at the different steps performed by JMeter during testing:

1. It creates a request and sends to the server.


2. It receives the response from server, collects them and visualizes those
details in a chart or graph.
3. It processes the response from the server.
4. It generates the test result in several formats such as text, XML, JSON so
that the tester can analyze data.
• Performance Test − This test sets the best possible performance
expectation under a given configuration of infrastructure. It also highlights
early in the testing process if any changes need to be made before the
application goes into production.
• Load Test − This test is basically used for testing the system under the top
load it was designed to operate under.
• Stress Test − This test is an attempt to break the system by overwhelming
its resources.

JMeter Features
Following are some of the features of JMeter −
• It has a simple and intuitive GUI.
• JMeter can conduct load and performance test for many different server types
− Web - HTTP, HTTPS, SOAP, Database via JDBC, LDAP, JMS, Mail - POP3,
etc.

• It is a 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.* ).
• JMeter store its test plans in XML format. This means you can generate a test
plan using a text editor.
• Its full multi-threading framework allows concurrent sampling by many threads
and simultaneous sampling of different functions by separate thread groups.
• It is highly extensible.
• It can also be used to perform automated and functional testing of the
applications.
JMeter Test Plan Elements
JMeter comprises of various elements which co-relates with each other but
designed for different purposes.

Following are some of the major components of JMeter:

o Test Plan
o Thread Group
o Controllers
o Listeners
o Timers
o Configuration Elements
o Pre-Processor Elements
o Post-Processor Elements
Test Plan
A test plan can be visualized as your JMeter script for running tests. A test plan
consists of test elements such as thread groups, logic controllers, sample-
generating controllers, listeners, timers, assertions, and configuration elements.

A test plan consists of all steps which execute the script. Everything which is
included in a test plan is executed in a sequence which is top to bottom or as per
the defined sequence in the test plan.

Thread Group
As the name implies, thread group represents the group of threads JMeter will
use during the test. Thread group elements are the beginning points of any test
plan. The controls provided by a thread group allow you to:

o Set the number of threads.


o Set the ramp-up period.
o Set the number of times to execute the test.

The steps to add a thread group in your test plan had been explained earlier in
the Add/Remove test elements portion

The following image shows the control panel portion of a thread group.
Controllers
Logic Controllers help you to control the flow the order of processing of
samplers in a thread. It can also change the order of requests coming from their
child elements.

Conntrollers can be divided into two broad categories:

1.Samplers 2.Logical Controllers

Samplers
Samplers are the components which allow JMeter to send specific types of
requests to a server.It simulates a user's request for a page to the target
server.Samplers are a must to add component to a test plan as only it can let
JMeter know what type of request need to go to a server. Requests could be
HTTP, HTTP(s), FTP, TCP, SMTP, SOAP etc.
Listeners
Performance testing is all about analysing server responses in various forms and
then presenting the same to the client.Listeners provide pictorial representation
of data gathered by JMeter about those test cases as a sampler component of
JMeter is executed. It facilitates the user to view samplers result in the form of
tables, graphs, trees or simple text in some log file.Listeners can be adjusted
anywhere in the test, including directly under the test plan.
Timers
When you perform any operation on a website or app, they naturally have
pauses and delays. These can be simulated with Timers.

JMeter sends requests without applying any delay between each


sampler/request. If you perform load/stress testing on your server without any
delay, it will be overloaded. This not exactly what you want. You can add a
timer element which will permit you to define a period to wait between each
request.

Configuration Elements
Working of configuration elements is quitesimilar to those of
samplers.However, it does not send requests but it allows you to modify the
requests made by the samplers.

It is a simple element where you can collects the corporate configuration values
of all samplers like webserver's hostname or database url etc.

1.Timer 2.Configuration Elements


Pre-processor Elements
A Pre-Processor element is executed just before the request made by the
sampler. If a Pre-processor is attached to a sampler element then it will execute
just prior to that sampler element running.A Pre-processor element is used to
modify the settings of a sample request just before it runs, or to update variables
that are not extracted from response text.

Post-processor Elements
A Post-processor element is executed 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, for example, to extract a particular value for future purpose.
Step by Step process for Load testing in Jmeter:
Step 1 – Install Java:
JMeter is pure Java desktop application and it requires a fully compliant JVM 6
or higher. You can download and install the latest version of Java SE
Development Kit.

Step 2 – Download Jmeter:

The Latest version of JMeter available is 5.1. You can download any
of the binaries.

Step 3 – Install Jmeter:


Installation of JMeter is extremely easy and simple. You simply unzip the
zip/tar file into the directory where you want JMeter to be installed. There is no
tedious installation screen to deal with. To run the jmeter, go to the folder
the /jmeter/bin and run jmeter.bat file.
If you are using Window, just run the file /bin/jmeter.bat to start JMeter in GUI
mode

Step 4 – Create test plan:


A useful test plan is created with minimum 3 components –
1. Thread Group – contains the simulation of multiple concurrent users. A
single thread represent a single user. We can create any number of threads
to put the desired load on the application. It also help us in scheduling the
delay between two threads, and any repetition of request batches.
2. HTTP Request – consist the HTTP request configuration which thread
group will be invoking. It is the application URL which you want to load
test.
3. Listener – helps in viewing the result of the whole testing process. There
are multiple listener available in jmeter to verify the testing results.
Step -- 4.1. Create Thread Group
To create a thread group, navigate to ‘Right click Test Plan -> Add -> Threads -
> Thread Group’.
Create Thread Group Option
Fill in the values as per your requirements (or based on your assumptions, we
can change them anytime in future). Name the thread group and save it to any
location in your workstation.

Thread Group Created

Step -- 4.2. Create HTTP Request


To add HTTP request details, navigate to ‘Right click thread group -> Add ->
Sampler -> HTTP Request’.
< Create HTTP Request[/caption]>

Fill in the application URL details which we are going to test

Step -- 4.3. Add Listener


To see the results of test plan, add listener named “” by navigating to ‘Right
click thread group -> Add -> Listener -> View Results Tree’.

JMeter can show the test result in Graph format.

Right click Test Plan, Add -> Listener -> Graph Results

Step – 5 Perform load testing


To perform the load testing, start the thread group using the green play icon at
the top ribbon in tool.

Start Load Test


Let all threads run and invoke the configured application URL. After the test is
finished, we can review the load test results in consolidated manner in listener
tab.
TOOL DEMONSTRATION: WORKING ON JMETER

Step 1: Create Test Plan:


Step 2: Create Thread Group
1. Start JMeter
2. Select Test Plan on the tree
3. Add Thread Group

Right click on the "Test Plan" and add a new thread group: Add -> Threads
(Users) -> Thread Group

Case-1:

Action to be taken after a Sample error: Continue

Thread properties:

No.of.threads(USERS):100

Ramp-up period(seconds):10

Loop count:10
1. Start JMeter
2. Select Test Plan on the tree
3. Add Thread Group

Right click on the "Test Plan" and add a new thread group: Add -> Threads
(Users) -> Thread Group

Case-2:

Action to be taken after a Sample error: Continue

Thread properties:

No.of.threads(USERS):1000

Ramp-up period(seconds):20

Loop count:20
1. Start JMeter
2. Select Test Plan on the tree
3. Add Thread Group

Right click on the "Test Plan" and add a new thread group: Add -> Threads
(Users) -> Thread Group

Case-3:

Action to be taken after a Sample error: Continue

Thread properties:

No.of.threads(USERS):100

Ramp-up period(seconds):10

Loop count:Infinte
Step 3: Create HTTP Request Defaults
This element can be added by right-clicking on the Thread Group and
selecting: Add -> Config Element -> HTTP Request Defaults.

In the HTTP Request Defaults control panel, enter the Website name under test.

Server Name or IP: www.wikipedia.org ; path: /


Step 4: Create HTTP Request
Right-click on Thread Group and select: Add -> Sampler -> HTTP Request.

In the HTTP Request Defaults control panel, enter the Website name under test.

Server Name or IP: www.wikipedia.org ; path: /


Step 5:

Save the Report:


Open File -> Save

Saved report name as Loadtesting.jmx

OR

Press save button and save it as Loadtesting.jmx

You might also like