JMeter is a pressure measurement software developed by Apache. It is based on Java and provides GUI, which can run well on Windows, Linux, Mac and other operating systems. In the process of pressure measurement, we often use personalized operations, such as the interface needs encryption, such as the interface needs signature. For example, this interface needs to be generated dynamically every time you request it. How do you stress test it? How to use JMeter for stress testing

download

Jmeter.apache.org/download_jm…

Adding a thread group

Right click “Test Plan” and choose “Add” > “Threads” > “Thread Groups” to dynamically set the number of Threads (concurrent users), the number of loops, or how long the access lasts, when to start and when to end using the scheduler

The diagram shows 10 concurrent users, each requesting twice

Adding HTTP Requests

Right-click “Thread group” and choose “Add” > “Sampler” > “HTTP Request”. Here you can add server name (domain name), port, request protocol, request method, request path parameters and so on

Graphic request domain + path test, HTTP protocol, port 80, and to send parameters

Note: here we set bank_code ${bank_code}, which means bank_code will be dynamically assigned

Added pre-request processing

Right click “HTTP request” and choose “Add” > “PreProcessor” > “BeanShell PreProcessor”. Here we can do a series of processing before the request to randomly generate the order number

String mer_trade_code = java.util.UUID.randomUUID().toString();
vars.put("mer_trade_code", mer_trade_code);
 Copy the code

After the string is concatenated according to the convention, the signature is generated

java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
md.update(str.getBytes());
String sign = new java.math.BigInteger(1, md.digest()).toString(16);
vars.put("sign", sign);
 Copy the code

Added Debug Sampler to view printed information

Right-click “Thread Groups” and choose “Add” > “Sampler” > “Debug Sampler”.

Graph some print information, such as the start and end of thread groups, and our log print log

View the results

Right-click “HTTP Request” and choose “Add” > “Listener”.

View the result tree

The icon shows whether the request was successful or not. If success is green, you can see the sampler result, request, and response data on the right, and see some details about the request

Graphic results

It has the following values to look at response time, sample size (total number of requests), latest sample (last number of requests), average (mean), deviation, median, and throughput.

Use a chart to view the results

You can see the following values: Sample (number), StartTime (StartTime), ThreadName (ThreadName), Label (request Label), Sample Time (request Time) Status (Status, green indicates success), Bytes returns the number of Bytes, Latency (), Connect Time

Monitor results

Aggregate reports Label, Samples, Average, Median, 90%Line, 95%Line, 99%Line, Min, Max, Error%, Throughput (TPS), KB/ SEC

Related articles