Use of Jmeter (complete a simple test plan)

Source: Internet
Author: User
Tags http request regular expression port number

1. Open:

Run in the bin directory where JMeter is installed: SH jmeter.sh


2, complete a simple test plan

(1) Set up a thread group

Where, number of threads: number of virtual users. A virtual user occupies a process or thread. Set how many virtual users here is the number of threads set.

Ramp-up Period (in seconds) (preparation time): How long the number of virtual users set will take to start all. If the number of threads is 20 and the preparation time is 10, then 10 seconds will be required to start 20 threads. That is, starting 2 threads per second.

Number of cycles: the number of times each thread sends a request. If the number of threads is 20 and the number of cycles is 100, then each thread sends 100 requests. The total number of requests is 20*100=2000. If "Forever" is checked, then all threads will continue to send the request, one to choose to stop running the script.

(2) Add a sampler:

After adding the completion thread group, select the HTTP request on the right-click menu (Add--->sampler->http request) on the threaded group.

For JMeter, a sampler (Sampler) is a unit that interacts with the server. A sampler typically works in three parts: sending a request to the server, recording the server's response data, and recording the corresponding time information.

Name: This property is used to identify a sampler and it is recommended to use a meaningful name.

server name or IP: The name or IP address of the destination server sent by the HTTP request.

Port Number: The port number of the destination server, the default value is 80.

protocol: the Protocol that sends an HTTP request to the destination server, either HTTP or HTTPS, with the default value HTTP.

Methods : methods for sending HTTP requests, including GET, POST, HEAD, PUT, OPTIONS, TRACE, delete, and so on.

Content Encoding: The encoding of the contents, the default value is iso8859.

path: destination URL path (not including server address and Port).

send parameters with the request: The URL parameter is sent in the request, and for the URL with the parameter, JMeter provides a simple method for parameterization.

The user can set all parameters in the URL in this table, and each row in the table is a parameter value pair (the name 1= value 1 in the corresponding Rul).

(Note: If you just do a stress test on a link, then the location of the path to write the link address is OK, such as: https://www.baidu.com/

Here we use "https://www.baidu.com/" to do the test)

(3) Add assertion---response assertion:

            

Response Assertion: An assertion check is made on the server's response.

Scope of application: Most of us tick "main sample only" is sufficient, because we a request, essentially only one request. But when we send a request, we can trigger multiple server requests, like Ajax, then there is the main sample and Sub-sample.

Response Text: server response Text, general HTTP response, all tick this.

pattern matching rules:

Include: Return results include the content you specified, support regular match

The:

(1) equal to equals. When the return value is fixed, you can return a value to make an assertion with the same effect as equals

(2) Regular match. Matches the return result with a regular expression, but must match all. That is, the regular expression must be able to match the entire return value,

Rather than part of the return value.

(4) Add Summary report to view test results

Select Thread Group, right (add listener, Summary report)

(5) Operation

Once saved, click the Run button.

If the machine is running online, you must first install the JMeter on the test machine and copy the saved JMX files to the test machine (such as TEST.JMX).

then run to the directory where TEST.JMX is located: Sh ~/apache-jmeter-2.13/bin/jmeter-n-T test.jmx

where ~/apache-jmeter-2.13/bin/jmeter is the JMeter path on the machine. The option-N tells JMeter to run the JMeter script with a non-graphical,-T to specify the script file to run .


(6) View test results

           

(7) monitor memory and CPU, etc.

enter $ jconsole at the terminal to bring up a Java monitoring and management console

          

You can select a local process or a remote process and then connect to the following monitoring and management platforms:

           

If you are testing under Linux, you can use the top command and the Vmstat command to monitor the CPU situation.






Three time in JMeter report results


1. Elapsed time Elapsed (= Sample times = Load Duration = Response hours)

This time is the time we used to test, and the time spent on the entire request, from the time of sending to receiving complete

2. Latency Time delay

Infrequently used, indicating that the request was sent to the beginning of the receive response, which <elapsed time

3. Connection time to establish connection times (2.13 new parameters)

Infrequently used, request connection setup time, this time < Latency hours < Elapsed




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.