java.lang.IllegalArgumentException: 报告生成需要 csv 输出格式

java.lang.IllegalArgumentException: Report generation requires csv output format

当我尝试 运行 在非 GUI 模式下使用输出文件格式 XML 进行 JMeter 负载测试时,出现以下错误。我正在使用 docker 容器来安装 JMeter。 我需要请求和响应数据成为 result-jtl 文件的一部分

错误:

2020-11-04 08:44:35,820 ERROR o.a.j.JMeter: Error in NonGUIDriver
java.lang.IllegalArgumentException: Report generation requires csv output format, check 'jmeter.save.saveservice.output_format' property
        at org.apache.jmeter.report.dashboard.ReportGenerator.<init>(ReportGenerator.java:123) ~[ApacheJMeter_core.jar:5.3]
        at org.apache.jmeter.JMeter.runNonGui(JMeter.java:1062) [ApacheJMeter_core.jar:5.3]
        at org.apache.jmeter.JMeter.startNonGui(JMeter.java:994) [ApacheJMeter_core.jar:5.3]
        at org.apache.jmeter.JMeter.start(JMeter.java:566) [ApacheJMeter_core.jar:5.3]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_252]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_252]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_252]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_252]
        at org.apache.jmeter.NewDriver.main(NewDriver.java:252) [ApacheJMeter.jar:5.3]
2020-11-04 08:44:35,825 ERROR o.a.j.JMeter: An error occurred:
org.apache.jmeter.report.config.ConfigurationException: Error in NonGUIDriver Report generation requires csv output format, check 'jmeter.save.saveservice.output_format' property
        at org.apache.jmeter.JMeter.runNonGui(JMeter.java:1104) ~[ApacheJMeter_core.jar:5.3]
        at org.apache.jmeter.JMeter.startNonGui(JMeter.java:994) ~[ApacheJMeter_core.jar:5.3]
        at org.apache.jmeter.JMeter.start(JMeter.java:566) [ApacheJMeter_core.jar:5.3]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_252]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_252]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_252]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_252]
        at org.apache.jmeter.NewDriver.main(NewDriver.java:252) [ApacheJMeter.jar:5.3]
Caused by: java.lang.IllegalArgumentException: Report generation requires csv output format, check 'jmeter.save.saveservice.output_format' property
        at org.apache.jmeter.report.dashboard.ReportGenerator.<init>(ReportGenerator.java:123) ~[ApacheJMeter_core.jar:5.3]
        at org.apache.jmeter.JMeter.runNonGui(JMeter.java:1062) ~[ApacheJMeter_core.jar:5.3]
        ... 7 more

Jmeter 参数:

-Dlog_level.jmeter=DEBUG -Jjmeter.save.saveservice.response_data=true -Jjmeter.save.saveservice.response_data.on_error=true -Jjmeter.save.saveservice.output_format=xml -Jjmeter.save.saveservice.samplerData=true -Jjmeterengine.force.system.exit=true -n -t test/trivial/test-plan.jmx -l test/trivial/test-plan.jtl -j test/trivial/jmeter.log -e -o test/trivial/report

要生成仪表板报告 (-e -o),您需要将 CSV 结果作为异常状态

Report generation requires csv output format

所以要么更改为 CSV,要么稍后使用 jtl 文件生成仪表板报告

generate the HTML report using menu item Tools → Generate HTML report

-Jjmeter.save.saveservice.output_format=xml

JMeter 5.3 HTML Reporting Dashboard can be generated only out of .jtl files in CSV format as per documentation 开始,您必须删除此 属性:

The dashboard generator is a modular extension of JMeter. Its default behavior is to read and process samples from CSV files to generate HTML files containing graph views. It can generate the report at end of a load test or on demand.

如果您需要额外存储 request/response 数据,您可以使用 Simple Data Writer or Flexible File Writer listener

我确实观察到类似的异常。请按步骤找到解决方案:

  1. 打开 user.properties 文件。你可能拥有价值 jmeter.save.saveservice.output_format=xml
  2. 改成 jmeter.save.saveservice.output_format=csv

您可以通过以下步骤生成 csv 文件和输出文件夹:

1.Open 航站楼

2.Navigate到Jmeter的bin文件夹

sh jmeter.sh -n -t your_JMX_File.jmx -l your_output_csv_file.csv -e -o yourTargetedOutputFolder