如何在JMeter HTTP请求中更改Post Body的内容 [英] How to change content of Post Body in JMeter HTTP Request

查看:745
本文介绍了如何在JMeter HTTP请求中更改Post Body的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请原谅我的无知,因为我是jmeter菜鸟.我的网络服务接受JSON对象,因此我能够编写一个基本测试,在http请求的帖子正文"部分中创建带有JSON对象的HTTP请求.

Please forgive my ignorance as I'm a jmeter noob. My webservice accepts JSON objects so I was able to write a rudimentary test where I create an HTTP Request with a JSON object in the "Post Body" portion of the http request.

无论如何,我想做的是让HTTP请求从csv文件或其他某种输入机制中选择一个不同的JSON对象,以便我可以随机化在负载测试期间运行的查询的类型.有没有办法做到这一点?最接近的可能是使用变量(用户手册中的4.11节),但是我感觉并不是使用变量的方式.

Anyway, what I want to do is have the HTTP Request choose a different JSON object from a csv file or some other input mechanism so that I can randomize the types of queries that are being run during the load test. Is there a way to do this? The closest is probably using variables (section 4.11 in the user manual) but I have a feeling that's not how variables are used.

我理论化的第二种方法(尽管我还没有尝试过,因为我认为上面的方法更简单)是创建一个HTTP Request Default obj,其中包含一堆带有不同JSON对象的HTTP Request,然后使用一个随机控制器,可以在每次通过时随机通过我的多个HTTP请求.

A second way I've theorized (although I haven't tried yet since I think the method above is easier) is to create a HTTP Request Default obj with a bunch of HTTP Requests with different JSON objects in them and then use a Random Controller to randomly go thru my multiple HTTP Requests on each pass.

如果有第三种方法,我将竭尽全力学习如何使用此工具.我将继续阅读并可能尝试上述计划B.预先感谢您可以给我的任何帮助.

If there's a third way, I'm all ears to learn how to use this tool. I'll continue to read and possibly experiment with plan B above. Thanks in advance for any help you can give me.


更新:所以我尝试了第二种方法,它似乎可以工作.我有3个不同的HTTP请求,每个请求被命中的次数因运行而异.我仍然希望社区提供答案,因为我想了解专家在解决类似于我的问题方面的工作.


UPDATE: So I tried the second way and it seems to work. I had 3 different HTTP requests and the number of times each request gets hit varies from run to run. I still invite answers from the community since I'd like to see what the pros do for issues similar to mine.

推荐答案

您自己说了"csv文件或",部分回答了自己的问题.这是详细信息.

You have partially answered your question yourself, by saying "csv file or". Here are the specifics.

您必须在测试计划中使用 CSV数据集配置来从CSV读取数据.在您的帖子正文中,使用从CSV读取的变量.

You will have to use CSV data set config in your test plan to read data from CSV. In your post body, use the variables read from CSV.

这是 查看全文

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