Jmeter Test Plan: Thread Group, Sampler, Controller & More

Jan 27, 2021, 1888 Views, 0

Contents

  • Test Plan
  • Thread Group
  • Jmeter Controllers
  • Listeners
  • Configuration Elements
  • Summay
  • Apache JMeter was introduced to the industry about 2 decades back. Java-based load testing tool, highly intensive on GUI and less coding. When we talk about load testing we mean to test the application performance under a large set of users and hence data, to record the response time as are there unseen delays or some load-based exception been raised by the code. Jmeter is also used for stress testing, where we go beyond the load limit and then see how the application reacts to the huge bulk of data and hence handle them to make the application robust in itself. Jmeter is an open-source tool, used by almost every company in the industry to test the load of servers, applications, distributed and also mailing servers. In this particular article, we are going to introduces you to the elements of Apache Jmeter which are test plan, thread group, controllers, listeners, and configuration elements. Though there are also assertions, times, preprocessors, variables these all will be discussed in a separate post as you can create a test plan using just a thread group with a sampler. So, let's get started.


    1. Test Plan

    Every Jmeter file that is saved under .jmx format is referred to as a test plan. It is under test plan that you create a thread group, then add a controller and listener. Under one test plan, you can have multiple thread groups attached to it as well. Until you check the box Run Thread Groups consecutively, on start only thread group you are in would run. Checking the box of functional test mode also would keep on saving the response every time you run an event, which would naturally slow down the testing process and hence is kept by default unchecked. 



    Jmeter Test Plan: Thread Group, Sampler, Controller & More

    2. Thread Group

    Jmeter takes full leverage of Java which has the concept of multithreading to it. Thread is the smallest unit of a program. Multithreading does look like multitasking but actually, it divides the program into small units that are threads which make this program look as if multitasking is taking place. Now here each thread in a thread group represents a user. Here 3 major actions that are provided are:

    1. Firstly you can specify the number of users. 
    2.Second action is the most interesting one which is ramp up period. Now it talks about the total time to execute all the threads in the thread group so if you say specify 10 users here and set ramp up period as 60 seconds then 10 users would complete the execution in 60 seconds making every next thread execute after 6 secs. 
    3. And thirdly loop count, if you want to repeat the sampling event. Samplers, listeners, and configuration elements all are added to the thread group as the thread group here is the main parent.

    Jmeter Test Plan: Thread Group, Sampler, Controller & More

    3.Jmeter Controllers

    Jmeter provides 2 types of controllers: Samplers and Logic Controllers. There is also a special type of controller called test fragments. Let us talk in a bit in detail about them.  

    1.Samplers

    Samplers send in the request which you can customize on the basis of which request is being sent as if its HTTP request, JDBC request, FTP request java request, etc. The basic test plan consists of only thread group and JMeter sampler. Samplers themselves can be customized via the logical controller or configuration elements which will talk below. Also one needs to attach listeners to the thread group to record the result returned by the samplers.
    Jmeter Test Plan: Thread Group, Sampler, Controller & More


    Jmeter Test Plan: Thread Group, Sampler, Controller & More

    2.Logic controller

    Logical controller where you can add logic as when should the sampler be even called say you are using if controller, while controller, loop controller. All the logical control of the samplers happens here as if a condition is met then skip the particular sampler etc.
    Jmeter Test Plan: Thread Group, Sampler, Controller & More

    3.Test fragments

    Test fragments are special controllers that are added at the same level as thread groups and executed only when called by module controller or include controller. This element is used to add the code reusability feature in JMeter.

    Jmeter Test Plan: Thread Group, Sampler, Controller & More

    4.Listeners

    The response captured by the sampler is stored in a file via customizing listeners. Apache provides multiple ways to do so via Graph results which show the result in a graphical format, result in view tree which shows response on a tree format which could save the data in either CSV format or other. Also, the result set every time you run a thread group could be stored in a separate file or could even be appended to the same file. Without listeners the response is not recorded the only requests would be sent to the server. Also at one point in time, only one response is recorded.

    Jmeter Test Plan: Thread Group, Sampler, Controller & More


    Jmeter Test Plan: Thread Group, Sampler, Controller & More

    5.Configuration Elements

    All the modification of requests takes place in configuration elements. User-defined variables are also part of the configuration elements which are processed at the start of the thread group, does not matter on which sequence they are in the hierarchy. DNS manager, Cache manager, Cookie manager are all parts of configuration elements and they work according to the hierarchy they are placed in as in which logic controller and sampler they are part of. Configuration elements don't send in the request directly.

    Jmeter Test Plan: Thread Group, Sampler, Controller & More

    6.Summary

    1. Apache Jmeter tool is used for load testing. A test plan is the main file stored with .jmx which can run with just a thread group and sampler.
    2. Thread group makes use of Java multithreading concept to define the number of users.
    3. Jmeter has 3 types of controllers: sampler that sends a request, test fragments that are for re-usability, and logical controllers to loop in the sampler.
    4. Listeners Record the result by the response in a separate file in XML or CSV format.
    5. Configuration elements contain cookie manager, cache managers and are executed in the order they are placed in.

    Comments Section: