How to use JMeter to construct MySQL test data in batches

Source: Internet
Author: User

When we perform API testing, WEB service, or other system module testing, 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 released, 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
    • There is an available account for MySQL
    • Tools such as Java and JMeter are configured correctly

I. Configuring the database connection 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, configure the JMeter db Connection configuration

4. Start JMeter, add the JDBC Connection configuration element, how to: Thread Group----Add the configuration component-->jdbc Connection config. Used to configure 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 for the SQL statement, and Select statement indicates that the request will retrieve the 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" and run Test 9. Adding "response assertion" as a child element of the JDBC 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

How to use JMeter to construct MySQL test data in batches

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.