Gowthaman Ravindran
Gowthaman Ravindran

Reputation: 65

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

I am writing a load test where in a post request i need to send a value that has unique id in the payload for each request.

We are using ruby-jmeter for performance testing. I see a lot of documents suggesting for jmeter but no mention of how to achieve the same in ruby-jmeter.

Upvotes: 0

Views: 183

Answers (1)

Dmitri T
Dmitri T

Reputation: 168072

Just use JMeter's 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

Here is an example in 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)

More information on JMeter Functions concept: Apache JMeter Functions - An Introduction

Upvotes: 0

Related Questions