特定事务的 Jmeter 检查点

Jmeter checkpoint for a specific transaction

这段代码有问题吗? 运行 测试时,我试图在 JMeter 中识别失败的用户。该脚本在我的本地和有限数量的用户中绝对运行良好。使用分布式测试时如何在日志中打印失败的用户?我是 运行 每台机器 100 个用户(5 个奴隶和主人)

我的第一笔交易有 10 个请求,在请求 post 处理器中,我使用以下代码在日志中打印。但是它将在分布式负载测试中显示的确切位置,我最终使用了 Apdex 报告,但它甚至没有显示在那里。

if(prev.getResponseCode()=='500') { log.info('Failed User: ' + '${__threadNum}-${用户名}-${MachineIp}-${__machineName}'); }

它将出现在 jmeter.log 文件(或 jmeter-server.log 文件中,具体取决于您如何启动从站的方式)在失败的机器上

如果你想在HTML Reporting Dashboard - you need to use prev.setResponseMessage()函数中看到这个

也不要内联 JMeter Functions or Variables into Groovy scripts as it conflicts with GString templates 并且只有第一次出现会被缓存并用于后续迭代

更多信息:Apache Groovy - Why and How You Should Use It

建议的代码更改:

import org.apache.jmeter.util.JMeterUtils

if (prev.getResponseCode() == '500') {
    prev.setResponseMessage('Failed User: ' + ctx.getThreadNum() + '-' + vars.get('Username') + '-' + JMeterUtils.getLocalHostIP() + '-' + JMeterUtils.getLocalHostName());
}