Tutorial by Vinod Kumat

Jmeter Tutorial

In this tutorial, going to discussed about the Jmeter, open source tool for performance testing.

Following are the topic we'll discussed in more details:

Performance Testing & Types of Performance testing
Pre Requisites
Jmeter Features
Jmeter installation
Jmeter Components
    Test Plan and its elements
Creating a TestPlan
Thread Group
Sampler Controllers
Listeners and Timers
Logical Controller
Graphs and Reports

Performance Testing & Types of Performance testing:
Definition: Performance testing, in general, is testing performed to determine how a system performs in terms of responsiveness and stability under a particular User load (concurrent users).
Other attributes Performance testing validates or verifies
   Scalability
   Reliability
   Resource usage
Main Objective:
   Find bottlenecks
   Improve customer experience

Load testing: Evaluate the behavior of the application under increasing load. Identify the highest load the application is designed to perform correctly.
Stress testing:  Evaluate a system or component at or beyond the limits of anticipated or specified workloads, or with reduced availability of resources such as access to memory or servers. This test is an attempt to break the system by suppressing its resources.
Spike Testing: Spike testing is done by suddenly increasing the load generated by users by a very large amount and observing the behavior of the system.
Soak Testing: Soak testing also known as endurance testing, is usually done to determine if the system can sustain the continuous expected load. During soak tests memory utilization is monitored to detect potential leaks.
Volume Testing: Testing whether the system is subject to large volumes of data.

Pre Requisites
Non Functional Requirements Document should be available which gives the details of the types of load test to be performed, number of concurrent users to be loaded, expected response time and other performance attributes to be captured.

Dedicated performance test environment to be available.

Test Environment should be like the actual production environment.

Get the details like the app server, DB server configurations etc.

Performance Test approach document should be ready and is signed off by all the concerned stake holders.

Jmeter Features
It’s free. It’s open source
It is 100% Java application
It has simple and intuitive GUI
It can do load and performance test on several servers:
    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 jmeter.sh. On Windows it can be invoked by starting the jmeter.bat file.
JMeter store its test plans in XML format. This means you can generate a test plan using a text editor.
It is full multi-threading framework allows concurrent sampling by many threads and simultaneous sampling of different functions by separate thread groups.
It is highly extensible.
Controllers are configurable and can monitor server performance.
Test results can be captured in various format like summary report, aggregate report, graph, aggregate graph, results in tree, results in table

Jmeter life cycle

jmeter simulates a group of users sending requests to a target server, and return statistics that show the performance/functionality of the target server/application via tables, graphs etc.

Jmeter,java jmeter, tutorial, beginner, basic, advanced, testing, test, performance, nonfunctional and open source













Jmeter Performance tool and installation
jMeter is an open source, pure Java application, software testing tool for load and performance testing

Installation:
Step 1: Install Java – JDK above version 6
 If already installed, verify the version
 Windows – Open Command Prompt - java -version
 Linux – Open Command Terminal - $java -version
Step 2: Download jMeter: https://jmeter.apache.org/download_jmeter.cgi
Step 3: Unzip the files to the destination folder

Step 4: Double click on jMeter.bat to open the application.
            It will there in \apache-jmeter-2.11\bin\jMeter.bat


Jmeter,java jmeter, tutorial, beginner, basic, advanced, testing, test, performance, nonfunctional and open source







Fundamental  jMeter Components
Test Plan: defines a series of steps on how and what to test. Only one test plan can be added per script and can be saved for future use.
Thread Group:  Represents a set of actions added under test plan and can simulate multiple users.

Http request sampler: Records requests to web server and receives response

Elements of a Test Plan
A test plan provides a layout of how and what to test
Some of the test plan elements are:
  Thread Group
  Controllers
  Listeners
  Timers
  Assertions
  Configuration Elements
  Pre-Processor Elements
  Post-Processor Elements


Creating a test plan
Add the following elements to the test plan for a basic test scenario
    Add number of users using Thread Group
    Add  default HTTP request from Config element
    Add HTTP Request from Samplers
    Add Listener to view results

