Constantly put pressure on the database and verify the performance of database processing So how can we perform pressure testing on the database in jmeter? We can add a component called jdbc to jmeter to connect and operate the database.
-
Install and download jmeter on the computer and unzip OK
-
Download the mysql driver and copy and paste the mysql jar package (mysql-connector-java-8.0.30.jar) to the lib path in jmeter's D:\apache-jmeter-5.4.3\lib
-
Start jmeter, add a JDBC Connection Configuration, connection pool configuration file
-
Add a thread group, add driver jdbc request
1. Install mysql driver
Open the https://dev.mysql.com/downloads/connector/j/ address, select platform independent, select the zip package to download, and unzip the zip package after the download is complete
2. Place the jar package into the lib directory
Put the mysql-connector-java-8.0.30.jar package in the decompressed compressed package under the path of D:\apache-jmeter-5.4.3\lib, which is the lib path of jmeter!
3. Add components to connect to the database
Start jmeter to add a JDBC Connection Configuration, test plan -> add -> configuration element -> JDBC Connection Configuration, used to connect to the database
Defines the name of the connection database connection pool
configuration item | illustrate |
---|---|
Variable Name for created pool | The name of the database connection pool, fill in the variable name, and bind it to the Variable Name in the JDBC request |
Connection pool parameter configuration
Basically keep the default, you can modify it as needed
configuration item | illustrate |
---|---|
Max Number of Connection | The maximum number of database connections can generally be set to 0, which means that each thread uses a separate database connection, and the database connection between threads is not shared |
Max Wait (ms) | Retrieve the connection maximum waiting time in the connection pool |
Time Between Eviction Runs(ms) | Thread idle time If a connection in the current connection pool is idle for time Between Eviction Runs Millis and still not used, it will be physically closed |
Auto Commit | Automatically submit sql statements |
Read timeout(ms) | Timeout waiting for server response |
Transaction isolation | Transaction isolation level, mainly has the following options: (JMX encryption and decryption) TRANSACTION_NODE transaction node, TRANSACTION_READ_UNCOMMITTED transaction uncommitted read, TRANSACTION_READ_COMMITTED transaction committed read, TRANSACTION_SERIALIZABLE transaction serialization, DEFAULT default, TRANSACTION_REPEATABLE_READ transaction repeated read |
Preinit Pool | Initialize the connection pool immediately If it is False, the response time of the first JDBC request will be longer, because it includes the connection pool establishment time |
Database connection pool configuration
configuration item | illustrate |
---|---|
Variable Name for pool declared in JDBC Connection Configuration | The name of the database connection pool is consistent with the name of the Variable Name for created pool of JDBC Connection Configuration |
4. Add thread group
After setting, you can add a thread group, add a JDBC Request in the thread group, thread group > sampler > JDBC Request
-
Write the variable name in the connection configuration to the JDBC Request
-
Fill in the sql statement you need to execute
5. Run the thread group
After running, you can see some results of your sql statement running
See if the script is working correctly by looking at the results tree. In the navigation tree on the left, select View Result Tree to check whether the request result meets expectations. If the request fails or the result return does not meet expectations, the script or SQL statement needs to be readjusted.
The following is the supporting information. For friends who do [software testing], it should be the most comprehensive and complete preparation warehouse. This warehouse also accompanied me through the most difficult journey. I hope it can help you too!
Software testing interview applet
The software test question bank maxed out by millions of people! ! ! Who is who knows! ! ! The most comprehensive quiz mini program on the whole network, you can use your mobile phone to do the quizzes, on the subway or on the bus, roll it up!
The following interview question sections are covered:
1. Basic theory of software testing, 2. web, app, interface function testing, 3. network, 4. database, 5. linux
6. web, app, interface automation, 7. performance testing, 8. programming basics, 9. hr interview questions, 10. open test questions, 11. security testing, 12. computer basics
Information acquisition method: