1. Preparation
Jmeter downloadJmeter.apache.org/download_jm…
After decompressing the jmeter.bat script, you can modify head-xmx-xms to add memory to Jmeter.You can use option-> Choose Language to switch to Chinese
2. Configure thread groups and requests
2.1 Is the default test plan. To add a thread group, right-click -> Add -> Threads -> Thread Group
Parameter: Number of threads is the number of local threads (concurrent) enabled during ramp-up time. Cycle times: If “forever” is selected, the duration can be selected by the scheduler.
2.2 Configuring HTTP Requests
Configuration parameters: protocol header, IP, port number, request method, path, request content…Keep Alive: This option is selected by default. If the pressure test is too high, an address binding exception may occur (java.net.bIndexCeptionaddress already in use:connect).
Solution:
- Add the number of TCP/IP ports for Windows: (select HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters, create a DWORD value, name: MaxUserPort, value: 65534);
- Change to short connection: do not check the keep-alive option, each request to reclaim the connection, re-initiate the connection;
If the request content (message body data) is in JSON format, http-header: content-type =application/json is required
3. Simulate user login
Request parameters require login to obtain token, or request needs to simulate multiple users. Processed by JSON extractor +BeanShell post-handler
3.1 Import CSV account data to simulate multi-account login;
Return the result tree to view the corresponding response data structure, which is parsed by the JSON parser.
3.2 JSON extractor
Parse returns JSON as a local variable (accessible within thread groups)
3.3 Beanshell extractor
Local variables are set to be globally visible (accessible across thread groups)
4. View the result
4.1 return the tree
Request to right-click add -> Listener -> Result tree
4.2 Summary Report
Thread group right-click add -> Listener -> Summary report
Write in the last
If multiple thread groups (all requiring tokens) are tested at the same time, the pressure on the login interface may be heavy in actual scenarios. If you have not found a more reasonable method, please leave comments.