登录一次并在 JMeter 中重复使用访问令牌

Login Once and Re-use access Token in JMeter

我有一个要求,我们需要为给定的测试用户登录一次,并为剩余的 API 调用重新使用登录脚本生成的访问令牌,持续时间为 1 小时。 我认为的一种方法是登录并在 csv 文件中写入令牌,然后从 CSV 文件中读取这些令牌以执行剩余的 API,但是 这种方法我们需要在代理中的 CSV 文件中写入令牌。 因为,我们将在负载测试台上进行 运行 测试。我们无权写入代理。 有什么方法可以让我们登录一次,在某个变量中生成令牌并重新使用令牌。

如果有人能对此提供帮助,我们将不胜感激。

  1. 每个用户登录一次-将获取令牌的逻辑放在Once Only Controller and it will be executed during 1st iteration of the Thread Group
  2. 1用户登录一次,所有用户使用token - 获取token的逻辑放在setUp Thread Group, save the token into a JMeter Property using __setProperty() function and read it in the main Thread Group using __P() function