JDBC Test - Testing Tools

Let us now consider the "Weather India" application. It is a web-based application, which accesses data from the table called "cityweather" of "weafher.mdb" (MS Access file). We will demonstrate how to use Apache JMeter to test the performance of the database server (.mdb file), when multiple users try to access the database simultaneously.

The first step is to create a JDBC Test Plan. The test plan includes the following sections:

  1. Creation of Thread Group
  2. Adding the JDBC Requests
  3. Adding Listeners to View/Store Results
  4. Saving the Test Plan
  5. Running the Test Plan

Creating the Thread Group

When you initially start the JMeter application, it displays the dialog shown in Figure. By default, the tree structure contains two elements: Test Plan and Work Bench.

Creating the Thread Group

Step 2: To create a Thread Group, right click on the "Test Plan" and select Add-> Thread Group as shown in Figure.

Creating the Thread Group

The Thread Group has to be created under the "Test Plan" section.

Step 3: On adding the "Thread Group", it displays the "Thread Group" details on the right side of the window as shown in Fig. 8.3, which prompts you to enter all the details related to the Thread Group, such as

  • Name of the Thread Group
  • Number of Threads to be created
  • Delay time between the execution of each thread (called Ramp-Up period).
  • Loop Count which specifies the number of times each thread has to be executed.

Creating the Thread Group

Enter the Thread Group name as "Weather Jdbc Users", Number of Threads to be created as 10 and uncheck the "Forever" checkbox and enter the "Loop Count" as 3 as shown in Figure.

Step 4: After entering all the details, click the "Add" button, the newly created Thread Group will be added to the Tree under the "Test Plan" section.

Creating the JDBC Requests

Now add the various requests to be made, to the Thread Group we just created.

Step 1: Select the "Weather Jdbc Users" Thread Group from the tree structure. Right click on it to add the JDBC Request as shown in Figure.
Add -» Sampler ->JDBC Request

Creating the JDBC Requests

Step 2: When you select the "JDBC Request" option, it displays the "JDBC Request" details at the right side work area as shown in Figure.

JDBC Request

  • Enter the name of the JDBC Request as "City Weather JDBC Requestl".
    Enter the JDBC URL as "jdbc:odbc:weather" where "weather" is the DSN (Data Source Name) of the "weather" database.
  • Enter the "Driver Class" as "sun.jdbc.odbc.JdbcOdbcDriver as this is the default driver for Java based applications.
    Give the query string that has to be executed.

JDBC Request

Similarly create some more JDBC Requests, which retrieve the weather information of some more cities like "Pune", "Jaipur", "Chennai" etc. by providing the corresponding query strings.

Adding Listeners that Display the Result

This helps you to view the results and to store the results in a file. To add listeners follow the steps given below:

Step 1: Select the "Weather Jdbc Users" Thread Group. Right click on it and add the "Listener" as shown in Figure.
Add -> Listener -> Graph Results

Adding Listeners that Display the Result

Step 2: On selecting this option, the "Graph Results" section will be added to the "Weather Jdbc Users" Thread Group. Enter the name of the Lis­tener as "Weather Graph Results".

Saving the Test Plan

To Save the Test Plan File -> Save

It will display the Save Dialog box, enter a File name and click on Save button.

Running the Test Plan

To Run the Test plan
Run -> Start

The "Start" option of "Run" menu will now be disabled and the "Stop" option will be enabled. If the small square on the upper-right hand of the "Graph Results" dialog is in green color, it indicates that the application is in "Running" Mode as shown in Figure.

Running the Test Plan

If you stop the execution in between by selecting the "Stop" option from the "Run" menu, then it displays the message shown in Figure.

Displays the results that are generated by the Graph Listener after executing the requests.

results that are generated by the Graph Listener

Inserting the Tinier

JMeter,by default, does not pause between the requests. But it is recommended to put some time-interval before processing the next request. Timer is used to specify the delay between each request.

Till now we have tested the application without introducing any delay between the requests. We now introduce some delay and perform the tests again. There are 4 types of timers. We will make use of the "Constant Timer".

To insert the timer into the test plan, the procedure is as follows:

Step 1: Insert the Timer as shown in Figure.

Inserting the Tinier

The "Constant Timer" waits for the specified amount of time before processing the next request.

Step 2: On selecting "Constant Timer", the dialog shown in Figure is displayed.

Constant Timer

Enter the name of the Timer as "Weather Constant Timer" and the delay time as 300 milliseconds as shown in Figure.

Step 3: Before running the test plan, clear the previous test results.
Run ->Clear

Step 4: Run the test plan: Select the "Weather Graph Results" element from the tree, run the test plan using Start option in Run menu (Run -^ Start) and examine the test results as shown in Figure.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Testing Tools Topics