我正在编写一个负载测试,在后请求中,我需要为每个请求发送一个在有效负载中具有唯一id的值。
我们正在使用ruby jmeter进行性能测试。我看到很多文件建议使用jmeter,但没有提到如何在ruby中实现同样的jmeter。
只需在需要发送唯一ID的地方使用JMeter的UUID((函数,ruby-jmeter
只不过是一个包装器,因此它完全支持JMeter函数和变量的正常语法
下面是Ruby中的一个例子:
$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功能-简介