在JMeter中从CSV数据集中的每个线程使用同一行 [英] Use same row per thread from a CSV data set in JMeter

查看:911
本文介绍了在JMeter中从CSV数据集中的每个线程使用同一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在JMeter中制定如下测试计划:

I want to make a test plan in JMeter as follows:

我在使用Web服务器时有特定的流程:

I have a specific flow with a web server:

Req1  
Reply for Req1  
Req2  
Reply for Req2  
Req2  
Reply for Req2    
etc

我需要将它们作为流运行,即每个线程从头到尾执行此操作(不是 Req1Req2通过不同的线程发送).
我还需要在每次迭代中发送不同的参数,因此我使用了CSV data set.

I need to have these run as a single flow i.e. each thread executes this from start to finish (not Req1 and Req2 send by different threads).
I also need to send different parameters in each iteration so I used CSV data set.

问题:
对于每个线程的所有请求,我都需要从CSV发送同一行.

Problem:
I need to send the same row from CSV for all the requests per thread.

例如:
如果我有以下CSV文件:

For example:
If I have the following CSV:

john,A1111,engineer  
bill,A2111,manager  
mary,C1111,secretary   

我需要将第一行发送到 all ,由线程1将Req1到最后一个请求的流发送,而将第二行发送给 all 请求中的线程2.等等

I need the first row to be send in all the flow from Req1 to the last request by thread 1 and the second row by thread 2 in all requests etc.

这可能吗?我尝试将相同的CSV文件添加到所有控制器,但仍无法按预期工作.

Is this possible? I tried adding the same CSV file to all my controllers but still does not work as expected.

更新:
我感兴趣的是让每个线程在CSV文件中消耗1行,并为我的流中的所有请求缓存"该行.

Update:
What I am interested in is having each thread consume 1 row from the CSV file and "cache" that row for all requests in my flow.

推荐答案

实现方案的最简单方法如下:

The simplest way to implement your scenario is like the following:

Test Group
Number of Threads = N
    CSV Data Set Config
    Filename: ... (your csv-file here)
    Variable Names: name,id,position       // (as per your csv sample above)
    Delimiter: ,
    Recycle on EOF = True
    Stop Thread on EOF = False
    Sharing Mode = All threads
    Simple Controller  // that's optional: simply to group your requests flow
        Sampler 01     // use ${name}, ${id}, ${position} variables to refer extracted values
        Sampler 02
        ...
        Sampler X

  • Number of Threads = N将启动N个线程;
  • Sharing Mode = All threadsSharing Mode = Current thread group将强制每个线程从csv读取单独的行,然后在所有后续采样器中使用提取的值;
  • 如果线程数N> csv中的条目数,
  • Recycle on EOF = True将回收csv.
    • Number of Threads = N will start N threads;
    • Sharing Mode = All threads or Sharing Mode = Current thread group will enforce each thread to read separate row from csv and then use extracted values in all the subsequent samplers;
    • Recycle on EOF = True will recycle your csv if number of threads N > number of entries in csv.
    • 这篇关于在JMeter中从CSV数据集中的每个线程使用同一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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