jmeter 循环使用csv数据_如何在JMeter中的while循环中使用CSV数据集配置?

这篇博客讨论了如何在JMeter中实现对一组URL在不同服务器上进行测试的问题。作者指出,当前的While Controller逻辑只遍历内部循环,没有处理外部循环。解决方案包括使用Thread Group配合ForEach Controller,或者生成包含URL和服务器变量的CSV文件,然后用单个Thread Group读取。这两种方法可以确保URL在所有服务器上正确迭代执行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I need to test the same set of urls against 5 to 10 servers. URLs are defined in the CSV file. Server names are defined in User Defined Variables config.

I'm using While Controller based on the number of servers to iterate and execute the url requests. My current logic is defined as below:

Thread group

While controller

Counter (defines number of servers)

While controller (inner check "${URL}" != "")

CSV Data Set Config (stop EOF is true)

HTTP Sampler (with url data)

As per the logic my script will run and read the CSV file once and stop. It's not reading the outer loop. Only inner loop and stopped.

解决方案By default, the file is only opened once, and each thread will use a

different line from the file. However the order in which lines are

passed to threads depends on the order in which they execute, which

may vary between iterations. Lines are read at the start of each test

iteration. The file name and mode are resolved in the first iteration.

Thread groups cannot be nested. So you have to use the threadgroup to iterate in CSV and foreach to iterate in something else. The second option is to generate a CSV with the URL+Server variations, and using simply a single threadgroup to read the CSV.

First option is here.

Iterating URLs outer loop, iterating servers inner loop. You just need a threadgroup and a foreach inside it. See the pictures:

Sample results:

And of course 3 more results...

You can also play with CSVRead function if you have time :)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值