Learning to use JMeter for stress Testing (iii)--database testing

Source: Internet
Author: User

Database testing

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, simulate

The concurrent user sends the SQL request 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. Adding 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

The Variable name:mysql 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 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; It seems like nothing to look at the statement, but there is thousands data in the table.

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.

Learning to use JMeter for stress Testing (iii)--database testing

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.