【发布时间】:2018-11-01 22:12:58
【问题描述】:
在 GUI 模式下运行 JMeter 时,有时请求卡住或需要很长时间(一分钟或更长时间)才能获得响应
有没有办法在收到响应之前查看请求?
很明显Listeners是在Sampler完成后因为Scoping规则而执行的,但是还有其他方法吗?
【问题讨论】:
标签: jmeter
在 GUI 模式下运行 JMeter 时,有时请求卡住或需要很长时间(一分钟或更长时间)才能获得响应
有没有办法在收到响应之前查看请求?
很明显Listeners是在Sampler完成后因为Scoping规则而执行的,但是还有其他方法吗?
【问题讨论】:
标签: jmeter
稍微复杂一点的选项是使用JSR223 PreProcessor 和Groovy 将请求详细信息打印到jmeter.log 文件,这将查询sampler 实例,这是HTTPSamplerProxy 类的简写喜欢:
log.info('URL: ' + (sampler.getUrl() as String) + sampler.getQueryString())
log.info('Parameters: ')
sampler.getArguments().each {arg ->
log.info(arg.getObjectValue() as String)
}
if (sampler.getCookieManager() != null) {
log.info('Cookies: ')
sampler.getCookieManager().getCookies().each { cookie ->
log.info(cookie.getObjectValue() as String)
}
}
if (sampler.getHeaderManager() != null) {
log.info('Headers:')
sampler.getHeaderManager().getHeaders().each {header ->
log.info(header.getObjectValue() as String)
}
}
//etc
演示:
【讨论】:
按照 Apache JMeter 大师的书,填写超时可以防止此类问题:
填写 HTTP Request 的 Timeouts (milliseconds) 选项可以让你不用等待 无限期的 SUT 响应。
这将提供以下好处:
• 允许 JMeter 在测试结束时停止,而无需无限期等待 挂起的请求。默认情况下,HTTP 请求中的超时时间是无限的
【讨论】: