每25分钟一次如何在jmeter中运行线程

时间:2018-12-05 04:13:13

标签: testing timer jmeter jsr223

我正在使用HTTP GET请求访问其他API,该请求的标头中包含身份验证令牌。因此,在线程组中,我要访问身份验证服务器以获取身份验证令牌。在随后的线程组中,我将请求HTTP GET请求

TEST plan (property auth)
  ThreadGroup(authentication)
    http GET to get authentication token
    extracting response and putting in auth
  
  Thread group(GET)
    http GET
    
  Thread group(GET)
    http GET
    
  and soo on
  

此处身份验证令牌每25分钟将过期,因此我需要一种机制来每25分钟生成一次身份验证令牌,而不会中断正在进行的HTTP GET调用的工作

3 个答案:

答案 0 :(得分:1)

您可以浏览以下屏幕截图以获取更多详细信息。如果您仍然需要更多帮助,请告诉我。

使用Beanshell断言将变量存储到属性变量中

Use Beanshell Assertion to store variable into Property variable

以这种方式使用属性变量来获取值

Use the property variable in this way to fetch the value

Use the below method to set the delay for Auth Token creation

答案 1 :(得分:0)

您可以按以下方式进行配置。

ThreadGroup(authentication)
    http GET to get authentication token
       Extract the authentication token and save in a jmeter property variable 

将令牌保存在属性变量中的好处是,您也可以访问其他线程组中的属性变量。以上述方式配置后,您可以每23分钟执行一次ThreadGroup(authentication),以便它可以在到期之前更新Jmeter属性变量(身份验证令牌)。

要设置属性变量:${__setProperty(variable, ${variable})}

要访问属性变量:${__property(variable)}

您可以在最后尝试一下,让我知道它的进展。

答案 2 :(得分:0)

在您的http GET to get authentication token请求之后添加Test Action个采样器(由于JMeter 5.0这个元素被称为流动作控制),并将其配置为{strong>暂停 1}}毫秒(25分钟*分钟60秒*​​秒1000毫秒)

enter image description here