0

I have a post request that takes a variable in the url path and for every loop the variable must be unique.

As I wanted the post request for n no of times I have placed it in a loop controller, I can't use a csv file or any file upload externally to give different values

The sample post request goes somthing like

https://demo.apple.com/users/${deviceId}

And the body is

{

"type":"device",

"Name":"acb"

}

As it is a post request it has body also, I can't add deviceid under parameters.

So is there any way to create a variable to have unique value for every iteration and pass it to the url path, if yes please help me out.

  • 1
    You can use JMeter's Random function https://stackoverflow.com/questions/45328356/generate-random-number-variables-in-jmeter/45328753#45328753 – Ori Marko Apr 13 '22 at 11:04
  • Will this be unique for every iteration run for suppose I need to run 1 lakh iterations and i have set the random function limit to more than 1 lakh – sleepingpanda Apr 13 '22 at 11:17
  • 1
    for unique values you can use UUID https://stackoverflow.com/questions/62193915/use-placeholder-or-generate-unique-id-using-wiremock-with-jmeter/62194070#62194070 – Ori Marko Apr 13 '22 at 11:25
  • Okay thank you, is ther a way we can pass like ${userid}+random function in url path for every iteration like for example userid is abcd and random function gives 10 then the value becomes abdc10 as a string. – sleepingpanda Apr 13 '22 at 11:35

1 Answers1

0

Loop Controller exposes ${__jm__Loop Controller__idx} pre-defined variable which returns the number of the current iteration. You can combine it with __threadNum() function so the combination of user and iteration would be more or less "unique" (within the bounds of test run)

enter image description here

But if you need to re-run the test most probably the data won't be accepted unless you clean up the database.

Also there is __UUID() function which generates a GUID-like structure which is supposed to be unique

enter image description here

See Apache JMeter Functions - An Introduction article for more information on JMeter Functions concept.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Actually I can't use it in the loop controller in loop count because I'll need to give a different variables in the loop count for needed iterations, i need to pass a variable unique value string only in the url path for every iteration and I can't use uuid function it's too large string for requirement, if there is any other way can you please suggest – sleepingpanda Apr 13 '22 at 11:48