How can I configure Jmeter such that it hits two different tokens, one after the other, then after some period of time it hits only the second token?

huangapple go评论55阅读模式
英文:

How can I configure Jmeter such that it hits two different tokens, one after the other, then after some period of time it hits only the second token?

问题

我必须运行一个为期24小时的浸泡测试,使用两个令牌-GET和验证。

在这里,我必须连续24小时使用从GET令牌获取的同一访问令牌来请求验证令牌。

访问令牌每12小时过期一次,所以我的方法是在开始时只请求一次GET令牌,然后在接下来的12小时内重复使用同一令牌来请求验证令牌,然后再在11小时55分钟后再次请求GET令牌,并在接下来的12小时内重复使用这个访问令牌来进行验证。

我尝试在Jmeter中创建4个线程组,其中:

在第一个线程组中,我请求一次GET令牌,然后使用该GET令牌的访问令牌来请求验证令牌,持续11小时55分钟,然后对接下来的2个线程组也进行了相同的操作,但效果不如预期。

请建议是否有其他方法来实现这个目标。

英文:

I have to run a soak test for 24 hours with two tokens- GET and Validate

Here I have to hit Validate token continuously for 24 hours using the same access token which I get from the GET token.

The access token expires every 12 hours, so my approach is to hit the GET token once at the start then use the same token in VALIDATE token for the next 12 hours, then again I want to hit GET token after 11 hours 55 minutes , and use this access token for the next 12 hour hits for Validating it.

I tried creating 4 thread groups in Jmeter, where

In the first thread group I hit the GET token once, and use that GET token's access token to hit the validate token for the next 11 hours 55 minutes, again did the same for the next 2 thread groups, but it didn't work as expected

Please suggest if there are any other approaches to achieve this.

答案1

得分: 1

  1. 第一个线程组,每11小时55分钟获得一个令牌,并通过__setProperty()函数或JSR223后处理器和Groovy脚本将其转换为JMeter属性,例如props.put('some-property-name', vars.get('variable-holding-the-token'))

    通过流控制操作采样器可以创建11小时55秒的“睡眠”。

  2. 第二个线程组,将使用__P()函数获取令牌,如:

     ${__P(some-property-name,)}
    

这样,第一个线程组中的请求将每11小时55分钟重复一次,因此令牌不会过期。

更多信息:在多个线程组中使用JMeter变量

英文:

I think you could go for:

  1. 1st Thread Group which will be getting a token each 11 hours 55 minutes and converting it into a JMeter Property via __setProperty() function or JSR223 PostProcessor and Groovy script like `props.put('some-property-name', vars.get('variable-holding-the-token'))

    The "sleep" for 11 hours and 55 seconds can be created using Flow Control Action sampler

  2. 2nd Thread Group which will be using the token via __P() function like:

    ${__P(some-property-name,)}
    

This way the request in 1st thread group will be repeated each 11 hours and 55 minutes so the token will not expire.

More information: Using JMeter Variables With Multiple Thread Groups

huangapple
  • 本文由 发表于 2023年7月3日 20:56:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76604955.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定