每个请求的每个线程的jmeter唯一ID [英] jmeter unique id per thread for http request

查看:827
本文介绍了每个请求的每个线程的jmeter唯一ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的jmeter测试发出一个包含唯一ID的http请求.

My jmeter tests make a http request which contains a unique id.

http://myserver.com/{uniqueId}/

我想设置基数(例如35000)并为每个线程递增,例如,我的id是35001、35002、35003 ...

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}

我看到__threadnum和__counter的函数,但是我将如何:

I see functions for __threadnum and __counter but how would I:

  1. 将其设置为变量,以便我可以将其替换为我的网址
  2. 将此计数添加到我的基本值中

推荐答案

我将只使用Beanshell预处理程序.

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));

现在,如下所示的HTTP请求应替换为该值.

Now your HTTP requests as given below should have the value substituted.

http://myserver.com/ $ {uniqueId}/

http://myserver.com/${uniqueId}/

这篇关于每个请求的每个线程的jmeter唯一ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