JMETER - Performance Test Plan

JMETER - Test Plan

Apache JMeter may be used to test performance both on static and dynamic resources (files, Servlets, Perl scripts, Java Objects, Data Bases and Queries, FTP Servers and more). It can be used to simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load types. You can use it to make a graphical analysis of performance or to test your server/script/object behavior under heavy concurrent load.
Download and install JMeter

Setup - quick Guide


1.       Open Jmeter (bin/Jmeter.bat on Windows) or double click .jar file
2.       Add (via right click) a Thread group to the Test Plan

3.       Add à Config Element àHTTP Request Defaults (Mention default http request details for thread group).




4.       choose Add à  Config Element à HTTP Header  Manager/HTTP Cookie Manager/HTTP Cache Manager


5.       Add àConfig Element à CSV Data Set Config (To mention multiple loop data)

6.       Add à Sampler àHTTP Request – configure protocol, method, parameters and any additional path (if needed) parameters.


7.       Addà Listeners àAdd needed Listeners to create view performance detail


8.       Finally click on the run button to view result




Thread Group

                The first step you want to do with every JMeter Test Plan is to add a Thread Group element. The Thread Group tells JMeter the number of users you want to simulate, how often the users should send requests, and the how many requests they should send.
                Selecting the Test Plan, clicking your right mouse button to get the Add menu, and then select Add --> ThreadGroup




Number of Threads        - Number of users
Ramp-Up Period              - This property tells JMeter how long to delay between starting each user.
Loop Count                         - This property tells JMeter how many times to repeat your test.
The Ramp-Up Period, leave the default value of 1 second. This property tells JMeter how long to delay between starting each user. For example, if you enter a Ramp-Up Period of 5 seconds, JMeter will finish starting all of your users by the end of the 5 seconds. So, if we have 5 users and a 5 second Ramp-Up Period, then the delay between starting users would be 1 second (5 users / 5 seconds = 1 user per second). If you set the value to 0, then JMeter will immediately start all of your users.




HTTP Request Defaults


                Here you will specify the default settings for your HTTP requests. And then you will add HTTP Request elements which use some of the default settings you specified here.
Begin by selecting the JMeter Users (Thread Group) element. Click your right mouse button to get the Add menu, and then select Add --> Config Element --> HTTP Request Defaults.

