使用CSV数据集配置时强制线程使用相同的输入行 [英] Force a thread to use same input line when using CSV Data Set Config

查看:58
本文介绍了使用CSV数据集配置时强制线程使用相同的输入行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试建立一个Jmeter测试计划,该计划可以对服务器进行http调用.线程组中的每个线程将从CSV文件中读取2个参数,并使用参数进行http调用,并继续使用相同的参数进行相同的调用,例如说1000次,每个线程执行之间的延迟为10s.

I am trying to build a Jmeter test plan that can make http calls to a server. Each thread in the thread group will read 2 parameters from a CSV file and make the http call with the params, and continue to make the same call with same parameters for lets say 1000 times with a delay of 10s between each thread execution.

http呼叫看起来像

The http call looks like


/service/method?param1=${param1}&param2=${param2}

CSV是这样的:


1,2
3,4
5,6
7,8

我已经制定了测试计划,该计划在大多数情况下都适用,除了单个问题.我希望每个线程在执行时都使用相同的参数(输入的同一行).当前唯一的方法是设置Recycle on EOF = true,但是线程随机选择值.只要参数Param1和Param2在整个执行过程中坚持使用相同的线程,就可以将它们随机生成.

I have the test plan set up that works for the most part except the single issue. I want each thread to use the same parameters (same line of input) whenever the thread executes. Currently the only way to do it is to set Recycle on EOF = true, but the threads randomly pick the values. Param1 and Param2 can be randomly generated values as long as they stick with the same thread throughout the execution.

反正我能做到吗?

谢谢!

推荐答案

我不太确定我是否理解您的问题(您可以更明确地描述它,也可以使用示例),但是下面的模式应该实现您的测试-计划说明:

I'm not really sure I understand your issue right (you can possibly describe it more explicitly or using an example) but the schema below should implement your test-plan description:


Test Plan
    Thread Group
    Number of Threads: N
        . . .
        While Controller
        Condition: ${__javaScript("${param2"!="<EOF>",)} - read csv-file until the EOF 
            CSV Data Set Config
            Filename: [path to your file with test-data]
            Variable Names: param1,param2
            Recycle on EOF? False
            Stop thread on EOF? True
            Sharing mode: Current thread group
            Loop Controller
            Loop Count = 1000 - number of loops for each thread, with the same params
                HTTP Request - your http call
                Test Action
                Target = Current Thread
                Action = Pause
                Duration (ms) = 10000 - pause between calls
            . . .

如果您需要N个线程中的每个线程读取并使用csv文件中的单行和唯一行,则必须为CSV数据集配置设置Sharing mode: Current thread group(csv条目数应为在这种情况下必须保持理智的线程号,否则应设置Recycle on EOF? False.
如果您需要N个线程中的每个线程读取并使用csv文件中的 all 行,则必须为CSV数据集配置设置Sharing mode: Current thread.

In case if you need that each of N threads reads and uses single and unique line from csv-file you have to set Sharing mode: Current thread group for CSV Data Set Config (number of csv-entries should be in this case the sane as threads number, or Recycle on EOF? False should be set otherwise).
In case if you need that each of N threads reads and uses all lines from csv-file you have to set Sharing mode: Current thread for CSV Data Set Config.

如果这不是您想要的,请更清楚地描述您的问题.

If that's not what you want please describe your issue a bit more clear.

这篇关于使用CSV数据集配置时强制线程使用相同的输入行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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