Constructing MySQL test data using JMeter

Source: Internet
Author: User

Objective:

when we do When testing an API test,Web Service, or other system module, you may need to obtain and record data from the database. The purpose of these tests is to examine the data specified in the database, or to add the specified data to the database , and this article will show how to check, update, or create new data using JMeter. You can implement more complex database interaction tests based on these examples.

In this blog post, we will use the following software:

    • Jmeter 3.3
    • MySQL 5.7.18 Community Edition
    • Java8, when writing a blog, Java 9 has been published, but it is not recommended to use,--2018.3.1

The author has already shared to Baidu Net disk, HTTPS://PAN.BAIDU.COM/S/1I5U58MP

When conducting the following experiments, ensure that the following conditions are met:

    • MySQL Database has been successfully installed and can be accessed normally
    • have a one available account for MySQL
    • tools such as Java and JMeter are configured correctly

First, in Configuring database connections in JMeter

1. Download mysql-connector/j 5.1.42 driver, MySQL official download link: https://dev.mysql.com/downloads/connector/j/ , Download zip or . tar.gz can be 2. Unpack the Tarball

3. Copy xx to the JMeter installation directory under the Lib folder:

Second, the configuration DB Connection Configuration for JMeter

4. Start JMeter, add JDBC Connection configuration elements, how to: Thread Groups--> Add--> Configure Components- ->jdbc Connection Configuration. Used to configure the JMeter connection parameters.

5. Fill in the necessary parameter information, note Variable name is very important, must fill, cannot omit

6. Send data request, add JDBC Sampler

7. Configure the JDBC Request

    • Add Variable Name, it is recommended to add the first step
    • Set The query type of the SQL statement,Select statement indicates that the request retrieves data from the database.
    • Set result variable name, which stores the values of all fields and fields returned from the database. This variable must be unique within the thread group. If this variable is used by more than one JDBC Request , only the contents of the last query are stored.
    • Create a new SQL statement, as shown in.
    • The rest of the parameters can not be filled
8. Add a "View results tree" to run the test9. Add "Response assertion" asJdbcchild elements of request
    • After running the test, if the pattern is found smoothly, no error will be

10. Add "BeanShell assertions" as child elements of the JDBC request

11. Add the following code to the BeanShell assertion:

If an error occurs, an assertion is displayed

Demo file: Use Jmeter to construct MySQL test data . JMX, please refer to the students, thank you.

Reference Links:

[1] https://www.blazemeter.com/blog/mysql-database-and-jmeter-how-to-test-your-connection This blog is very high quality, very recommended to read.

[2] https://dev.mysql.com/downloads/connector/j/MySQL driver, official download link

Constructing MySQL test data using JMeter

Related Article

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.