Note: this introduction to basic component is less, more is a advanced use of jemter tools, if can be for beginners to learn from other reference documents or official website: jmeter.apache.org/usermanual/…
1. Common components, execution sequence and scope of Jmeter
1. TestPlan TestPlan
2. Thread Group Thread Group
3. Configure ELement Config
4. Preprocessor
5. Timer Timer
6. Samper
7. Rear processor Postprocessor
8. Assert component Assertions
9. Listener
10. Logical Controller
11. Test the TestFragment
12. Non-test Element
Order of execution among components: Configure component → preprocessor → timer → sampler → postprocessor → assertion → listener
Same component execution order: execute sequentially, who is on top, who executes first
Scope: A component affects sibling nodes and child nodes
2. Configure Jmeter parameters
1. Use the User Parameters component
Add two parameters, username and password. Three users are configured. To reference a variable
{password} references; If you have three threads, thread 1 takes admin, thread 2 takes Tom, thread 3 takes Jack; If you have 4 threads, thread 4 takes admin (next cycle)
2. Use the CSV Data Set Config component
The method of reading the CSV file is the same as the principle of parameters, and the method of quoting the defined parameters is also through ${variable name}, simple example is as follows:
Demo.CSV File contents
Username,password
Admin,123
Tom,123
Jack,123
Copy the code
Read the file Settings and define variables as follows: where because my CSV file has a header and uses English comma separated; Therefore, the configuration is shown as follows:
- Add parameters through the function helper
Select the function in the red box, click the green box to generate, and copy the contents of the blue box to the place where you want to reference it
3. Logical Controller – Transaction Controller
The transaction controller can group multiple requests into one transaction and analyze the aggregated report on a transaction basis.
Note: If the sum difference between the transaction request data and the HTTP request data below is not large, the data can be used as the correct data. If the total number of transactions is large, the value of the test data is low. The reasons may be:
-
Jmeter is not running properly. You need to modify the configuration file to adjust the memory
-
There are too many threads of requests running on a single machine, and the CPU and memory are saturated. Need to use distributed request (online load)
-
The configuration of the machine is low or there are other programs running, insufficient resources; Run using the command line
4. Rear processor-re extractor
Regular expression
Details on www.runoob.com/regexp/rege…
5. Back processor – JSON extractor
6. Collection point (true concurrent use)
Use synchronization timer to achieve
7. Jmeter online load and command line
Online load: master machine (storing scripts) → Load machine (running scripts) Procedure: A. Start jmeter-server.bat or jmeter-server.shb on each load machine. Modify the jmeter.properties file on the main controller
# please find remote_hosts configuration remote_hosts = 127.0.0.1, 192.168.6.166:1099Copy the code
Load machine configuration
Server_port =1099 # Server_port =1099 # server.rmi.localport=1099 # Find server.rmi.ssi. Disable =true uncomment server.rmi.ssi. Disable =trueCopy the code
C. Start jmeterD on the main control machine. Select remote start or remote start to run jmeterD on the command line
Jmeter -h View all commands -n non-GUI mode -> Run Jmeter -t test file in non-GUI mode -> Jmeter test script file to run -l log file -> Record result file -r remote execution -> All remote servers specified in the jmter. properties file -h proxy host -> Set the proxy host used by JMeter -p proxy port -> Set the port number of the proxy host used by JMeter Example: JMX -l logfile1. JTL -h 192.168.1.1 -p 8080 Run the command in the following format: jmeter -n -t [JMX script path] -l [Test output file path] parameter Description: -n: jmeter -n -t test1.jmx -l logfile1. -t: indicates the path of the Jmeter script. -l: indicates the path of the output result. If this file is not available, it is automatically created and CSV or JTL text can be generatedCopy the code
8.Beanshell
Is a small embedded Java source code interpreter with object scripting language features that can dynamically execute standard Java syntax.
- The Jmeter beanshell
L Timer beanshell
L Preprocessor Beanshell
L The sampler beanshell
L Rear processor Beanshell
L assertion beanshell
L Listener beanshell
Common built-in variables for JMeter’s Beanshell
Log → Write information to jmeter.log file log.info (” This is a log “)
CTX → References the context of the current thread
Vars.get (string key)→ Get variables from Jmeter
Vars. Put (String key, string key)→ Write data to a variable
Get (string key)→ read from jmeter.properties
Props. Put (String Key, string key)→ Define properties
Prev. GetResponseDataString () – > get response information
Prev.getresponsecode ()→ Get the response code
Finally: you can receive a free 216-page software test engineer interview guide by clicking on the blue font. And the corresponding video learning tutorial free to share! . It includes basic knowledge, Linux prerequisites, Shell, Principles of Internet programs, Mysql database, special topics of package capture tools, interface testing tools, advanced Python programming, Web automated testing, APP automated testing, interface automated testing, advanced continuous integration of testing, test framework development and test framework, and performance testing , safety test, etc.
If my blog is helpful to you, if you like my blog content, please “like” “comment” “favorites” one key three even oh!