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

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

问题描述

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

http 调用看起来像

<前>/service/method?param1=${param1}&param2=${param2}

CSV 是这样的:

<前>1,23,45,67,8

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

无论如何我能做到这一点吗?

谢谢!

解决方案

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

<前>测试计划线程组线程数:N...虽然控制器条件:${__javaScript("${param2"!="<EOF>",)} - 读取 csv 文件直到 EOFCSV 数据集配置文件名:[带有测试数据的文件路径]变量名:param1,param2在EOF上回收?错误的在 EOF 上停止线程?真的共享模式:当前线程组循环控制器Loop Count = 1000 - 每个线程的循环次数,具有相同的参数HTTP 请求 - 你的 http 调用测试操作目标 = 当前线程动作 = 暂停持续时间 (ms) = 10000 - 通话之间的暂停...

如果您需要 N 个线程中的每一个从 csv 文件中读取和使用单行和唯一行,您必须为 CSV 设置共享模式:当前线程组数据集配置(在这种情况下,csv 条目的数量应与线程数相同,否则应设置 Recycle on EOF?False).
如果您需要 N 个线程中的每一个读取和使用 csv 文件中的所有行,您必须为 CSV 数据集配置设置共享模式:当前线程.>

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

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.

The http call looks like

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

The CSV is like this:

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

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.

Is there anyway I can achieve this?

Thanks!

解决方案

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
            . . .

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天全站免登陆