JMeter components: Thread Group, Samplers, Listeners, Configuration

Tram Ho

As in the previous article we went to learn how to install JMeter. Today I will go to introduce the basic components in JMeter. The components explored in today’s article are:

  • Thread Group
  • Sampler
  • Listener
  • Configuration

1. Thread Group

The thread group represents a user group and contains other threads. Each Thread group will simulate users to perform a specific test case. Some parameters to note in the Thread Group:

– Number of Threads: Each Thread represents a virtual user, JMeter allows changing an unlimited number of users to perform tests.

– Ram-Up Period: Time to start all threads.

– Loop Count: The number of times the user repeated requests.

How to create a Thread group: right-click Test plan -> Add -> Threads (Users) -> Thread group

2. Sampler

Samplers will instruct JMeter to send the request to the server and wait for a response. To connect to the server, users need to make requests. How to create a Sampler: Right-click on Thread Group -> Add -> Sampler -> select any Sampler you want Sampler to include:

  • FTP Request
  • HTTP Request (can be used for SOAP or REST Webservice also)
  • JDBC Request
  • Java object request
  • JMS request
  • JUnit Test request
  • LDAP Request
  • Mail request
  • OS Process request
  • TCP request

Example when using HTTP Request: You want 100 users to attack https://www.google.com simultaneously. How to create: Thread Group -> Sampler -> HTTP Request.

3. Listeners

After creating and sending the request to the server, JMeter will receive the results returned and displayed. Listeners allow viewing of results obtained from running in different types, such as tables, graphs, trees, etc. Listener will visually provide the data collected. Let’s find out some common forms as follows:

– View Results Tree: Allows tracking information of the server data returned to each user in different forms.

– Graph Results: Returns a graph representing the parameters: the number of requests, the number of requests processed per minute, the average value, the median value of the entire response time from the server.

– Summary Report: Provides a report on the values: lowest response time / highest, number of error occurrence requests, average flow.

How to create: Right-click Thread group -> Add -> Listener -> Select the result type

4. Configuration

Configuration is used to set default values ​​and variables for later use by samplers. The following figure shows some of the configuration elements commonly used in JMeter:

CSV Data Set Config

In case you want to test 100 users simultaneously logging in with different login information. Then you don’t need to record the script 100 times. You can store login information (username, password) into a text file. Use “CSV Data Set Config” to read parameters from file.

HTTP Cookie Manager

Have you ever been to a website, for example: https://shopee.vn , log in with your username and password. Then turn it off and on again to see no need to log in anymore. Have you ever wondered: Why don’t I have to log in again? The reason is that your browser will use cookies as the user data to log in. JMeter provides an HTTP Cookie Manager manager that has the same features as a web browser. If you have an HTTP Request request that contains a cookie, Cookie Manager will automatically store that cookie and will use it for all future requests to that particular website. This is the HTTP Cookie Manager screen:

HTTP request default

The HTTP request default allows you to set the default values ​​that your HTTP Request controller uses. Example: You are sending 100 HTTP requests to google.com server You will have to manually enter server name = google.com for all 100 requests instead Instead, you can add an HTTP request defaults with the field “Hostname or IP” = google.com No need to type 100 times!

Login Config Element

The Login Config Element allows you to add or override username and password settings. For example, you want to simulate a user logging into www.facebook.com using the user and password. You can use the Login Config Element to add password and user settings in user requests. Here you will see JMeter will provide Username and password for you to enter

Comparison between Login Config Element and CSV data Config

Login Config ElementCSV data Config
Simulate logging a userSimulate logging multiple users
Only suitable for login parameters (user and password)Suitable for large number of parameters

Above are some components that need attention and are often used in JMeter, hope it will help you in understanding JMeter.

References:

https://jmeter.apache.org/usermanual/test_plan.html https://www.guru99.com/jmeter-element-reference.html

Share the news now

Source : Viblo