Jmeter —— jmeter uses http in the sampler to send requests

Send HTTP request using Jmeter

A sampler is a type of component used to simulate user operations, send requests to the server and receive response data from the server, among which the HTTP request sampler is used to simulate common http requests

Proceed as follows:

Table of contents

Step 1: Add thread group

Step 2: Add HTTP request

Step 3: Add http header manager

Step 4: Add View Results Tree

 Step 5: Click Run

Step 1: Add thread group

Right click on the test plan - add - thread (user) - thread group

As shown below:

The meaning of "thread group": JMeter is implemented by Java, and uses a Java thread to simulate a user, so a thread group refers to a group of users, in other words a thread group is a group of virtual users. These virtual users use To simulate access to the system under test

①: Number of threads: here refers to the number of virtual users. The default input is "1", which means that a virtual user is simulated to access the system under test. If you want to simulate 100 users, enter 100 here.

②: Ramp-Up time (seconds): The virtual user growth time. That is to say, start all threads within the specified time

③: Number of cycles: set how many times a virtual user will perform the test here. The default is 1, which means that after a virtual user finishes doing things, the virtual user stops running. If "Forever" is selected, it means that the test will not stop at all after it runs, unless you force it to stop

Step 2: Add HTTP request

Right-click the thread group - add - sampler - HTTP request; as shown below

 Introduction to the basic interface options; as shown below

Name: This attribute is used to identify a sampler, it is recommended to use a meaningful name

Comments: have no effect on testing, only user-recorded user-readable comments

Protocol: The protocol when sending HTTP requests to the target server, it can be http or https or File, the default value is http

Server name or IP : The target server name or IP address sent by the HTTP request

Port number: The port number of the target server, the default value is 80, the port of https is 443

http request: method to send HTTP request, available methods include GET, POST, etc.

Path: target URL path (excluding server address and port)/full path can be written, but not standardized

Content encoding: the encoding method of the content, the default value is iso8859; generally fill in utf-8

Automatic redirection: If this option is selected, when the response after sending the HTTP request is 302/301, JMeter will automatically redirect to a new page, but Jmeter does not record the content of the redirection process.

Follow Redirect: The default option of the Http Request sampler, when the response code is 3xx, it will automatically jump to the target address. Different from automatic redirection, Jmeter will record all request responses during the redirection process. When viewing the result tree, you can see the content returned by the server. If there are multiple jumps, multiple requests will be recorded. This is the default option

Use keep Alive: When this option is selected, HTTP communication between jmeter and the target server will be carried out using KeepAlive, which is selected by default.

Use multipart/from-data for post: When sending a POST request, use the multipart/from-data method or the application/x-www-form-urlencoded method to send, which is not selected by default.

Browser-compatible header: When multipart/form-data is checked, checking this option will cut off the Content-Type and Content-Transfer-Encoding in the HTTP request header, and only send the Content-Disposition part.

Parameters: You can set all the parameters in the URL in this table. Each line in the table is a parameter-value pair. At this time, the encoding option is set to UTF-8 and it is best to check it to prevent the parameter value from containing ASCII Control Chars or Non-ASCII characters or other symbols cause garbled characters.

Message body data: the data information sent together with the request, here can support multiple data formats, json, xml, etc.;

File upload: the file information sent together with the request, the parameter name is the parameter corresponding to the file to be sent, MINE Type is the resource media type

Introduction to advanced interface options

Implementation: the method of sending http requests, the options are java and HttpClient4, and the default is HttpClient4

Connection: connection timeout setting, in milliseconds

Response: Response waiting timeout setting, in milliseconds

Obtain all contained resources from HTML files: When this option is selected, jmeter will also parse the HTML and obtain all resources contained in HTML (pictures, flash, etc.) )

Parallel download: Set whether to use a self-built resource pool, and the size can be set after checking

Quantity: resource pool size, the default is 6

URL must match: URL matching filter, fill in this item will only download the resource matching the URL of this content item

Source address: only used for http protocol and Implementation is HttpClient4, this attribute is used to enable IP spoofing. will override the default local IP address used by this http request. Used in cases where the Jmeter host has multiple IP addresses (i.e. IP aliases, network interfaces, devices). The value can be a hostname, an IP address, or a network interface device such as "ey0" or "l0" or "wlan0".

Proxy server: configuration information about the proxy server

Save response as MD5 hash: If this option is selected, only the MD5 value of the server response data will be recorded during execution, and the complete response data will not be recorded. When a test with a very large amount of data is required, it is recommended to select this option to reduce the overhead of the sampler recording response data

Step 3: Add http header manager

Right-click on Baidu Search——Add—Configuration Components—Add HTTP Information Header Management, add the header header information of Baidu Search

Step 4: Add View Results Tree

Right click on Baidu Search - Add - Listener - View Results Tree

 Step 5: Click Run

Click the triangle icon in the menu bar to start running, and then click to view the result tree, red means error, green means success

The following are supporting learning materials. For friends who do [software testing], it should be the most comprehensive and complete preparation warehouse. This warehouse also accompanied me through the most difficult journey. I hope it can help you too!

Software testing interview applet

The software test question bank maxed out by millions of people! ! ! Who is who knows! ! ! The most comprehensive quiz mini program on the whole network, you can use your mobile phone to do the quizzes, on the subway or on the bus, roll it up!

The following interview question sections are covered:

1. Basic theory of software testing, 2. web, app, interface function testing, 3. network, 4. database, 5. linux

6. web, app, interface automation, 7. performance testing, 8. programming basics, 9. hr interview questions, 10. open test questions, 11. security testing, 12. computer basics

Information acquisition method:

Guess you like

Origin blog.csdn.net/myh919/article/details/132082088