2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
Jmeter's GUI is mainly used to debug scripts
Make a script first
Demonstration: How to script a hybrid scene?
The proportion of 211 business
Database services: including mysql, redis
The default mysql port is 3306
netstat -lntp | grep 3306
In listening state, 6379 is the default port of redis
netstat -lntp | grep 6379
Project service port 18089
netstat -lntp | grep 18089
211 can convert two stress testing services
One is to register, the other is to register and log in to add products
The two are 50% respectively.
jmeter - add thread group - add - thread - user - thread group
Convert two stress testing services
jmeter --add-logic-controller-throughput-controller
Convert two stress testing businesses.
The first stress test business includes registration, login, and adding products
The second stress test service is registration
50% each
jmeter --add-sampler-http-request
Convert two stress testing services
According to the registration swagger, write and enter the parameters
Generally, you don't need to fill in the ID.
Addtime is not required.
Copy and paste the input data into jmeter
Path according to url
All are passed json
Fill in the IP and port according to the interface document
It is best to add assertions
-n Execute jmeter in non-gui mode
-t executes the test file location, specifies the script to run jmeter, is not in the current path, the full path needs to be written out
-l specifies the generated result file, which is the jtl file
-eAfter the test is completed, generate a test report
-o specifies the storage location of the test report html
-r remote start
Install jdk and jmeter on linux press
Install in usr/local
Directly upload the jmeter on the window to the Linux press, because the plug-ins involved in the debugging script can also be used
Note: If the script involves a csv parameter file, you need to upload the csv' parameter file to the bin directory of jmeter under linux
Aggregate reports and listeners need to be disabled before uploading
5 threads, one thread added every 30 seconds, that is 150
The duration needs to be greater than the Rang up time of 150, and then run for another 50 seconds, so set it to 200
After jmeter is uploaded successfully, verify the jmeter version and whether it is available
There are two places
First, the path to store the test script needs to create a directory to store the HTML report
Before running the script, the res directory must be empty
Second, clean up the data in the database table without considering the existing data.
result
548 requests completed in 13 seconds
Open Aggregate Report
The number of failed requests
resopntime response time
tps
How to view jtl files?
JTL can be opened in any listener, such as viewing result tree, aggregate report, tps, response time.
If opened in aggregate report, click Browse
Such as tps, response time
Look at tps first
Add tps
Click to browse
Response time
Sometimes a single press cannot achieve the desired result and a distributed press is needed.
After all, the resources of a single machine are limited, and it is difficult to support large concurrency. The press of a single machine also has bottlenecks.
Official website:https://jmeter.apache.org/usermanual/jmeter_distributed_testing_step_by_step.html
A server machine as a control machine
The rest of the machines are used as load machines
Target requested service
The controller remotely controls the start and stop of the load machine by sending signals, and collects and summarizes the load machine data.
The load machine mainly starts threads to access the server and the target server under stress test.
Generally, the worker starts the jmeter-server control machine to remotely control the load machine. The load machine starts a thread to request the target to obtain data and then sends it back to the control machine.
Where to put the script when distributed?
One controller with multiple workers
When executing non-gui, the script is transferred to the server. Now it is distributed, where should the script be transferred to?
The script will be transferred to the controller machine. When executed, the script will be sent to each load machine, that is, each worker. After the load obtains the script, it starts to execute the script. After execution, the data will be transferred to the control machine for aggregation.
The firewall needs to be closed. If the firewall is not closed, the port needs to be opened.
All clients must be on the same subnet.
Make sure jmeter can access the server
Make sure the jmeter and java versions are the same
Disable SSL
Requires 3 virtual machines
Use 181 as Controller
Use 182 and 183 as Workers (load machines)
At the same time, jdk and jmeter must be installed on these three virtual machines.
Check the JDK version
Install jmeter on three virtual machines
The local jmeter is transferred to the usr/local directory of the virtual machine
Check the jmeter version after uploading
182、182
First back up the configuration file jmeter.properties
server_port can be modified or not modified. The default value is 1099
Disable SSL
server.rmi.ssl.disable=false, change false to true
Start jemter
./jmeter-server
Check whether the port is in listening state on 182
verify
The control machine telnets the load machine to see if the port is connected
Before configuring the control machine, debug on jmeter on window
win: for debugging
First back up the configuration file jmeter.properties
By default, this machine is used as the load machine.
The current load machine is a remote load machine, change remote_hosts=127.0.0.1 to remote_hosts=192.168.117.182:1099
You must enter the remote load machine's IP and port here. Separate multiple with commas.
Disable SSL
Change server.rmi.ssl.disable=false to server.rmi.ssl.disable=true
Debug it first on this machine
Restart jmeter and re-read the configuration file
After debugging on window, go to linux to configure
Configuring on 181
First back up the configuration file jmeter.properties
The current load machine is a remote load machine.remote_hosts=127.0.0.1
Change toremote_hosts=192.168.117.182:1099
You must enter the remote load machine's IP and port here. Separate multiple with commas.
server.rmi.ssl.disable=false
Willserver.rmi.ssl.disable=false
Change toserver.rmi.ssl.disable=true
Once the script is transferred to the control machine, it will be automatically distributed to each load machine.
Separate test single scenario login
After uploading the script, execute the script
Execute via remote load
/usr/local/apache-jmeter-5.1.1/bin/jmeter -n -r -t test.jmx
Each workload machine (press machine) has 5 threads, and the total control machine has 10 threads
Environment Preparation
Two virtual machines. One master and two slaves. The Windows machine is used as the master, and the slaves are virtual machines.
原理:https://jmeter.apache.org/usermanual/jmeter_distributed_testing_step_by_step.html
Problems:
java.rmi.RemoteException: Cannot start. localhost.localdomain is a loopback address
Created remote object: UnicastServerRef2 [liveRef: [endpoint:127.0.0.1:43474,objID:[-5a8dd143:17e2852fe88:-7fff, 3673082414768940798]]]
Server failed to start: java.rmi.RemoteException: Cannot start. localhost.localdomain is a loopback address.
An error occurred: Cannot start. localhost.localdomain is a loopback address.
Exception information: Server startup exception: Java remote method call threw an exception: Unable to start the service. localhost.localdomain is a local loopback address
The host name obtained by the hostname command is localhost
Use the command cat /etc/hosts to view the hosts configuration. localhost localhost.localdomain localhost4... points to 127.0.0.1
Solution:
Specify the IP address of the remote server host (rmi.server.hostname)
Start by specifying a terminal command
./jmeter-server -Djava.rmi.server.hostname=192.168.2.2