Preface
As a test engineer, I believe that everyone is familiar with jmeter. The first few blogs of the editor also wrote about jmeter for interface automation testing. Today, it is mainly used to introduce the use of jmeter for performance testing and stability. The actual test.
1. Introduction to performance test
Performance testing is different from the storage software products and distributed storage performance testing (fio, vdbench) we have mentioned before. Fio and vdbench are generally true for hardware performance testing. This time we introduce software performance testing.
Taking web projects as an example, performance test cases include but are not limited to the following:
Performance test module | Performance test items | Performance test case |
Module A | Module A Topic 1 Precise Search | Searching for 300,000 pieces of data in the test environment returns results within 3 seconds |
Module A Topic 1 Fuzzy Search | Searching for 300,000 pieces of data in the test environment returns results within 3 seconds | |
Module B | Module B Topic 1 Search | 100 million pieces of data are accurately queried in the test environment and the result is returned within 2 seconds, and the fuzzy query returns the result within 5 seconds |
The total number of associations is less than 50, and the result will be returned within 3 seconds | ||
The total number of associations is less than 150, and the result will be returned within 5 seconds | ||
Module C | Module B Topic 1 Search | 500,000 search results returned within 3 seconds in the test environment |
Module B Topic 2 Search | 500,000 search results returned within 3 seconds in the test environment | |
Module B Topic 3 Search | 500,000 search results returned within 3 seconds in the test environment | |
Module B Topic 9 Search | 500,000 search results returned within 3 seconds in the test environment | |
Module B Topic 10 Search | 500,000 search results returned within 3 seconds in the test environment | |
Number of concurrent users | 50 users | Log in and operate to support 50 concurrent users |
As shown in the above table, there are some examples of performance test cases
2. Introduction to stability test
For web projects, stability generally refers to the trouble-free operation within a specified time. Including but not limited to the following items:
Test module | test item | Test case | expected outcome |
System as a whole | Continuous load operation | The product can run continuously for 3*24 hours without failure under the condition of about 50% load | During the 3*24 hours of operation, the system was operating normally and no faults occurred. |
As shown in the above table, the overall software project can be carried out for 3*24 hours, or 7*24 hours without failure under 50% load (CPU, memory).
3. Jmeter script recording
1. Open jmeter, select the recording template and click create
3. View the catalog of templates
From the picture below, we can see that it is in English, and we can change the name to Chinese by ourselves so that we can check it by ourselves.
Note: Because in the real environment, corporate websites such as Baidu www.baidu.com and Tencent have their own security protection measures.
There is no way to show it to everyone in actual combat, so I just found a website on the Internet to test it, as follows, we are the following website
Carry out the performance test and stability test of "calculating string length". As an example.
3. Turn on the proxy settings of win10
4. Turn on the http proxy server
When the http proxy server is turned on, we go to the browser to start the operation, and jmeter has actually recorded it for us. Go to the website to refresh
jmeter began to capture the behavior of our operations.
At this time we should pay close attention to the request generated in the recording controller. As shown below:
In order for us to get what we want more clearly, we generally comment on newly generated requests every time we perform an operation (mouse click, etc.).
Add comments as shown in the figure below: In this way, every step of our operation is clearly visible.
5. After recording, stop the proxy server and turn off the built-in proxy of win10
As of the above steps, the recording script has been executed.
4. Performance test run script
1. Add an aggregate report component
2. Set the cycle time or number of times
The following figure represents, 1 thread, run 1 time
If it is a concurrent test with 100 users, it is 100 threads
3. Click Execute, after the execution is completed, and view the results of the result tree.
View the result tree:
From the figure below, we can see that the scripts we recorded in the result tree are all executed in a one-to-one correspondence, and all green indicates successful execution. (Green may not be successful in actual combat)
We can also further view the details of script execution: including request and response data .
4. View the aggregate report
The aggregation report is a comprehensive report of the script executed this time, which contains the time we executed this toluene, the correct rate and the error rate.
As shown in the figure below, we generally have to look at two places,
Average: The average request response time, in milliseconds. The data in the figure shows us 619ms, which means that the response time of the performance test we performed is 619 milliseconds.
If our test requires a result to be returned within 3 seconds, 619ms<3s, it means that the request performance test has passed.
Error: Generally, if it is 0, it means no error is reported, that is, the test is normal.
5. Stability test run script
1. Modification time
In general, the script to be run for stability is the same as the script for performance testing, that is, the above steps are executed once, but the difference is that the test time will change.
Our stability test requirement is 3*24 hours, trouble-free operation. So the time has to be changed.
As shown in the figure below, the number of cycles has been changed to forever , and the scheduler is checked . Duration (seconds): 3*24*3600 seconds = 259200 seconds . If there are 100 concurrent users, the number of threads must be changed to 100
2. View the result tree and aggregate report
In this way, the script will be executed in a loop for three days and three nights. After the time is up, the program will stop. Let's check the result tree to see if there is any script error.
If there is no error, and in the aggregate report, Error is also 0%, which means that the stability test has passed.
to sum up:
This article uses jmeter to give a general introduction (in more detail) to the performance test and stability test of the web project. The process is very comprehensive.
But you may have various problems when you use it yourself. Don't worry about everything is normal, just solve it a little bit.
If you have any questions, please leave a message, you must reply when you see it.