A
A
Alexander2018-07-08 17:44:01
stress testing
Alexander, 2018-07-08 17:44:01

How to send a JMetr POST request to a URL, with data from a file(s)?

Good day everyone!
There is no experience in using JMeter, unfortunately.
There is a directory with text files, each line in which there is a POST request body. Each file contains requests from one client, i.e. file=client.
I ask for advice or information on solving the problem of automatically sending
data from files to a given URL using JMeter.
It's great if you manage to manage the parameters:
1. The number of simultaneously "working" clients (files)
2. The frequency of sending requests.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Smirnov, 2018-10-01
@polarnik

Good day.
About loading the request body from a file The HTTP Request
component has a special behavior for the File Path field: field , just for sending the full request body from a file:

Name of the file to send. If left blank, JMeter does not send a file, if filled in, JMeter automatically sends the request as a multipart form request.
If it is a POST or PUT or PATCH request and there is a single file whose 'Parameter name' attribute (below) is omitted, then the file is sent as the entire body of the request, ie no wrappers are added. This allows arbitrary bodies to be sent. This functionality is present for POST requests, and also for PUT requests. See below for some further information on parameter handling.

This feature is especially useful when sending large requests with a minimum amount of RAM. Otherwise, you would have to store a large request body in the test, and load large requests as strings into JMeter memory, and memory is always a valuable resource.
I recommend doing this:
* use the Directory Listing Config from JMeter Plugins, putting the file names in a variable
* and specify the variable in the File Path field of the HTTP Request component
If you use only standard tools, you can do this:
* command dir /Bor ls -lorfind *form a list of file names in the form of a file, let its name be files.csv * Duration (seconds): 300
* use CSV Data Set Config to load file names into a variable
* and specify the variable in the File Path field of the HTTP Request component
There are different approaches.
The easiest one is to just use a Thread Group with the following parameters:
* Action to be taken after a Sampler error: Start Next Thread Loop
* Number of Threads: 80000
* Ramp-up Period: 10000
* Loop Count: 1
* Delay Thread creation until needed: [v]
* Scheduler: [v] * Startup delay (seconds): 0
what happens - JMeter will know that in 10,000 seconds it is necessary to perform 80,000 starts, that is, it will work with a frequency of 8 starts per second. All frequency is controlled. Don't be afraid of the cosmic value of 80,000 threads, because the Delay Thread creation until needed: [v] checkbox is checked.
And the test will be performed with such a frequency of 300 seconds or 5 minutes (not 10,000 seconds).
There is an option to control the load, through the calculation of the number of threads and pauses between the execution of operations in them.
The classic option is to use
* Ultimate Thread Group
* Test Action (now called Flow Control Action)
* Constant Throughput Timer
I wrote an instruction about such a bunch:
*https://loadtestweb.wordpress.com/2017/08/23/pacing/
Alternatively, you can use the option with the exact execution of a given number of requests per time interval:
* using Precise Throughput Timer instead of Constant Throughput Timer
Or the fourth, using additional plugins:
* Concurrency Thread Group
* Throughput Shaping Timer
* Schedule Feedback Function
(but I still did not try)
In this way, you can solve all the problems:
  • Send request with body from specified file
  • Take files from the specified directory
  • Control the sending rate

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question