PRACTICAL 2: Performance Testing using Jmeter
PRACTICAL
2: Performance Testing using Jmeter
Introduction
to Jmeter
Jmeter is an application
that offers several possibilities to configure and execute load, performance
and stress tests using different technologies and protocols. It allows
simulating different type of requests against all kind of databases, FTP, HTTP,
HTTPS or other kind of servers.
JMeter is a Java desktop
application. Its UI is implemented using the Swing Java API. Due to these two
points, JMeter is multiplatform and runs in any kind of machine with a Java virtual
machine installed: Windows, Linux, Mac. Its framework allows concurrency and
the execution of several Threads and Threads Groups. This is very useful when
trying to configure load and stress tests.
JMeter is part of the
Apache software foundation and is completely free and open source (http://www.apache.org/licenses/)
1.      Web Test Plan 
 The following figure
shows you the steps involved in practicing this test
·        
STEP
1. Add Thread Group – 
Ø  First,
start JMeter by running jmeter.bat or double clicking the ApacheJMeter.jar
file. 
Ø  Select
the Test Plan and right click on it. Add a Thread Group to your selected Test
Plan by choosing Add > Threads (Users) > Thread Group from the pop up
menu.
Figure 1- add thread group
Ø 
The newly created Thread Group is displayed in
the left hand pane. You can configure the Thread Group’s properties in the
right hand pane as shown in the screenshot below.
Figure
2- Thread group properties
·        
Step
2. Add Sampler-
Ø  Now
that we have created a Thread Group, we need a way to send a request to the
server. We can achieve this using Samplers. You need to add a Sampler to the
Thread Group now.
Ø  Right
click and select the Thread Group > Add > Sampler > HTTP Request.
Figure 3-Adding sampler as HTTP request
·        
The HTTP Request sampler is added to the
Thread Group. It can be configured as shown in the screenshot.
Figure 4-http request -config settings
Name:
You can name your HTTP Request Sampler using this field
Server Name or IP:
Name or IP address of web server under test. In this case we are testing the
Google homepage so we will use www.google.com
Method:
You can select several method of HTTP protocol such as GET, POST, HEAD…etc based
on your requirement. In our tutorial we will use GET.
Path:
URL path to invoke on the server. For example, if path is set calendar, JMeter
will invoke the URL www.google.com/calendar in the request. In this case, we
keep this path blank to request to the servers root page.
Proxy Server:
This is useful if your computer is connected to the Internet via a proxy
server. You can set the Server Name, Port Number, Username and Password if
needed.
Embedded Resources from
HTML files: This is used if you want JMeter to download the
embedded content like JavaScript files, images, CSS files etc.
Source Address:
This is used for IP Spoofing and we are not going into that topic in our
current tutorial.
·        
Step
3. Add Listener-
Ø 
In order to save or view the results of
the test, you need to add a Listener to your Thread Group.
Ø 
JMeter will display the performance
results of the website through the Listener. This information can be displayed
in several formats such as Graph, Tree, Table, Log File etc.
Ø 
In this practical exercise, we will use a
Result Tree to display the statistical information of web server under test.
Ø  Right
click on the Thread Group > Add > Listener > View Results Tree.
Figure 5-adding listener
·        
Step
4. Run The Test Plan in Jmeter
Ø 
Now that all the
configurations are ready, let us execute the test plan. Save the test plan
before running the test.
Ø  Start running the test plan by click button Start or
Start No Pause button in the menu bar.
Figure 6- running the test plan
Ø  JMeter will run the test and this may take some time.
During the execution the Stop button will be enabled and the small rectangle on
the far right corner of the menu bar will be green.
Ø  Once JMeter completes execution, the Stop buttons will be
disabled and the small rectangle indicator will turn gray.
Ø  Let examine in detail the information displayed in
JMeter.
Ø  In this test, JMeter sends the HTTP request to the
google.com server. The left pane of the View Results Tree lists the Sampler
Responses. Clicking on a Sampler response will display its data in the right
pane.
Ø  In Sampler result tab, you can see the information of the
regarding the request like load time, latency, etc.
Figure 7-jmeter response result
Ø  In the Response Data tab, JMeter displays the response
data returned from web server. In this example it is the HTML code returned by
the Google homepage.
2.     
Database Test Plan-
Ø  For database testing, we have downloaded a
mysql-connector-java JAR file and placed it in the lib folder of JMeter. Now,
we start with the thread group.
Figure
8-creating thread
Ø  Now,
we make a JDBC connection configuration.
Figure
9-jdbc connection
Ø  In
the JDBC connection configuration, we will define the database URL, JDBC driver
class, the MySQL username and password, etc.
Ø  Now,
we add a sampler for the JDBC request.
Figure
10-adding sampler
Ø  In
the JDBC request, we define the query. For example, if we're running a select
query, we select the select statement in Query Type.
Figure
11-running select query
Ø  We
can see the result in the View Results Tree listener:
Figure
12-viewing result














 
 
Comments
Post a Comment