JMeter:CSV数据集配置“在每次测试迭代开始时读取行". -应该如何运作? [英] JMeter: CSV Data Set Config "Lines are read at the start of each test iteration." - how exactly should it work?

查看:134
本文介绍了JMeter:CSV数据集配置“在每次测试迭代开始时读取行". -应该如何运作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我关注 CSV数据集配置和<通过作用域规则对于 CSV数据集配置,它说每次测试迭代的开始.".起初我以为是关于线程的,然后阅读了使用jmeter测试多个网站,其中将配置放在loop controller内,并在每次循环迭代中读取行.我已经用5.1.1进行了测试,并且可以正常工作.但是,如果我将config放在测试计划的根部,则在每次thread迭代中将仅读取新行.我可以仅基于没有尝试和错误的文档就可以期待这种行为吗?我看不到它是如何从csv config element上的scoping + exec order + docs流向的.我想念什么吗?

For CSV Data Set Config it is said "Lines are read at the start of each test iteration.". At first I thought that talks about threads, then I've read Use jmeter to test multiple Websites where config is put inside loop controller and lines are read each loop iteration. I've tested with now 5.1.1 and it works. But if I put config at root of test plan, then in will read new line only each thread iteration. Can I expect such behaviour based on docs only w/out try-and-error? I cannot see how it flows from scoping+exec order+docs on csv config element. Am I missing something?

我会欣赏一些想法,为什么这样的事实行为很方便,以及为什么以这种方式实现功能.

I would appreciate some ideas why such factual behaviour is convenient and why functionality was implemented this way.

P.S.如何在测试开始时将一行cvs读取到vars,然后停止运行该配置以节省CPU时间?在2.x版本中,有 VariablesFromCSV 配置...

P.S. how can I read one line cvs to vars at start of test and then stop running that config to save CPU time? In 2.x version there was VariablesFromCSV config for that...

推荐答案

  1. 线程组具有隐式的循环控制器:

只要

the next line from CSV will be read as soon as LoopIterationListener.iterationStart() event occurs, no matter of origin

使用CSV数据集配置是安全的,因为它不会将整个文件保留在内存中,它仅在发生上述iterationStart()事件时才读取下一行.但是,它会保持打开的文件句柄.如果您确实有很多RAM且文件处理量不足,则可以在测试开始时使用

It is safe to use CSV Data Set Config as it doesn't keep the whole file in the memory, it reads the next line only when the aforementioned iterationStart() event occurs. However it keeps an open file handle. If you do have really a lot of RAM and not enough file handles you can read the file into memory at the beginning of the test using i.e. setUp Thread Group and JSR223 Sampler with the following code

SampleResult.setIgnore()

new File('/path/to/csv/file').readLines().eachWithIndex { line, index ->
    props.put('line_' + (index + 1), line)
}  

完成后,您将可以使用 __P()函数引用第一行${__P(line_1,)},第二行为${__P(line_2,)},依此类推

once done you will be able to refer the first line using __P() function as ${__P(line_1,)}, second line as ${__P(line_2,)}, etc.

这篇关于JMeter:CSV数据集配置“在每次测试迭代开始时读取行". -应该如何运作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