JMeter Quick Start [Notes]

JMeter is a software that is mainly used for performance testing of server-side systems.
Generally, it can be used to test the performance of web sites and API servers.

Schematic:
insert image description here
Knowledge Reserve:

Basic knowledge of HTTP protocol (Hypertext Transfer Protocol), API concept, HTML, JSON

HTTP was originally used to transmit hypertext (web pages, videos, pictures, etc.) information between browsers and website servers (web services);
because HTTP is simple and easy to use, later, it is not only used between browsers and servers , between servers, between mobile apps and servers, are widely used, and become one of the preferred protocols for communication between software systems.
The biggest feature of the HTTP protocol is that the communication parties are divided into client and server .
insert image description here

The information exchange between HTTP parties is such a way:
the client first sends an http request (request) to the server,
and then the server sends an http response (response) to the client

(The server cannot actively send information to the client first)

Here is an example of 2 http request messages:

GET /mgr/login.html HTTP/1.1
Host: www.baiyueheiyu.com
User-Agent: Mozilla/6.0 (compatible; MSIE5.01; Windows NT)
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate

The request line
is the content of the first line of the http request, indicating what resource to operate and what version of the http protocol is used?
It contains 3 parts of information: the request method, the address of the operating resource, and the version number of the protocol,
which means that the resource is to be obtained . The address of the resource is /mgr/login.html, and the protocol used is HTTP/1.1

GET: Get resource information from the server , which is the most common request .
For example, to obtain web page resources, image resources, user information data, etc. from the server.

POST /api/medicine HTTP/1.1
Host: www.baiyueheiyu.com
User-Agent: Mozilla/6.0 (compatible; MSIE5.01; Windows NT)
Content-Type: application/x-www-form-urlencoded
Content-Length: 51
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate

name=qingmeisu&sn=099877883837&desc=qingmeisuyaopin

For POST, the request method should be to add resource information to the server for processing (such as submitting a form or uploading a file).

For example, to add user information, upload image data to the server, etc.

Specific data information, usually in the HTTP message body

and

POST /api/medicine HTTP/1.1

Indicates adding resource information, adding resources to the address /api/medicine, the protocol used is HTTP/1.1

GET and POST are request methods, indicating the general purpose of this action, whether to obtain information, submit information, or modify information, etc.

Common HTTP request methods are:
PUT: request the server to update resource information, such as to update user name, address, etc.
DELETE: request the server to delete resource information, such as to delete a user, a drug, etc.

Request headers request headers
The request header is the content below the http request line, which stores some information.

For example, what is the domain name of the server to send the request to, what language to use for the response message you want to receive, the length of the request message body, and so on.

Usually there are many request headers, one request header occupies one line

The format of a single request header is: name: value

The HTTP protocol specifies some standard request headers
. Developers can also add their own defined request headers to HTTP messages.

Some data information can be stored in the url of the message body
request and the request header, but some data information often needs to be stored in the message body.
Especially for requests such as POST and PUT, the added and modified data information is usually stored in the request message body.
Not every request has a message body, and get generally does not. He only needs to get it without passing it.

If the HTTP request has a message body, the protocol stipulates that a blank line needs to be inserted between the message header and the message body to separate them.

The data information to be submitted to the server is stored in the request message body.

For example, if the client wants to upload a file to the server, it can send the file data to the server through an HTTP request.

The data of the file should be in the message body of the request.

Another example: in the above example, the client wants to add medicine, and the name, code, and description of the medicine are stored in the request message body.

WEB API request message body is usually text in a certain format, common ones are:
Json, Xml, www-form-urlencoded

Example HTTP response message
:

HTTP/1.1 200 OK
Date: Thu, 19 Sep 2019 08:08:27 GMT
Server: WSGIServer/0.2 CPython/3.7.3
Content-Type: application/json
Content-Length: 37
X-Frame-Options: SAMEORIGIN
Vary: Cookie

{"ret": 0, "retlist": [], "total": 0}

The HTTP response message contains the following parts:
status line status line :
the status line is the first line, which contains 3 parts:

1. Protocol version

In the above example, it is HTTP/1.1

2. Status code

In the above example, it is 200

3. Phrases describing the state

In the above example, it is OK
,,,

Let's focus on the status code, which indicates the result of the server's processing of the client's request.

The status code is represented by a 3-digit number, the first number represents the general type of the processing result, and the common ones are as follows:

• 2xx

Usually indicates that there is no problem with the request message, and the server processed it correctly

The most common is 200

• 3xx

This is a redirection response, and the common values ​​are 301, 302, which means that the url address of the client's request has changed, and the client needs to re-initiate a request to another url.

• 4xx

Indicates that there is an error in the client request. Common values ​​are:

400 Bad Request indicates that the client request does not meet the interface requirements, such as the format is completely wrong

401 Unauthorized means that the client needs to be authenticated before sending the request

403 Forbidden means that the client does not have permission to ask the server to process such a request, such as an ordinary user requesting to delete someone else's account, etc.

404 Not Found means that the url requested by the client does not exist

• 5xx

Indicates that an unknown error occurred while the server was processing the request.

Usually it is a code design problem on the server side, or a failure in the service subsystem (for example, the database service is down)

Response headers
The response headers are the content below the response status line, which stores some information. The function and format are similar to the request
header message body
Sometimes, the HTTP response requires a message body;
similarly, if the HTTP response has a message body, the protocol stipulates that a blank line needs to be inserted between the message header and the message body to separate them;

Guess you like

Origin blog.csdn.net/qq_44114055/article/details/125259601