首页 > 解决方案 > JMeter 在 CLI 中给出错误百分比,但在 GUI 中没有

问题描述

我有一个在 docker 容器中运行的小型微服务,我试图获得使用 JMeter CLI 的延迟。我使用 JMeter GUI 进行了测试,并首先从中运行了测试。然后错误百分比为 0。但是当我使用 CLI 运行相同的测试时,我得到了错误百分比的值。我收到以下警告:

Creating summariser <summary>
Created the tree successfully using /Users/sulekahelmini/Documents/fyp/jmeter_scripts/factorial.jmx
Starting standalone test @ Tue Feb 18 02:20:35 IST 2020 (1581972635848)
Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
summary =     50 in 00:00:02 =   25.0/s Avg:    50 Min:     4 Max:   323 Err:     0 (0.00%)
Tidying up ...    @ Tue Feb 18 02:20:38 IST 2020 (1581972638095)
... end of run
2020-02-18 02:20:39,012 WARN o.a.j.u.JMeterUtils: Exception 'null' occurred when fetching String property:'sampleresult.default.encoding', defaulting to: ISO-8859-1
2020-02-18 02:20:39,022 WARN o.a.j.u.JMeterUtils: Exception 'null' occurred when fetching String property:'jmeterPlugin.prefixPlugins'
2020-02-18 02:20:39,022 INFO k.a.j.PluginsCMDWorker: Using JMeterPluginsCMD v. N/A
2020-02-18 02:20:39,025 INFO o.a.j.u.JMeterUtils: Setting Locale to en_LK
2020-02-18 02:20:39,030 INFO k.a.j.JMeterPluginsUtils: Loading user properties from: /Users/sulekahelmini/Documents/fyp/apache-jmeter-5.2.1/bin/user.properties
2020-02-18 02:20:39,030 INFO k.a.j.JMeterPluginsUtils: Loading system properties from: /Users/sulekahelmini/Documents/fyp/apache-jmeter-5.2.1/bin/system.properties
2020-02-18 02:20:40,083 WARN o.a.j.g.ObjectTableModel: Header count=13 but classes count=11
2020-02-18 02:20:40,083 WARN o.a.j.g.ObjectTableModel: Header count=13 but writeFunctor count=11
2020-02-18 02:20:40,210 INFO o.a.j.s.SaveService: Testplan (JMX) version: 2.2. Testlog (JTL) version: 2.2
2020-02-18 02:20:40,215 INFO o.a.j.s.SaveService: Using SaveService properties file encoding UTF-8
2020-02-18 02:20:40,217 INFO o.a.j.s.SaveService: Using SaveService properties version 5.0
2020-02-18 02:20:40,224 INFO o.a.j.s.SampleResult: Note: Sample TimeStamps are START times
2020-02-18 02:20:40,224 INFO o.a.j.s.SampleResult: sampleresult.default.encoding is set to ISO-8859-1
2020-02-18 02:20:40,225 INFO o.a.j.s.SampleResult: sampleresult.useNanoTime=true
2020-02-18 02:20:40,225 INFO o.a.j.s.SampleResult: sampleresult.nanoThreadSleep=5000
2020-02-18 02:20:40,226 INFO o.a.j.s.SampleEvent: List of sample_variables: []
2020-02-18 02:20:40,450 INFO k.a.j.v.AggregateReportGui: Saving CSV to /Users/sulekahelmini/Documents/fyp/fyp_work/MLscripts/agg_test.csv

这是我用来运行测试并将结果转换为 csv 的代码:

#run test
  cd /Users/sulekahelmini/Documents/fyp/apache-jmeter-5.2.1/bin && sh jmeter -n -t /Users/sulekahelmini/Documents/fyp/jmeter_scripts/factorial.jmx -l /Users/sulekahelmini/Documents/fyp/fyp_work/MLscripts/jmeter_results.jtl
  #convert result to csv
  cd /Users/sulekahelmini/Documents/fyp/apache-jmeter-5.2.1/bin && ./JMeterPluginsCMD.sh --generate-csv /Users/sulekahelmini/Documents/fyp/fyp_work/MLscripts/agg_test.csv --input-jtl /Users/sulekahelmini/Documents/fyp/fyp_work/MLscripts/jmeter_results.jtl --plugin-type AggregateReport

下面显示的是生成的汇总报告(使用 jtl 文件)。请注意,那里有一个错误百分比。

在此处输入图像描述

另外,请注意我的 JMeter 不在容器内。我在这里做错了什么?在 GUI 中运行时如何不显示错误百分比?

标签: javajmetercommand-line-interfacemicroserviceslatency

解决方案


我看不到你从哪里得到a value for error percentage的,因为它似乎为零:

摘要 = 00:00:02 中的 50 = 25.0/s 平均:50 最小值:4 最大值:323错误:0 (0.00%)

如果您在生成的文件中看到错误,/Users/sulekahelmini/Documents/fyp/fyp_work/MLscripts/agg_test.csv则可能是该文件以前存在并且包含失败的“旧”结果。

此外,我认为您正在使用聚合报告侦听器将某些内容写入该文件,然后使用 JMeter 插件命令行工具将最后的结果附加到同一文件中。

为了获得“干净”和有效的结果:

  1. 删除/Users/sulekahelmini/Documents/fyp/fyp_work/MLscripts/agg_test.csv文件
  2. 删除/Users/sulekahelmini/Documents/fyp/fyp_work/MLscripts/jmeter_results.jtl文件
  3. 从您的测试计划中删除聚合报告侦听器(和所有其他侦听器),因为侦听器不会增加任何价值,只会消耗资源
  4. 在终端中重复您的 2 个命令
  5. 您应该看到agg_test.csv没有任何错误的文件

推荐阅读