A, Jmeter download and install deployment
Download extracting archive JMeter
Download: http://jmeter.apache.org/download_jmeter.cgi
JMeter after decompression, ... \ apache-jmeter-4.0 \ bin \ jmeter.bat, open directly without installation.
Download and install JDK
Download: http: //www.oracle.com/technetwork/java/javase/downloads/index.html
Note to download the corresponding version of the Java JDK according to Jmeter requirements. As shown below.
Environment variable settings
jdk settings:
New system variable JAVA_HOME, value: jdk installation directory, such as: C: \ Program Files \ Java \ jdk1.8.0_152
New system variable CLASSPATH, value:% JAVA_HOME% \ lib \ dt.jar;% JAVA_HOME% \ lib \ tools.jar;
Value "Path" modified system variables, plus the beginning:% JAVA_HOME% / bin
Jmeter settings
New system variables JMETER_HOME, Jmeter path value, such as: D: \ apache-jmeter-4.0
修改CLASSPATH,添加:%JMETER_HOME%/lib/ext/ApacheJMeter_core.jar;%JMETER_HOME%/lib/jorphan.jar;%JMETER_HOME%/lib/logkit-2.0.jar
Two, Jmeter basic use
This section will be an example to cut, how to design a basic Jmeter test scripts, several issues need to be addressed unfold:
1. How to send HTTP requests?
2. How flexible read parameters? (Another article to explain)
3. How can I see results?
4. How assertion?
5. How to set up the scene: the number of users, number of requests, request time interval, or duration request time?
6. How to program deal with individual requirements? (Beanshell, another article to explain)
How to send HTTP requests?
First, add a thread group, then add the following three:
Default HTTP request (Add-> Config element)
HTTP header information manager (Add-> Config element)
HTTP请求 (Add->Sampler)
Default HTTP request may be set in the HTTP default for all of its scope, the HTTP request including host, port, protocol, etc.
HTTP header information manager, sends a request to specify the main header, as shown below:
Of course, if you need to log http request authorization to do premise, you can add a HTTP Authorization Manager. (Config Element-> HTTP Authorization Manager)
Returning now to the HTTP request, the setting is as shown below.
Note: "Automatic redirection" option is available when the method is "GET" or "HEAD" when
To here, a basic configuration of the HTTP request has been finished, the brief summary, A) is the need to set the server HTTP request message including the requested protocol (HTTP), the request address, port number, the method (get, post) HTTP requests and request path, and to set parameters sent with the request in accordance with needs. b) further provided multiple HTTP requests if the next thread group, these requests are sharing a Server address, you can add HTTP Request Defaults for a unified set of server information, mainly protocol, server address and port number. c) The final step is the first request (request headers), set to a manager of the HTTP header.
How to analyze the results?
Add the listener, common: Thread Group -> Listener -> Aggregate Report
Label - Sample label.
# Samples - The number of the same name Label
Average - The average response time
Median - 50% of the time spent request does not exceed the value
90% Line - 90% of the time spent request does not exceed the value
Min - minimum response time
Max - the maximum response time
Error% - error rate
Throughput - Throughput, ie how many requests per second
Sent Kb / sec - throughput, number Kb per second
You can also add other listeners:
Tree View Results
View the results in tabular form
summary report
FIG Response Time
How assertion
Common asserted: Thread Group -> Add assertion -> Response Assertion
important point:
When the mode-matching rules "including" and "match", supports regular expressions; when the "Equals" or "the Substring" is the exact match.
How to set up the scene?
Thread group were set as follows:
The actual scenario, you may also need to consider the time interval between each request, known as the "think time." You can be set by a timer.
E.g:
Fixed Timer
Gaussian random timer
The scope of the timer, then the timer is performed before each sampler, rather than (or whether the position before the sampler below); Before performing a sampler, all current timers scope will be executed; if desired timing of is applied to only one sampler, the timer is added as a child node;
If you want to wait after executing the sampler can be used TestAction.
User written program
We may often encounter requests need to do some special processing parameters or results, may require the user to write additional programs. We recommend to beanshell, compatible java language, it is recommended after the eclipse debugged the code, copy and paste to come.
Jmeter in Beanshell related components as follows:
BeanShell preprocessor
Beanshell postprocessor
Beanshell assertion
Beanshell timer