有没有办法使用 ruby-jmeter 为每个线程 运行 发送唯一值

Is there a way to send unique value for each thread run using ruby-jmeter

我正在编写负载测试,在 post 请求中,我需要为每个请求发送一个在有效负载中具有唯一 ID 的值。

我们正在使用 ruby-jmeter 进行性能测试。 我看到很多建议使用 jmeter 的文档,但没有提到如何在 ruby-jmeter.

中实现相同的目的

只需使用 JMeter 的 UUID() function in the place where you need to send the unique ID, ruby-jmeter is nothing more than a wrapper hence it fully supports normal syntax for 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