Popular in the whole network, detailed explanation of Jmeter interface test and Jmeter performance test (super detailed)


foreword

Jmeter interface test

1. Create a test task
Add a thread group, right-click the test plan, and click Add-"Thread (User)-"Thread Group in the shortcut menu. Setting the thread group mainly includes three parameters: the number of threads, Ramp-Up, and the number of cycles.

D1

Number of threads: Set the number of virtual users. A virtual user occupies a process or thread. The number of threads is equivalent to the number of virtual users.

Ramp-Up: The startup time of the set number of threads, in seconds. If the number of threads is 100 and the preparation time is 20 seconds, it takes 20 seconds to start 100 threads, and an average of 5 threads are started per second.

Number of loops: The number of requests sent by each thread. If the number of threads is 100 and the number of loops is 2, then each thread sends 2 requests, and the total number of requests is 100*2=200 times.

If the "Forever" check box is checked, all threads will send requests in a loop until the stop button on the toolbar is manually clicked or the set thread running time ends.

For the interface test this time, the default value is 1.

2. Add the HTTP request of get
Right-click the line group, and click Add-"Sampler-"HTTP Request in the shortcut menu.

D2

Protocol: The protocol when sending an HTTP request to the target server, which can be HTTP or HTTPS, and the default is HTTP if it is not filled.

Server IP and port: Enter the target server address and port number.
Content Encoding: The default value is iso8859
Method: Select for the request method
Path: Enter the request target address
Parameter: Enter the parameter value of the query

3.
The method of adding post HTTP request is the same as above, but the request method is different. This time, POST is used to transfer parameters to the server and the URL address of the POST request.

D3

According to the interface document provided by the development, refer to the incoming parameter option and enter it.

4. Add an assertion
Right-click the conference query information and add conference information respectively, Add-"Assertion-"Response assertion
This time, select the response text, and then enter the data that needs to be matched.

D4

5. Add and view the result tree
Right-click the release system project, click Add-"Listener-" View the result tree, after running:

D5

A green mark is displayed for success, and a red mark is displayed for failure. You can view the data returned by each use case.

6. Add a table to view the results

D6

You can view time-consuming and byte size, result status, and use case information in more detail.

Jmeter performance test

Since JMeter does not support recording well enough, the common method now is to use Badboy to record, generate JMeter scripts, then open them with JMeter, and add listeners to view the results.

Double-click the software icon to open badboy and you will see the following interface:

D7

1. Start recording
Enter the URL of the web application you want to record in the address bar (the part framed in red in the figure), and click the red dot button to start recording.

After recording starts, you can directly operate the web application under test in Badboy's built-in browser (right side of the main interface), and all operations will be recorded in the editing window on the left side of the main interface: as shown in the figure below

D8

export script as jmeter

D9

The number of threads represents the number of users sending requests, and the Ramp-up period (inseconds) represents the total time interval for each request to occur, in seconds. If the number of my requests is 5, and the Ramp-up period (inseconds) parameter is 10, then the interval between each request is 10/5, which is 2 seconds.

If Ramp-up period (inseconds) is set to 0, it means concurrent requests.

Finally, clear the checkbox for the number of cycles to "Forever" and enter 1. This value tells JMeter how many times to repeat your test. If you enter 1, then JMeter will only run the test once. To run your test plan continuously, select the "Forever" checkbox.

As shown in the figure below, simulate the number of 1000 concurrent users to run a login test.

D10

2. Add monitoring
This is mainly used to view test results, which can be displayed in different forms.

Here is an example to add a listener: view results in a table, aggregate report and graphical report thread Group->Add->Listener->Aggregate Report (graphical report, view results in a table) as shown in the following figure:

D11

After the program is running, you can view the corresponding test results. Here, the following report is obtained by taking the instantaneous concurrency of 1000 thread groups as an example:

D12

The meanings of the parameters in the above chart are as follows:

