Jmeter unique id for stream for HTTP request
My jmeter tests are making an HTTP request that contains a unique id.
http://myserver.com/{uniqueId}/
I want to set a base number (say 35000) and an increment for each thread, for example my IDs will be 35001, 35002, 35003 ...
http://myserver.com/{base + count}
I see functions for __threadnum and __counter, but how would I:
- set it in a variable so I can substitute it in my url
- add this count to my baseline
+3
source to share
2 answers
I would just go with a Beanshell pre-processor.
int threadNo = ctx.getThreadNum()+1; //to get the thread number in beanshell
int base = 35000;
int uniqueId = threadNo + base;
vars.put("uniqueId", Integer.toString(uniqueId));
Your HTTP requests should now have a replaced value as below.
http://myserver.com/ $ {uniqueId} /
+9
source to share
To set a variable for a thread, you can use Custom Variables .
In sum, you can use functions:
Or use JSR223 PRE Processor or JSR223 POST Processor + Groovy and do it in Groovy.
+2
source to share