Random Jmeter variable in multiple threads

I have a Jmeter thread group that uses the uuid variable several times.

uuid determined using 12345678-1234-4444-a123-${__Random(111111111111,999999999999)}

In other words, it starts with the fixed series 12345678-1234-4444-a123- and then randomizes the last twelve characters.

I want to start several threads at the same time, this gives the following problem.

When I define uuid as a user variable within a thread group, it randomizes once and then uses that value for all my threads. If I install it globally, the same thing happens.

I will run thousands of threads at the same time when I finish, so I can not perform manual decisions or read / write to disk.

Does anyone have any experience with this? I have been looking through the documentation and Google for quite some time, but cannot find a solution.

In short: I need to randomize a variable, use this variable in the entire thread group and run this thread group in several simultaneous threads. The variable must have different randomized values ​​in each separate thread.

+8
source share
2 answers

Suppose you can just use a Random variable :

 Variable Name: uuid Output Format: 12345678-1234-4444-a123-000000000000 Minimum Value: 111111111111 Maximum Value: 999999999999 Per Thread (User): True 

Generated value

  • can be obtained as ${uuid} ;
  • unique to each stream;
  • stored between different samplers, causes the stream of each stream (not regenerated during each link);
  • generated during each iteration of a group of threads.
 Test Plan Thread Group Random Variable ... Sampler 1 Sampler 2 ... 

eg.

 iteration: 1 thread: 1 sampler 1: VALUE_1-1 sampler 2: VALUE_1-1 ... thread: 2 sampler 1: VALUE_2-1 sampler 2: VALUE_2-1 ... ... iteration: 2 thread: 1 sampler 1: VALUE_1-2 sampler 2: VALUE_1-2 ... thread: 2 sampler 1: VALUE_2-2 sampler 2: VALUE_2-2 ... ... 

An example script implemented for the above scheme: rnd-var.jmx


According to the description of the field Random Seed Random variable :

The default value is the current time in milliseconds. If you use the same seed, the value in Per Thread is set to true, you will get the same value for earch Thread according to a random class.

If two instances of Random are created with the same seed, and the same sequence of method calls is performed for each of them, they will generate and return identical sequences of numbers.

Keep this in mind when implementing high concurrency scenarios (as noted in the comments below). To overcome this problem, you can use a randomized seed, for example. ${__Random(MIN,MAX)} as the value of the Seed for Random function field.

+20
source

Just lay

 12345678-1234-4444-a123-${__Random(111111111111,999999999999)} 

Built-in where you need it.

If you put this in your UDV component, the value is assigned only once before the threads are even started. The behavior is in accordance with the Jmeter documentation. Please read this carefully.

0
source

Source: https://habr.com/ru/post/945597/


All Articles