Jmeter - 运行 多个线程使用不同的作者令牌

Jmeter - running multiple threads using different author token

我创建了一个包含三个步骤的线程:

  1. 访问令牌请求:它生成一个令牌以在第三步中使用。此令牌存储在 属性

    ${__setProperty(accessToken,${accessToken})}

  2. Logon Get 请求命中 url

  3. 登录 Post 请求,将一些数据传递给 url 并且我已经使用 Bearer + accessToken(第一个生成的)设置授权 header步骤.

运行单线程运行,完美;但是当我增加线程数时,这 3 个步骤没有按顺序 运行ning,也许我在第一次登录 Post 之前有一些访问令牌,我看到这个正在使用的令牌不是第一步生成的token,是最后生成的。

如果我将剩余时间设置为比总执行时间更长的时间,那么我就无法运行 多个线程并行。

如何将脚本配置为 运行 使用每个 Post 中步骤 1 中生成的相应标记的线程?如何使用不同的属性或变量来存储每个线程的令牌并使用它们?

谢谢。

您的问题是您混合了变量和属性。

总之,根据functions reference

  • 变量是每个线程
  • 属性跨线程共享

所以不要使用setProperty,只需使用${accessToken}

仅当您想要影响所有线程时才使用属性。否则,您可以将变量保存在其他变量中,如 User_Parameters 中,您在其中放置新变量名称,值可以是不同的变量,如 ${accessToken}

filling in the Variable name in the 'Name:' column. To add a new value to the series, click the 'Add User' button and fill in the desired value in the newly added column.

Values can be accessed in any test component in the same thread group, using the function syntax: ${variable}.