Thread group
The thread group elements control the number of threads JMeter will use during the test.
To create the Thread Group, first run JMeter, from opened interface of JMeter choose Test Plan from the tree and right click to choose Add -> Threads (Users) ->Thread Group.
After opening thread Group, enter Thread Properties as given below
Number of Threads: The required number of Virtual users is specified here.
Loop Count: How many times (iterations) it is required to execute

Ramp-Up Period: How the load to be increased

Right click on the Test Plan > Add > Threads (Users) > Thread Group
Jmeter,java jmeter, tutorial, beginner, basic, advanced, testing, test, performance, nonfunctional and open source








Change the name of My Thread Group, we can put as much as we want to put for load for concurrent user, loop count and all.
Jmeter,java jmeter, tutorial, beginner, basic, advanced, testing, test, performance, nonfunctional and open source









Right click on the My Thread Group > Add > Sampler > HTTP Request
Jmeter,java jmeter, tutorial, beginner, basic, advanced, testing, test, performance, nonfunctional and open source













Enter the Server or IP address
Jmeter,java jmeter, tutorial, beginner, basic, advanced, testing, test, performance, nonfunctional and open source









Listeners and Timers
Listeners: Listeners are used to view the results in the form of graph, tree or numbers. Listeners like view results tree shows data for each item with details like request, response and transaction status and Summary report listener will give complete performance information, simulated users and details in numbers for each user.
Timers: Timers allow JMeter to delay between each request which a thread makes. Timer can solve the server overload problem.
  Types of Timers
  Constant Timer
  Constant Throughput Timer
  Uniform Random Timer
  Gaussian Random Timer
  BeanShell Timer
  Poisson Random Timer
  BSF Timer
  JSR223 Timer
  Synchronizing Timer

Logical Controller
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 Each Controller, While Controller, Loop Controller, IF Controller, Run Time Controller, Interleave Controller, Throughput Controller, and Run Once Controller.

Jmeter,java jmeter, tutorial, beginner, basic, advanced, testing, test, performance, nonfunctional and open source















Results & Listener

Right click on the My Thread Group > Add > Listener > Select any one of listener.


Jmeter,java jmeter, tutorial, beginner, basic, advanced, testing, test, performance, nonfunctional and open source




















Save it and click My Thread Group >  Start button on menu button or Run > Start.









Best Practices: Do/Don't
Do not use GUI mode: Run Jmeter in non gui mode. Use jmeter –n-t test.jmx test.jtl
Use Remote and Distributed testing for larger load testing
Do not load more than 300 threads (Vusers) per plan
Do not add listeners & graphs to the Jmeter test plan. Write the results to a file in the system
Erase the local path of all the CSV data set config files
Use naming conventions for all the elements
Do not use XPATH extractor
Generate reports after run
Only save the data that is needed

Do not use assertions unless required

Finishing Words:
Thanks! Hopping, tutorial for java jmeter, open source tool, for performance testing, will help. Please share and like if you like my work.

Happy learning and Implementation.

13 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. How to do load testing with API(ie., i need to do load testing for mobile application). Do i have any way?

    ReplyDelete
  3. Hi,
    I just came across your Page and wanted to say that I’ve really enjoyed reading your jmeter posts. Thank you

    ReplyDelete
  4. Hi buddy,

    Thanx for sharing this blog withus.

    I've come up against a few real-world situations where performance test analysis is almost complete and test script development about to begin.

    Selenium Automation testing

    ReplyDelete
  5. Great Article. Kindly share more article.

    Automation Testing Service

    ReplyDelete
  6. That is very interesting; you are a very skilled blogger. I have shared your website in my social networks! A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article.Selenium Automation Testing

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Hi, Thanks for sharing the post and this is a good flow of information about Performance Testing. surprisingly, i have seen a great post on Performance Testing and I believe your readers will love to browse “5 Ways to Plan Application Performance Testing” on Cigniti Blog. Here is the link to access the post – https://bit.ly/3c03lLs. I would love to know your comments on our blog.

    ReplyDelete
  9. Thanks for sharing JMeter tutorial. Here are a few useful links for performance testers,
    Software Performance Testing
    How to do Performance Testing
    Performance Testing Jobs

    ReplyDelete