无头JMeter - 如何在输出文件中打印响应数据

Ish*_*ray 3 response headless jmeter load-testing

我在非gui模式下使用jmeter脚本运行负载测试.

我使用以下命令以非gui模式运行JMeter,结果存储在Test.jtl文件中

sh jmeter.sh -n -t ThreadGroup.jmx -l Test.jtl
Run Code Online (Sandbox Code Playgroud)

写入Test.jtl的样本数据如下所示,不会打印响应数据.有没有办法打印响应数据,也可以通过改变jmeter脚本或以上命令?

任何帮助,将不胜感激.

1453272193899,231,HTTP Request-staging-qqq-customer1,200,OK,Thread Group two 1-6,text,true,466,231
1453272193927,227,HTTP Request-staging-TT2-customer1,503,Service Unavailable,Thread Group two 1-1,text,false,751,227
1453272193963,222,HTTP Request-staging-TT2-customer1,503,Service Unavailable,Thread Group two 1-2,text,false,604,222
1453272194026,238,HTTP Request-staging-TT1-customer1,200,OK,Thread Group two 1-3,text,true,448,238
1453272194131,233,HTTP Request-staging-qqq-customer2,200,OK,Thread Group two 1-6,text,true,466,233
Run Code Online (Sandbox Code Playgroud)

谢谢

Dmi*_*i T 7

默认情况下,JMeter不会将响应数据存储为:

  1. 由于磁盘IO较高,它会增加执行开销
  2. .jtl文件的大小大大增加
  3. 无法以默认格式(CSV)存储响应数据,因为响应数据肯定至少有一个分隔符

您仍然可以将JMeter配置为存储响应数据,但请记住上述约束.为此,请传递以下额外的命令行参数:

sh jmeter.sh -Jjmeter.save.saveservice.output_format=xml -Jjmeter.save.saveservice.response_data=true -n -t ThreadGroup.jmx -l Test.jtl
Run Code Online (Sandbox Code Playgroud)

另一个选择是将下两行添加到user.properties文件(位于JMeter安装的/ bin文件夹中)

jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.response_data=true
Run Code Online (Sandbox Code Playgroud)

有关JMeter属性及其使用方法的更多信息,请参阅Apache JMeter属性自定义指南

  • 如果您需要两者,则无法从 XML 格式的 .jtl 文件生成仪表板 - 只需添加一个 [Listener](https://jmeter.apache.org/usermanual/listeners.html),例如 [Simple Data Writer](https ://jmeter.apache.org/usermanual/component_reference.html#Simple_Data_Writer),其默认配置适合生成仪表板。或者,可以将简单数据写入器配置为以 XML 格式存储请求/响应数据。更多信息:[如何在JMeter中保存响应数据](https://www.blazemeter.com/blog/how-to-save-response-data-in-jmeter) (2认同)