Apache JMeter is a pure Java open-source software for load testing or performance testing. Describes a method and JMeter building distributed test environment used in the previous article, but after a main multi-pressure measurement from the environment, and is specified by the pages in the demo manner, with specific examples of the article to explain how to use the command line to dynamically specify the node, because the integration JMeter of time, this manual operation requires the use of an automatic way to replace, but the command line directly provides the option to be supported.
a
JMeter distributed pressure test environment preparation
Detailed construction method with reference to the following environment:
- https://blog.csdn.net/liumiaocn/article/details/101638943
The results confirmed
Start command: jmeter -Djava.rmi.server.hostname = machine name or IP address of the -Dserver_port = port number -s -j log file name
Prepared in advance of the start Slave nodes only need to set aside three of JMeter, there will be three inactive after starting the process JMeter
liumiaocn:apache-jmeter-5.1.1 liumiao$ ps -ef |grep jmeter |grep -v grep
501 17284 16769 0 6:47AM ttys001 0:00.01 /bin/sh bin/jmeter -Djava.rmi.server.hostname=192.168.31.242 -Dserver_port=31099 -s -j /tmp/jmeter-slave-1.log
501 17291 17284 0 6:47AM ttys001 0:01.52 /Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/bin/java -server -XX:+HeapDumpOnOutOfMemoryError -Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 -Djava.security.egd=file:/dev/urandom -Duser.language=en -Duser.region=EN -Xdock:name=JMeter -Xdock:icon="bin/../docs/images/jmeter_square.png" -Dapple.laf.useScreenMenuBar=true -Dapple.eawt.quitStrategy=CLOSE_ALL_WINDOWS -jar bin/ApacheJMeter.jar -Djava.rmi.server.hostname=192.168.31.242 -Dserver_port=31099 -s -j /tmp/jmeter-slave-1.log
501 17292 16939 0 6:47AM ttys002 0:00.01 /bin/sh bin/jmeter -Djava.rmi.server.hostname=192.168.31.242 -Dserver_port=31020 -s -j /tmp/jmeter-slave-2.log
501 17299 17292 0 6:47AM ttys002 0:01.55 /Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/bin/java -server -XX:+HeapDumpOnOutOfMemoryError -Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 -Djava.security.egd=file:/dev/urandom -Duser.language=en -Duser.region=EN -Xdock:name=JMeter -Xdock:icon="bin/../docs/images/jmeter_square.png" -Dapple.laf.useScreenMenuBar=true -Dapple.eawt.quitStrategy=CLOSE_ALL_WINDOWS -jar bin/ApacheJMeter.jar -Djava.rmi.server.hostname=192.168.31.242 -Dserver_port=31020 -s -j /tmp/jmeter-slave-2.log
501 17300 17108 0 6:47AM ttys003 0:00.01 /bin/sh bin/jmeter -Djava.rmi.server.hostname=192.168.31.242 -Dserver_port=31021 -s -j /tmp/jmeter-slave-3.log
501 17307 17300 0 6:47AM ttys003 0:01.54 /Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/bin/java -server -XX:+HeapDumpOnOutOfMemoryError -Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 -Djava.security.egd=file:/dev/urandom -Duser.language=en -Duser.region=EN -Xdock:name=JMeter -Xdock:icon="bin/../docs/images/jmeter_square.png" -Dapple.laf.useScreenMenuBar=true -Dapple.eawt.quitStrategy=CLOSE_ALL_WINDOWS -jar bin/ApacheJMeter.jar -Djava.rmi.server.hostname=192.168.31.242 -Dserver_port=31021 -s -j /tmp/jmeter-slave-3.log
liumiaocn:apache-jmeter-5.1.1 liumiao$
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
Pressure test preparation application (nginx service)
Pressure sensing applications:
http://192.168.31.242:8088/
In use port 8088 starts a Docker application Nginx local machine (in other ways may also be used), example is shown below:
liumiaocn:~ liumiao$ docker images |grep nginx |grep latest
nginx latest e445ab08b2be 2 months ago 126MB
liumiaocn:~ liumiao$ docker run -p 8088:80 -d --name=nginx-test nginx:latest
a80fb1a4fc20627891a6bd7394fd79ae9aefb7dc8cf72c12967bc2673a815308
liumiaocn:~ liumiao$
- 1
- 2
- 3
- 4
- 5
Use the curl command or direct the browser to confirm nginx has been running
liumiaocn:~ liumiao$ curl http://localhost:8088/
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
liumiaocn:~ liumiao$
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
Pressure test content preparation (jmx file)
Pressure measurement Content:
using a thread group 100 * 10 cycles total stress test the http get method of http://192.168.31.242:8088/ 1000 times.
In order to accomplish pressure sensing content, file content related to the following jmx
liumiaocn:apache-jmeter-5.1.1 liumiao$ cat /tmp/data/jmeter-nongui-test.jmx
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.1.1 r1855137">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="测试计划" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="线程组" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="循环控制器" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">10</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">100</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP请求" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain">192.168.31.242</stringProp>
<stringProp name="HTTPSampler.port">8088</stringProp>
<stringProp name="HTTPSampler.protocol">http</stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">/</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>
liumiaocn:apache-jmeter-5.1.1 liumiao$
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
Slave node performs the specified test pressure
Used to specify -R Slave node performs pressure measurement, as shown using the following command:
Run: jmeter -n -t jmx file -R Slave node IP: Port number -l -j result log file
Slave node performing the specified pressure measurement content -2
liumiaocn:apache-jmeter-5.1.1 liumiao$ bin/jmeter -n -t /tmp/data/jmeter-nongui-test.jmx -R 192.168.31.242:31020 -l /tmp/jmeter-result.jtl -j /tmp/jmeter-test.log
Creating summariser <summary>
Created the tree successfully using /tmp/data/jmeter-nongui-test.jmx
Configuring remote engine: 192.168.31.242:31020
Starting remote engines
Starting the test @ Thu Oct 03 07:03:46 CST 2019 (1570057426968)
Remote engines have been started
Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
summary = 1000 in 00:00:01 = 850.3/s Avg: 23 Min: 2 Max: 71 Err: 0 (0.00%)
Tidying up remote @ Thu Oct 03 07:03:49 CST 2019 (1570057429128)
... end of run
liumiaocn:apache-jmeter-5.1.1 liumiao$
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
It can be seen simultaneously perform output start and end at the terminal node Slave-2
liumiaocn:apache-jmeter-5.1.1 liumiao$ bin/jmeter -Djava.rmi.server.hostname=192.168.31.242 -Dserver_port=31020 -s -j /tmp/jmeter-slave-2.log
Created remote object: UnicastServerRef2 [liveRef: [endpoint:[192.168.31.242:61451](local),objID:[4cbbe152:16d8ea7fd55:-7fff, -5053050829591264010]]]
Starting the test on host 192.168.31.242:31020 @ Thu Oct 03 07:03:47 CST 2019 (1570057427648)
Finished the test on host 192.168.31.242:31020 @ Thu Oct 03 07:03:49 CST 2019 (1570057429128)
- 1
- 2
- 3
- 4
Further jtl also confirmed by the results of the file to which the content execution of 1000 (1001 results because a line in the file header)
liumiaocn:apache-jmeter-5.1.1 liumiao$ wc -l /tmp/jmeter-result.jtl
1001 /tmp/jmeter-result.jtl
liumiaocn:apache-jmeter-5.1.1 liumiao$
- 1
- 2
- 3
Slave node performing the specified pressure measurement content -3
liumiaocn:apache-jmeter-5.1.1 liumiao$ bin/jmeter -n -t /tmp/data/jmeter-nongui-test.jmx -R 192.168.31.242:31021 -l /tmp/jmeter-result.jtl -j /tmp/jmeter-test.log
Creating summariser <summary>
Created the tree successfully using /tmp/data/jmeter-nongui-test.jmx
Configuring remote engine: 192.168.31.242:31021
Starting remote engines
Starting the test @ Thu Oct 03 07:05:46 CST 2019 (1570057546255)
Remote engines have been started
Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
summary = 1000 in 00:00:01 = 854.7/s Avg: 25 Min: 2 Max: 86 Err: 0 (0.00%)
Tidying up remote @ Thu Oct 03 07:05:48 CST 2019 (1570057548344)
... end of run
liumiaocn:apache-jmeter-5.1.1 liumiao$
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
It can be seen simultaneously perform output start and end at the terminal node Slave-3
liumiaocn:apache-jmeter-5.1.1 liumiao$ bin/jmeter -Djava.rmi.server.hostname=192.168.31.242 -Dserver_port=31021 -s -j /tmp/jmeter-slave-3.log
Created remote object: UnicastServerRef2 [liveRef: [endpoint:[192.168.31.242:61458](local),objID:[1f33aa8e:16d8ea81815:-7fff, 4753743365701930552]]]
Starting the test on host 192.168.31.242:31021 @ Thu Oct 03 07:05:46 CST 2019 (1570057546881)
Finished the test on host 192.168.31.242:31021 @ Thu Oct 03 07:05:48 CST 2019 (1570057548344)
- 1
- 2
- 3
- 4
Alternatively, it can confirm the execution of 1000 has increased by jtl file.
liumiaocn:apache-jmeter-5.1.1 liumiao$ wc -l /tmp/jmeter-result.jtl
2001 /tmp/jmeter-result.jtl
liumiaocn:apache-jmeter-5.1.1 liumiao$
- 1
- 2
- 3
Generate test reports
2000 times using the results of the appeal file to generate stress test report
liumiaocn:apache-jmeter-5.1.1 liumiao$ bin/jmeter -g /tmp/jmeter-result.jtl -e -o /tmp/jmeter-rpt-dynamicnode -j /tmp/jmeter-rpt.log
liumiaocn:apache-jmeter-5.1.1 liumiao$
- 1
- 2
Summary Report messages are as follows