简体   繁体   English

如何在JMeter中读取CSV的值执行HTTP PUT请求?

[英]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:在我的场景中,我使用具有以下参数的并发线程组

  • Target Concurrency : 50目标并发数:50
  • RampUp Time ( secs ): 10加速时间):10
  • RampUp Steps count : 5 RampUp 步:5
  • Hold Target..( secs ): 10保持目标..():10

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 一些插件,例如:

  1. Random CSV Data Set Config 随机 CSV 数据集配置
  2. or HTTP Simple Table ServerHTTP 简单表服务器

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 ):因此,这种方式(在gEditLibreOffice 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.

相关问题 如何在 Z8F0466AE1A66FDAF3CED537A2 中的单个 HTTP 请求中从 CSV 文件发送多个 JSON 数据 - How to send multiple JSON data from CSV file in single HTTP request in JMETER tool 如何在Jmeter中执行PUT操作来更新API? - How to perform PUT operation to update an API in Jmeter? JMeter从JSON读取值 - JMeter reading values from JSON 如何用参数将jmeter请求中的json值从“ null”替换为null? - how to replace json values from “null” to null in jmeter request with parameters? Jmeter-如何读取Json格式的数组形式的GET请求返回的多个值并将其写入CSV文件 - Jmeter - How to read multiple values returned by GET request in the form of array in Json format and write it to a CSV file 如何将值从字典列表到带有列名称的csv python中? - How to put values from list of dictionary to csv with column names in python? 对于jmeter post请求,如何从csv文件生成输入json? - For jmeter post request, how can I generate input json from csv file? JMeter GET 请求 – 如何从 .csv 文件中添加查询参数? - JMeter GET Request – How do you add query parameters from .csv file? 如何在jmeter的http请求请求主体中传递参数和json? - How to pass parameter and json both in http request request body in jmeter? 如何在 Z4F8AAC143764B0646D 中使用 groovy 将来自 http 请求的 JSON 响应传递给 jsr223 断言 - How can I pass JSON response from http request to jsr223 assertion using groovy in Jmeter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM