http请求的每个线程的jmeter唯一ID
jmeter unique id per thread for http request
我的 jmeter 测试发出了一个包含唯一 ID 的 http 请求。
http://myserver.com/{uniqueId}/
我想为每个线程设置基数(比如 35000)和增量,例如我的 ID 是 35001、35002、35003 ...
http://myserver.com/{base + count}
我看到了 __threadnum 和 __counter 的函数,但我会怎样:
- 将它设置在一个变量中,以便我可以在我的 url
中替换它
- 将此计数添加到我的基本值中
要为每个线程设置一个变量,您可以使用 User Defined Variables。
总而言之,您可以使用函数:
或使用 JSR223 PRE Processor or JSR223 POST Processor + Groovy 并在 Groovy 中完成。
我会直接使用 Beanshell 预处理器。
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));
现在您的 HTTP 请求应该替换为下面给出的值。
http://myserver.com/${uniqueId}/
我的 jmeter 测试发出了一个包含唯一 ID 的 http 请求。
http://myserver.com/{uniqueId}/
我想为每个线程设置基数(比如 35000)和增量,例如我的 ID 是 35001、35002、35003 ...
http://myserver.com/{base + count}
我看到了 __threadnum 和 __counter 的函数,但我会怎样:
- 将它设置在一个变量中,以便我可以在我的 url 中替换它
- 将此计数添加到我的基本值中
要为每个线程设置一个变量,您可以使用 User Defined Variables。
总而言之,您可以使用函数:
或使用 JSR223 PRE Processor or JSR223 POST Processor + Groovy 并在 Groovy 中完成。
我会直接使用 Beanshell 预处理器。
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));
现在您的 HTTP 请求应该替换为下面给出的值。
http://myserver.com/${uniqueId}/