In this tutorial, we will be studying the creation of a Database Test Plan in JMeter. We will see the different test plan elements required for creating the test script along with their usage and configurations.
Pre-requisites for a Database Server Performance Test
The following pre-requisites are mandatory for performance testing of a database server-
- The database driver jar file of the database to be load tested e.g. for mySQL database its driver jar file is – “mysql-connector-java-5.1.21.jar” (latest jar at the time of writing this tutorial) which can be download from this Maven repository. This jar file is required to be copied inside the lib folder of your JMeter installation directory.
- Database credentials of user having access to run the SQL queries in the database to be load tested.
Steps to Load Test a Database
The steps required to be performed for load testing a database server are-
1. Add Thread Group and configure
First of all, we will add a Thread Group to the Test Plan and name it. Then we can configure the Thread Group with required values of Number of Threads, Ramp-up time, loops and other scheduler configurations.
2. Add Element – JDBC Connection Configuration
The Config Element- “JDBC Connection Configuration” is required to be added as child of the Thread Group. The properties in “Connection Pool Configuration” and “Connection Validation by Pool” can be kept with default values. Appropriate values for the following parameters need to be configured in “Database Connection Configuration” section-
- Database URL – The URL of the database server
- JDBC Driver class – The database driver name e.g. com.mysql.jdbc.Driver
- Username – The username of the user having access to run the SQL query in the database
- Password – The password of the user having access to run the SQL query in the database
3. Add Sampler – JDBC Request
The Sampler- JDBC Request needs to be added as child of the Thread Group below the JDBC Connection Configuration. Here we can select the type of SQL query form the “Query Type” dropdown and place the SQL query in the “Query” text field.
4. Add Listeners
In order to store and analyze the test results, we can add different types of listeners studied in our tutorial – Listeners in JMeter.
5. Run and analyze the test
Once the whole test script creation and configuration is done, we will run the test by clicking the play icon or pressing Ctrl+r on keyboard. During the test execution, we will monitor the database server in parallel and once the test gets over, we can store and analyze the test results.
That’s all we have in this post, please share it with your friends and colleagues, comment below if you have any queries. Check out the complete JMeter tutorial below.