Name                                    - Descriptive name for this element that is shown in the tree
Server                                   -Domain name or IP address of the web server. e.g. www.example.com. [Do not include the http:// prefix
Port                                       -Port the web server is listening to
Connect Timeout             -Connection Timeout. Number of milliseconds to wait for a connection to open. Requires Java 1.5 or later when using the default Java HTTP implementation.
Response Timeout          -Response Timeout. Number of milliseconds to wait for a response. Requires Java 1.5 or later when using the default Java HTTP implementation.
Protocol                               -HTTP or HTTPS
Method                               -HTTP GET or HTTP POST
Path                                       -The path to resource (for example, /servlets/myServlet). If the resource requires query string parameters, add them below in the "Send Parameters With the Request" section. Note that the path is the default for the full path, not a prefix to be applied to paths specified on the HTTP Request screens.
Port                                       -Port the proxy server is listening to.

HTTP Header Manager


Each time the browser sends a request to a server, headers with additional information are attached to the request. When documenting to the HTTP protocol, a large number of them are described. Still, a group with many used headers can be allocated: Accept-Language, Accept-Encoding, User-Agent, Referer.
The HTTP Request Defaults element does not tell JMeter to send an HTTP request. It simply defines the default values that the HTTP Request elements use.
Select the Thread Group, and choose Add --> Config Element --> HTTP Header  Manager/HTTP Cookie Manager/HTTP Cache Manager

Name                    - Descriptive name for this element that is shown in the tree
Name (Header)                - Name of the request header. Two common request headers you may want to experiment with are "User-Agent" and "Referer"
Value                    -Request header value
Add Button         -Add an entry to the header table.
Delete Button   -Delete the currently selected table entry
Load Button       -Load a previously saved header table and add the entries to the existing header table entries
Save As Button                 -Save the current header table to a file.


HTTP Request


The HTTP Request elements tell JMeter to send an HTTP request.
Start by adding the first HTTP Request to the JMeter Users element (Add --> Sampler --> HTTP Request)


Name                                    - Descriptive name for this sampler that is shown in the tree.
Server Name or IP           - Domain name or IP address of the FTP server.
Port                                       - Port to use. If this is >0, then this specific port is used, otherwise JMeter uses the default FTP port.
Protocol                               -HTTP, HTTPS or FILE. Default: HTTP
Method                               -GET, POST, HEAD, TRACE, OPTIONS, PUT, DELETE, PATCH (not supported for JAVA implementation)
Content Encoding            -Content encoding to be used (for POST, PUT, PATCH and FILE). This the the character encoding to be used, and is not related to the Content-Encoding HTTP header.
Redirect Automatically -Sets the underlying http protocol handler to automatically follow redirects, so they are not seen by JMeter, and thus will not appear as samples. Should only be used for GET and HEAD requests. The HttpClient sampler will reject attempts to use it for POST or PUT.
Use KeepAlive                  -JMeter sets the Connection: keep-alive header. This does not work properly with the default HTTP implementation, as connection re-use is not under user-control. It does work with the Apache HttpComponents HttpClient implementations.
Browser-compatible headers     -When using multipart/form-data, this suppresses the Content-Type and Content-Transfer-Encoding headers; only the Content-Disposition header is sent.
Path                                       -The path to resource (for example, /servlets/myServlet). If the resource requires query string parameters, add them below in the "Send Parameters With the Request" section. As a special case, if the path starts with "http://" or "https://" then this is used as the full URL. In this case, the server, port and protocol are ignored; parameters are also ignored for GET and DELETE methods.
Parameters                        -The query string will be generated from the list of parameters you provide. Each parameter has a name and value , the options to encode the parameter, and an option to include or exclude an equals sign (some applications don't expect an equals when the value is the empty string). The query string will be generated in the correct fashion, depending on the choice of "Method" you made (ie if you chose GET or DELETE, the query string will be appended to the URL, if POST or PUT, then it will be sent separately)


Response Assertion


The response assertion control panel lets you add pattern strings to be compared against various fields of the response. The pattern strings are:
·         Contains, Matches: Perl5-style regular expressions
·         Equals, Substring: plain text, case-sensitive
You can also choose whether the strings will be expected to match the entire response, or if the response is only expected to contain the pattern. You can attach multiple assertions to any controller for additional flexibility.
Select the Thread Group, and choose Add --> Assertion --> response assertion
Pattern Matching Rules               
Indicates how the text being tested is checked against the pattern.
·         Contains - true if the text contains the regular expression pattern
·         Matches - true if the whole text matches the regular expression pattern
·         Equals - true if the whole text equals the pattern string (case-sensitive)
·         Substring - true if the text contains the pattern string (case-sensitive)
Equals and Substring patterns are plain strings, not regular expressions. NOT may also be selected to invert the result of the check.


Constant Timer
If you want to have each thread pause for the same amount of time between requests, use this timer.
Thread Delay                     - Number of milliseconds to pause.
Select the Thread Group, and choose Add --> Timer --> Constant Timer


Adding a Listener to View Store the Test Results
                Most of the listeners perform several roles in addition to "listening" to the test results. They also provide means to view, save, and read saved test results.
Note that Listeners are processed at the end of the scope in which they are found.

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.
There are several ways to view the response, selectable by a drop-down box at the bottom of the left hand panel.
·         Document
·         HTML
·         HTML (download resources)
·         JSON
·         Regexp Tester
·         Text
·         XML

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 spline has 10 points, each representing 10% of the samples, and connected using spline logic to show a single continuous line.
The graph is automatically scaled to fit within the window. This needs to be borne in mind when comparing graphs.

 

Run             

                Finally click on the run button to view result

Comments

Popular posts from this blog

SinglePass Terms of Service

Jasper Report Viruatization

JasperReports Tutorial