[英]How to perform HTTP PUT Request by reading values from CSV in JMeter?
how can I set up HTTP Request Sampler for HTTP PUT method in JMeter so it can read data from CSV file using CSV Data Set Config?如何在 JMeter 中为 HTTP PUT 方法设置 HTTP Request Sampler,以便它可以使用 CSV 数据集配置从 CSV 文件中读取数据? In my scenario I'm using Concurrency Thread Group with the following parameters:
在我的场景中,我使用具有以下参数的并发线程组:
This is my CSV Data Set Config setup:这是我的CSV 数据集配置设置:
(Java) Types of Variable Names are: bookId: Long , title: String , price: double , amount: int , authors: Set , categories: Set , isDeleted: boolean (Java)变量名的类型有:bookId: Long , title: String , price: double , amount: int , authors: Set , categories: Set , isDeleted: boolean
This is my HTTP Request Sampler setup:这是我的HTTP 请求采样器设置:
...and this is content of my bookCollection10Items.csv file where quoted values are Strings, and the ones in angle brackets [] are arrays of values (as I'm updating Book that has Many-To-Many relationship with Categories/Authors): ...这是我的bookCollection10Items.csv文件的内容,其中引用的值是字符串,尖括号[]中的值是arrays的值(因为我正在更新与类别/作者有多对多关系的书):
1,"Harry Potter and Magic Stone",39.99,2500,[4],7,11,false 1,"哈利波特与魔法石",39.99,2500,[4],7,11,false
2,"Murder on the Orient Express",[19.98,500500],1,9,false 2,"东方快车谋杀案",[19.98,500500],1,9,false
3,"The Murder of Roger Ackroyd",19.99,1500,1,[7,9],false 3,"罗杰·阿克罗伊德谋杀案",19.99,1500,1,[7,9],false
4,"Harry Potter and the Chamber of Secrets",24.99,0,4,[7,9],true 4,"哈利波特与密室",24.99,0,4,[7,9],true
5,"Harry Potter and the Prisoner of Azkaban",17.99,1200,4,7,false 5,"哈利波特与阿兹卡班的囚徒",17.99,1200,4,7,false
6,"The Da Vinci Code",29.99,700,8,10,false 6,"达芬奇密码",29.99,700,8,10,false
7,"Inferno",22.50,950,8,10,false 7,“地狱”,22.50,950,8,10,假
11,"War and Peace",31.99,300,5,8,false 11,"战争与和平",31.99,300,5,8,false
14,"The Trial",27.99,450,6,9,false 14,“审判”,27.99,450,6,9,假
15,"IT",16.50,0,2,5,true 15,"IT",16.50,0,2,5,真
What I want to achieve is that each Thread(ie User) to select one item from "bookCollection10Items.csv" file in a round-robin fashion and update it for a given bookId using "All Threads" as Sharing Mode option.我想要实现的是,每个线程(即用户)以循环方式将“bookCollection10Items.csv”文件中的一个项目select 更新为给定的 bookId,使用“所有线程”作为共享模式选项。
Any advice/suggestion is greatly appreciated.非常感谢任何意见/建议。
JMeter's built-in CSV Data Set Config is reading lines from the CSV file sequentially so each user will get the next line on each iteration. JMeter 的内置 CSV 数据集配置按顺序从 CSV 文件中读取行,因此每个用户将在每次迭代中获得下一行。
If you need to read a random line (however I don't think it's a good idea as I believe tests need to be repeatable ) you will need to go for some plugins like:如果您需要阅读随机行(但我认为这不是一个好主意,因为我认为测试需要可重复),您将需要 go 一些插件,例如:
Both can be installed using JMeter Plugins Manager两者都可以使用JMeter 插件管理器安装
I've managed to find a solution with my problem -> I made a mistake by:我已经设法找到解决问题的方法 -> 我犯了一个错误:
1) Creating CSV file in gEdit (Linuxs' equivalent of Windows Notepad) instead of using LibreOffice Calc where work is done in cells . 1)在gEdit (Linux 相当于 Windows 记事本)中创建 CSV 文件,而不是使用在单元格中完成工作的 LibreOffice Calc。 Therefore this way (both in gEdit and LibreOffice Calc ):
因此,这种方式(在gEdit和LibreOffice Calc中):
3,"The Murder of Roger Ackroyd",19.99,1500,1,[7,9],false
3,"罗杰·阿克罗伊德谋杀案",19.99,1500,1,[7,9],false
...is a no-no. ……是不行的。
2) Removing angle brackets [] from listing so arrays would NOT contain arrays. Eg When angle brackets are present I get this: 2)从列表中删除尖括号[] ,这样 arrays 就不会包含 arrays。例如,当存在尖括号时,我得到这个:
{
// some other fields
"authors" : [[7,9]]
}
3) Had to properly format numbers with decimals to contain dot , NOT comma ( locale issues). 3)必须正确格式化带小数的数字以包含点,而不是逗号(区域设置问题)。 Eg Proper format is 19.99, wrong format 19,99
例如,正确的格式是 19.99,错误的格式是 19,99
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.