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

查看:24
本文介绍了http请求的每个线程的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}/

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

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