Jmeter User Manual section 7th (Create a database test plan)-[jmeter]

Source: Internet
Author: User

Copyright Disclaimer: During reprinting, please use hyperlinks to indicate the original source and author information of the article and this statement
Http://zlfoxy.blogbus.com/logs/16785336.html

7. Create a database test plan

In this section, you will learn how to create a basic test plan to test a database server. you will create ten users to send 5 SQL requests to the database server. at the same time, you will tell the user to run the test three times. therefore, the total number of requests is 10 user X2 requests x repeated 3 times = 60 JDBC requests. to build this test plan, you will use the following components: thread group, JDBC request
,
Graphical result.

In this example, the MySQL database driver is used. To use this driver, the. jar file contained in it must be copied to the jmeterLibFolder (View

Jmeter classpath for more details ).

 

 
7.1 Add a user

The first step in every jmeter test plan is to add a thread group component. The thread group tells jmeter the number of users you want to simulate, how long the user sends the request, and how many requests they should send.

Add a thread group component. Select the test plan, right-click the component, select Add from the shortcut menu, and select Add --> thread group.

Now you should see that the thread group is under the test plan. If you do not see this component, click test plan component to expand the test plan tree.

 

Next, you need to modify the default attributes. select the thread group component in the tree (if you have not selected it ). now you should see the thread group control panel in the right column of the jmeter window (see Figure 7.1 below ).

 


Figure 7.1. Default thread group

Give our thread group A descriptive name. In the Name field, enter JDBC users.

In this example, the database is mydb and the table name is stocks.

Next, increase the number of users to 10.

In the next field, the ramp-up period is left as the default value 0 s. this attribute tells jmeter how long the delay is when every user is started. for example, if you enter a ramp-up period of 5 seconds, jmeter starts all users before the end of 5th seconds. therefore, if we have five users with a 5-second ramp-up period, the startup latency between each user is 1 second (5 users/5 seconds = 1 user/second ). if you set this value to 0, jmeter immediately starts all users.

Enter a value 3 in the number of cycles field. This attribute tells jmeter how many times you have repeated tests. Let jmeter keep running your test plan and select the "always" check box.

 

In most applications, You have to manually accept the changes you make in the control panel. however, in jmeter, after you make the changes, the control panel will automatically accept your changes. if you change the component name, the tree will update the component name to a new one after you leave the Control Panel (for example, after selecting another tree component)

See Figure 7.2. view the JDBC users thread group after completion.


Figure 7.2. JDBC users thread group

 

 
7.2 Add a JDBC request

Now we have defined our users and it is time to define their tasks. In this section, you will specify the JDBC request to be executed.

Select the JDBC users component first. right-click your mouse and choose add> Configure component> JDBC connection configuration. then, select the new component to view its control panel (see Figure 7.3 ).

Set the following fields (assume that we use a local MySQL database named test ):

  • Variable name bound to pool. This requires a unique identifier for this configuration. It is used by the JDBC sampler to identify the used configuration.
  • Database URL: JDBC: mysql: // localhost: 3306/test
  • JDBC Driver Class: COM. MySQL. JDBC. Driver
  • Username: Guest
  • Password: Password for guest

The default value can be retained for the remaining fields.

Jmeter creates a database connection pool using the configuration specified in the control panel. this pool is mentioned in the 'variable name' field of the JDBC request. some different JDBC configuration elements can be used, but they must have independent names. each JDBC request must point to a JDBC configuration pool. there can be more than one JDBC pointing to the same pool.


Figure 7.3. JDBC Configuration

Select the JDBC users component again. right-click and choose add> sampler> JDBC request. then, select the new component to observe its control panel (see Figure 7.4 ).


Figure 7.4. JDBC request

In our test plan, we made two JDBC requests. the first is used to query Eastman Kodak stocks, and the second is used to query Pfizer stocks (you should modify these items in the example to suit your special database ). see the following description.

Jmeter sends requests in the order you add them to the tree.

First, modify the following attribute values (see Figure 7.5 ):

  • Change the name to "Kodak ".
  • Enter the pool name: MySQL (same as in the Configuration component)
  • Enter the SQL query character Band.

 


Figure 7.5. JDBC request for querying Eastman Kodak stocks

Next, add the second JDBC request and edit the following attributes (see Figure 7.6 ):

  • Change the name to "Pfizer ".
  • Enter the SQL query string field.

 


Figure 7.6. JDBC request for Pfizer stock Query

 

 
7.3 Add a listener to observe/store test results

You finally need to add a listener to the test plan. This component is responsible for storing all your JDBC request results in a file and presenting them in a visualized data model.

Select the JDBC users component and add a graphical result listener (add --> listener --> graphical result ).


Figure 7.7. graphical result listener

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.