我正在编写一个负载测试,在post请求中,我需要为每个请求发送一个在有效负载中具有唯一id的值。
我们使用ruby-jmeter进行性能测试。我看到很多文档建议使用jmeter,但没有提到如何在ruby-jmeter中实现同样的功能。
发布于 2021-03-24 19:31:44
只需在需要发送唯一ID的地方使用JMeter的UUID() function,ruby-jmeter只不过是一个包装器,因此它完全支持JMeter Functions and Variables的常规语法
下面是一个用Ruby语言编写的example:
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'ruby-jmeter'
test do
threads count: 1, loops: 5, scheduler: false do
# Helper method to generate a single UUID per iteration
uuid_per_iteration
dummy_sampler name: '${__threadNum} - ${UUID}'
dummy_sampler name: '${__threadNum} - ${UUID}'
dummy_sampler name: '${__threadNum} - ${UUID}'
view_results
end
end.run(path: '/usr/local/share/jmeter-3.1/bin', gui: true)有关JMeter函数概念的更多信息:Apache JMeter Functions - An Introduction
https://stackoverflow.com/questions/66779498
复制相似问题