Jmeter 在不同主机上设置特定参数

Jmeter setup specific parameters on different host

我的测试计划使用一个参数作为startIndex

本地情况: "thread pool 1" -> "Java Request" -> "Send Parameters With the Request" -> 添加一个名为 startIndex 的参数, 并创建一个配置元素 - "User Defined variables",并提供一个参数 startIndex.

但是如何给每个服务器不同的startIndex参数, 例如:

serverA:"startIndex"=100, serverB:"startIndex"=200.

最好不要创建两个具有相同名称的变量。如果这种情况不可避免,则不要使用“用户定义的变量”。相反,您可以在特定采样器下创建第二个变量,方法是使用 beanshell (vars.put) 创建第二个变量。未经测试的技术,但您可以尝试。

  1. 在每台 JMeter 从机上,在 JMeter 安装的 /bin 文件夹下找到 user.properties 文件
  2. 将以下行添加到该文件中:

    • 在服务器 1 上:startIndex=100
    • 在服务器 2 上:startIndex=200
  3. 通过 __P() functionstartIndex 属性 值引用为 ${__P(startIndex,)} 需要的地方

确保在 user.properties 文件修改后重新启动 JMeter。

有关 JMeter 属性和使用它们的方法的扩展信息,请参阅 Apache JMeter Properties Customization Guide