如何避免在 JMeter 中重复使用 CSV 文件中的用户
How to avoid duplicate usage of Users from CSV file in JMeter
我正在使用 JMeter 执行负载测试,流程如下:
多个用户组成的线程组,无限循环5分钟。 (图片在下link->1)
具有以下配置的 CSV 配置文件 (in this link CSV config)
所以,我的计划是:
- 从 CSV 文件中获取用户(在 CSV 文件中,每一行都有用户名)。
- 有一个循环控制器,里面有:
- 曾经是我的登录请求的唯一控制器。
- 交易取决于会话有效性(这就是我拥有循环控制器的原因)。
问题是 - 我收到了很多多个会话错误,所以我想确保我正在正确配置我的测试,以避免出现上一个线程循环中的用户尚未完成流程的情况,但是第二个线程循环开始并从导致无效会话的 CSV 文件中获取特定用户的详细信息到第一个 运行.
谢谢
您可以通过提供足够数量的凭据来克服这种情况,即
number of credentials = number of threads.
因此,每个线程都可以选择一个唯一的用户名和密码,从而避免同一用户的多个会话的冲突。
如果 CSV 文件中没有足够的条目,JMeter 将重用凭据。即,Recycle on EOF, default value set to True.
(在 CSV 数据集配置 中)。因此,如果您提供的凭据数量较少,那么 JMeter 会从头开始为以后的线程重新使用这些值。除非 AUT(被测应用程序)支持同一凭据的多个会话,否则您不能使用更少数量的凭据。关闭设置 Recycle on EOF
,导致后面的用户(线程)缺少凭据,从而导致 JMeter 停止这些线程。
如何读取 CSV 值:
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.
如果您希望每个线程都有特定的值:
If you want each thread to have its own set of values, then you will need to create a set of files, one for each thread. For example test1.csv, test2.csv, …, testn.csv. Use the filename test${__threadNum}.csv and set the "Sharing mode" to "Current thread"
参考:
我正在使用 JMeter 执行负载测试,流程如下:
多个用户组成的线程组,无限循环5分钟。 (图片在下link->1)
具有以下配置的 CSV 配置文件 (in this link CSV config)
所以,我的计划是:
- 从 CSV 文件中获取用户(在 CSV 文件中,每一行都有用户名)。
- 有一个循环控制器,里面有:
- 曾经是我的登录请求的唯一控制器。
- 交易取决于会话有效性(这就是我拥有循环控制器的原因)。
问题是 - 我收到了很多多个会话错误,所以我想确保我正在正确配置我的测试,以避免出现上一个线程循环中的用户尚未完成流程的情况,但是第二个线程循环开始并从导致无效会话的 CSV 文件中获取特定用户的详细信息到第一个 运行.
谢谢
您可以通过提供足够数量的凭据来克服这种情况,即
number of credentials = number of threads.
因此,每个线程都可以选择一个唯一的用户名和密码,从而避免同一用户的多个会话的冲突。
如果 CSV 文件中没有足够的条目,JMeter 将重用凭据。即,Recycle on EOF, default value set to True.
(在 CSV 数据集配置 中)。因此,如果您提供的凭据数量较少,那么 JMeter 会从头开始为以后的线程重新使用这些值。除非 AUT(被测应用程序)支持同一凭据的多个会话,否则您不能使用更少数量的凭据。关闭设置 Recycle on EOF
,导致后面的用户(线程)缺少凭据,从而导致 JMeter 停止这些线程。
如何读取 CSV 值:
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.
如果您希望每个线程都有特定的值:
If you want each thread to have its own set of values, then you will need to create a set of files, one for each thread. For example test1.csv, test2.csv, …, testn.csv. Use the filename test${__threadNum}.csv and set the "Sharing mode" to "Current thread"
参考: