My jmeter tests make a http request which contains a unique id.
http://myserver.com/{uniqueId}/
I want to set the base number (say 35000) and increment for each thread, for example my ids would be 35001, 35002, 35003 ...
http://myserver.com/{base + count}
I see functions for __threadnum and __counter but how would I:
To get the number of the current thread (out of 5 in your case) use ctx. getThreadNum() which will get the number of the thread. To get the total number of threads being used by jMeter you can use ctx. getThreadGroup().
Functions can be used for many different operations, including: inputting information from a file, performing math calculations and value generation, processing strings, evaluating JMeter variables, working with JMeter properties and executing scripts like Javascript or BeanShell script.
It is used to decode a string.
I would simply go with 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));
Now your HTTP requests as given below should have the value substituted.
http://myserver.com/${uniqueId}/
To set a variable per thread you can use User Defined Variables.
To sum, you can use functions:
Or use a JSR223 PRE Processor or JSR223 POST Processor + Groovy and do it in Groovy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With