This section helps you to understand building a Database Test Plan. We will take an example of creating 50 users that send two SQL requests to the database server. We will be asking the users to run the test 100 times. Hence there will be 10,000 (50 users * 2 requests * 100 times) JDBC requests.

Adding Users

To start with, the very first step is to add a Thread group element as it instructs Jmeter the total number of user we’re trying to stimulate, how many requests the users need to send and when the users should send requests.

In order to add the ThreadGroup element, Click on the Test Plan, then Add and then select Add à ThreadGroup. Make sure you see this Thread Group element by expanding the Test Plan tree on the Test Plan element.

Next step is to change the default properties. Expand the Test Plan and click on the Thread Group and this will display all the default properties of the Thread Group.

Thread Group with Default Values

  1. Give a descriptive name to your Thread Group. Let’s name it JDBC users. When you change the name, please notice that your Thread group name changes under the Test Plan tree
  2. Set the number of users to 50
  3. Set the ramp up period to 10 seconds. This means that, your Jmeter will have a 10-second ramp up period to start all of the 50 users.
  4. Set the Loop count to 100. This instructs the Jmeter to the number of times the test needs to be run. In case if you would like to repeatedly run this test plan, then select the Forever checkbox.

JDBC Users Thread Group

The above figure shows the new values of JDBC Users Thread Group

Adding JDBC Requests

Now that we have defined our users, it is time to define the tasks that they will be performing. In this section, you will specify the JDBC requests to perform.

Next, we will be defining the tasks that the users will be performing. We will have to create the JDBC requests to perform the tasks.

Right Click on the JDBC users element under the Test plan, then choose Add, Config element and then JDBC Connection Configuration. In order to view this control panel, click on this new element.

Now edit the field values in the JDBC connection Configuration window. Other values than the listed ones below, can be left as it is.

  1. Name the JDBC Connection Configuration to MySQL Configuration
  2. Name the Variable to be myDatabase. JDBC Sampler uses this name to identify the configuration
  3. Set the Database URL to jdbc:mysql://ipOfTheServer:3306/cloud
  4. Set the JDBC driver class to com.mysql.JDBC.Driver
  5. Set the username to be Cloud.
  6. Give the password for the username

Now a database connection pool will be created with all the details that you have mentioned in the control panel.

JDBC Configuration

Now its time to set the JDBC request. Right click on the JDBC users element and then click on Add, Sampler and then JDBC Request. Click on this JDBC request under the Test Plan tree to view its control panel.

JDBC Request

We will create two JDBC requests in our Test Plan. First one is to select all the Running VM instances and the other one is to select Expunging VM instance. This is explained below.

Requests are being sent in the same order that you have added them in the tree.

Edit the following properties in the JDBC Request window.

  1. Set the Name to VM Running
  2. As in the Configuration element, Set the Pool name to myDatabase
  3. Enter the SQL Query String Field
  4. Set the Parameter Values to “Running”

Set the Parameter types to “VARCHAR”

JDBC Request for VM Running

Similarly, set the property values for the second JDBC Request

  1. Set the Name to VM Expunging
  2. As in the Configuration element, Set the Pool name to myDatabase
  3. Enter the SQL Query String Field
  4. Set the Parameter Values to “Expunging”
  5. Set the Parameter types to “VARCHAR”

JDBC Request for VM Expunging

Adding a Listener

The last step is to add a Listener to the test plan. Listener helps to view/store the JDBC request’s test results in a file and show the results.

Adding the listener can be done by Right click on the JDBC Users element, then click on Add, Listener and Summary Report.

Now save all the changes of the test plan and run your test by clicking on Menu, Run and then Start. Alternatively, as a shortcut, you can also CTRL+R in your Keyboard to run the test.

The listener will show the results like below

 The listener that shows the Results