The sample count is the total number of requests sent to the server.
The latest sample is a number representing the time when the server responded to the last request.
Throughput is the number of requests a server handles per minute.
The average is the total elapsed time divided by the number of requests sent to the server.
The median value is the number representing the time below which half of the servers responded and half above.
Skew represents server response time variation, the magnitude of the dispersion measure, or, in other words, the distribution of the data.

It can be seen that the average response time is 1630ms, the throughput is 3,940.887/minute, and the average response median value is 230ms when 1000 people are concurrent concurrently.

D13

The meaning of the chart is explained as follows:
Label: Indicates the request type, such as Http, FTP and other requests.
#Samples: That is, the number of samples in the graphical report, and the total number of samples sent to the server.
Average: That is, the average response time in the graphical report, which is the total running time divided by the number of requests sent to the server.

Median: that is, the median value of 50% user response time in the graphical report, half of the server response time is lower than this value and the other half is higher than this value.
90% line: It means that the response time of 90% of requests is smaller than the obtained value, that is, the response time of 90% of users.

Min: It is a number representing the time, and it is the minimum time for the server to respond.
Max: It is a number representing the time, which is the maximum time for the server to respond.
Error%: The error percentage of the request. The number of requests with errors in this test/total number of requests.
Throughput: That is, the throughput in the graphical report, here is the number of requests processed by the server per unit time, pay attention to whether it is seconds or minutes. By default it means the number of completed requests per second.

KB/sec: The amount of data received from the server per second.

To obtain correct data, the aggregated report error% must be 0.00%, otherwise it means that all users have not passed the test. Here, the average response time is 1630ms, and the median value of the average response is 230ms.

An error occurred in the error in the above figure, and the obtained data is not accurate. According to the log and table, the connection request timed out in the middle process, and the response time for the number of received requests is 0 within the response time.

As shown below:

Q14

D16

During the test, the average response time, throughput, and the number of concurrent connections are an important measure of our performance test, but in the test, especially in the aggregation report, the 90% Line obtained is equivalent to the 90% line proposed by the user %Response time. This value is also of great reference value for our performance test analysis.

90% response time means that among the sent requests, 90% of the user response time is shorter than the obtained value. It also shows that when a system is in use, 90% of the user response time can reach this value, then It provides a good reference value for system performance analysis.

If the number of threads is changed to 500 concurrent connection requests, Error will not appear as a result, and the obtained performance test data is accurate.

D15

In short, it is necessary to continuously optimize the comparison data, approach the optimal state, and determine the number of concurrent loads.

The following is the most complete software test engineer learning knowledge architecture system diagram in 2023 that I compiled

1. From entry to mastery of Python programming

Please add a picture description

2. Interface automation project actual combat

Please add a picture description

3. Actual Combat of Web Automation Project

Please add a picture description

4. Actual Combat of App Automation Project

Please add a picture description

5. Resume of first-tier manufacturers

Please add a picture description

6. Test and develop DevOps system

Please add a picture description

7. Commonly used automated testing tools

Please add a picture description

Eight, JMeter performance test

Please add a picture description

9. Summary (little surprise at the end)

No matter how difficult and dangerous the front is, we must embark on the journey with courage and determination. Struggle is not only a state, but also a belief. Only by persevering and forging ahead can we create brilliant chapters on the stage of life and achieve our own legend.

Every effort is an opportunity to change my destiny. No matter how bumpy the road ahead is, I still firmly believe that persistence and dedication will be rewarded. Believe in your ability, dare to challenge the limit, write your own glorious chapter with courage and wisdom, and bloom endless flowers of dreams.

Overcoming thorns and thorns without fear of hardships, and writing brilliance on the decisive battlefield. Struggle is a journey full of dreams. Only by doing your best can you surpass yourself and break through the winding path of life. Persevere, pursue enthusiasm, strive to create your own colorful stage, and achieve the infinite light in your heart.

Guess you like

Origin blog.csdn.net/csdnchengxi/article/details/132167931