JMeter can be used as a proxy gateway between the Web server and the browser to capture browser requests and Web server responses, which makes it easy to generate performance test scripts. According to the script,JMeter can simulate a real user's stress test on a Web server through a thread group . This article describes the process of using JMeter for database testing. Create a test plan that simulates concurrent users sending SQL requests to the database. Test the database.
The goal of performance testing is to find the system's performance bottlenecks. This article will complete the test of the database by constructing the test scenario.
Scene:
1. Single User: a.sql statement optimization; b. Database constraint checking; c. Paging query;
2. Concurrent users: A. Database connection pool,Web thread pool, database deadlock;
Steps:
(database) test plan:
1. Add Concurrent Users:
Add Thread group, modify the name to JDBC Users. Set the number of threads to 5 and the number of cycles to 2. Other configuration items do not change.
2. Add a JDBC request
2.1. Select the thread group, right-click Add, Configure component ->JDBC Connection configuration. In fact, this is the configuration file that connects to the database through JDBC.
to modify the configuration of DataBase Connection configurations:
Database URL:jdbc:mysql://localhost:3306/jmetertest
JDBC Driver class:com.mysql.jdbc.Driver
Username:Username
Password:passwd
Variable name: TheMySQL connection configuration name is unique in the test plan and is later bound to the JDBC request.
2.2. Select the thread group, right-click Add Sampler (Sampler)->jdbc Request. This is the request sent to the database through JDBC.
Modify:
Variable name:MySQL This is consistent with the configuration name in the database connection configuration (JDBC Connection config) and represents a correspondence relationship. That is, my JDBC request is going through the name MySQL
Database connection configuration file to send to the database.
Query:SELECT id,name,sex from users WHERE name= ' Lisi '
3. Add listeners to view /store test results
Select the thread group, right-click Add Listener-- View results tree.
Select the thread group and right-click to add an aggregate report,->-listener .
Select the test plan, right-click Add Listener-and graphical results.
The above listener is used to view and save test results.
Note: If you see the red JDBC Request or the aggregation report in the result tree after clicking "Run", the error column is nonzero. Indicates that there was an error in the test execution.
Look at the result tree, the Sampler Results tab, and find the Response message message, prompting for the cause of the error.
For example:no suitable driver found for JDBC . indicates a problem with the JDBC driver (I am connecting to a MySQL database).
View the database version as 5.1.30. Find Mysql-connector-java-5.1.30-bin.jar online. Copy to the Lib subdirectory of the JMeter home directory , and then add the library at the bottom of the test Plan page to resolve the issue.
Results Analysis:
I seldom touch database testing in my actual work. So it's stones.
Exposure to a case of a database of suspended animation, the reason is the development of written SQL statement is not rigorous caused. For example:SELECT * from user, look at the statement as if nothing, but the table contains thousands data.
The Web page is only the executive level of the user can operate, but the execution of the web will go into suspended animation state. It takes about 30 minutes to end this state, which is actually the problem of developing SQL statements. Add a few more restrictions
Just fine. In fact, the supervisor level of the user is the right to have this query, but are based on the conditions, the actual will not do the query all the user's operation.
Note:
0.5pt;font-family:arial;color:black ' >
"Turn" learning to use JMeter for stress Testing (iii)--database testing