Elements of JMeter


Below figure represents most widely used components of JMeter called as elements:

JMeterTutorial

Studying all of the JMeter Components will be confusing so I am covering only the most important JMeter elements:
  1. Thread Group
  2. Samplers
  3. Configuration
  4. Listeners

Thread Group

Thread Groups is a collection of Threads. Each thread represents one user using the application under test. Basically each Thread simulates one real user request to the server.

The controls for a thread group allow you to Set the number of threads for each group.

For example, if you set the number of threads as 100; JMeter will create and simulate 100 user requests to the server under test.
JMeter Thread Group
Samplers
There are many Samplers available. We will be covering following Samplers in this tutorial:
  1. HTTP
  2. FTP
  3. JDBC
  4. BSF
  5. Access Log
  6. SMTP
We understand from above that we thread sends request to server. However, how do they know which type of request (JDBC, FTP, BSF etc) do they need to send?

This is why we learn Samplers. Because the user request can be HTTP, FTP etc.

A) FTP Request:

Suppose you have to do performance testing of a FTP Server, Then, you can use JMeter FTP Request Sampler to test this. This control will allow you to download or upload files on FTP Server. 



Below is an example where we are downloading a file from FTP Server:


JMeter will send FTP command to FTP Server ftp.example.com and then download a file Test.txt from that server.

B) HTTP Request:

This Sampler will allow us to send HTTP/HTTPS request to Web Server.

Below is an example where JMeter send a HTTP request to Google website and retrieve HTML files or image from this website.
C) JDBC Request:

This sampler allows you to do Database Performance Testing. It sends JDBC Request (an SQL query) to a database.

Below is an example which shows that database has a field test_result stored in a table name test_tbl. You want to fetch this data from the database; you can configure JMeter to send a SQL query to this Database server & retrieve data. This can only be done using JDBC Sampler.


D) BSF Sampler: 

This sampler allows you to write a sampler using a BSF scripting language.

Below is an example of BSF Sampler in JMeter:


E) Access Log Sampler:

This sampler allows you to read access logs generated by server and generate http requests. The log could be html, css etc. Using this sampler, we can read logs from a Web Server.

F) SMTP Sampler:

This sampler allows you to test a mail server like gmail, yahoo etc. This is used to send email messages using SMTP protocol:


Listeners:

Listeners helps you to see the result of samplers execution. The results can be generated in multiple formats such as tree, table, graph, log file etc.

Configuration Elements:

Configuration Elements are nothing but just a way to save variables for later use by samplers or helps us to use external data. Here, we are covering some commonly used Configuration Elements in JMeter:

A) CSV Data Set Config:

Lets take an example where you have to test a website for 100 users signing-in with different credentials. You do not need to create 100 scripts for 100 users. You can create one script and parameterize it to enter different login credentials. This can only be done using "CSV Data Set Config". 

The login information (e.g. Username, password) can be stored in a text file. JMeter has an element "CSV Data Set Config" that allows you to read different parameters from that text file and split them into variables.
Example of CSV Data Set Config. It's a text file which contains username and password to login to your website:

B) HTTP Cookie Manager:
Let's understand this with an example -
You use your browser (Chrom, IE...Etc) to browse www.google.com. You login with your username and password. Your username and password will be stored in your computer as cookies.
Next time, when you visit www.google.com, you don't need to do login again because your browser will use your cookies as user data to login.
HTTP Cookie Manager also has the same feature like a web browser. If you have an HTTP Request and the response contains a cookie, the Cookie Manager automatically stores that cookie and will use it for all future requests to that particular web site.
C) HTTP request default:
This element lets you set default values that your HTTP Request controllers use.
For example,
You are sending 100 HTTP requests to the server gmail.com. You would have to manually enter server name = gmail.com for all these 100 requests
Instead, you could add a single HTTP request defaults with the "Server Name or IP" field = gmail.com. And then you don't need to type URL 100 times!
D) Login Config Element:
The Login Config Element lets you add or override username and password settings in samplers.
For example, you want to simulate login of one user to website www.facebook.com with username & password. You can use Login Config Element to add these crendentails in user request.
Login Config Element
CSV Data Config
Used to simulate one user login
Used to simulate multiple user login
Suitable for login parameter only (user and password)
Suitable for large numbers of parameters

0 comments:

Post a Comment