如何在 JMeter 中为每个用户动态迭代请求
How to iterate a request dynamically for each user in JMeter
我需要在 JMeter 中为不同的用户多次迭代请求。每个用户的迭代次数不同。例如:我需要为第一个用户迭代请求 5 次,为第二个用户迭代 3 次,为第三个用户迭代一次,依此类推。我们如何做到这一点以及如何将输入馈送到相同的位置。是否可以说在 csv 数据集配置中为第一个用户读取前 5 行,为第二个用户读取接下来的 3 行。
这是您的问题的解决方案。 JMeter 中可能还有许多其他解决方案可用。
您可以在(用户参数)enter link description here 预处理器中定义与用户(线程)关联的循环计数。
This panel allows you to specify a series of values for any User Variable. For each thread, the variable will be assigned one of the values from the series in sequence. If there are more threads than values, the values get re-used.
然后请求可以放在Loop Controller
内
用户参数组件应放置在 JSR223 采样器中,以确保在到达循环控制器之前启动值。还有 JSR223 Sampler shall be placed within a Once Only Controller 以确保采样器只执行一次。
在 JSR223 采样器中添加 SampleResult.setIgnore()
以避免采样器被记录到测试结果中。
测试计划结构
CSV Data Set Config more suitable for large numbers of parameters
您可以在 CSV file or via JMeter Properties
中为每个用户定义所需的循环次数
您可以使用 __groovy() function 从 CSV 文件中读取所需的行,例如:
${__groovy(new File('test.csv').readLines().get(0),)}
- 阅读第一行
${__groovy(new File('test.csv').readLines().get(1),)}
- 阅读第二行
- 等等
我需要在 JMeter 中为不同的用户多次迭代请求。每个用户的迭代次数不同。例如:我需要为第一个用户迭代请求 5 次,为第二个用户迭代 3 次,为第三个用户迭代一次,依此类推。我们如何做到这一点以及如何将输入馈送到相同的位置。是否可以说在 csv 数据集配置中为第一个用户读取前 5 行,为第二个用户读取接下来的 3 行。
这是您的问题的解决方案。 JMeter 中可能还有许多其他解决方案可用。
您可以在(用户参数)enter link description here 预处理器中定义与用户(线程)关联的循环计数。
This panel allows you to specify a series of values for any User Variable. For each thread, the variable will be assigned one of the values from the series in sequence. If there are more threads than values, the values get re-used.
然后请求可以放在Loop Controller
内用户参数组件应放置在 JSR223 采样器中,以确保在到达循环控制器之前启动值。还有 JSR223 Sampler shall be placed within a Once Only Controller 以确保采样器只执行一次。
在 JSR223 采样器中添加 SampleResult.setIgnore()
以避免采样器被记录到测试结果中。
测试计划结构
CSV Data Set Config more suitable for large numbers of parameters
您可以在 CSV file or via JMeter Properties
中为每个用户定义所需的循环次数您可以使用 __groovy() function 从 CSV 文件中读取所需的行,例如:
${__groovy(new File('test.csv').readLines().get(0),)}
- 阅读第一行${__groovy(new File('test.csv').readLines().get(1),)}
- 阅读第二行- 等等