I have the following setup in my Test Plan.
Thread Group (number of thread = 1)
ForEach controller
Precise Througput Timer
POST request
Teardown Thread Group
ForEach controller
DELETE request
I have the following two questions that I could not find answer for. I'd appreciate if someone can help me with.
My understanding is that the Precise Throughput Timer under ForEach controller in Thread Group schedules the POST requests to be sent so that the desired throughput is achieved. However, I am confused because the POST request is in a loop, which I expect that the a request in the next iteration can only be sent if the request in the current iteration is finished, i.e. getting back a response. If the current request is taking a long time to finish, does it mean it changes the time the next request is sent and thus affects the throughput? Or is the next request being sent without waiting for the current request to finish to ensure the defined schedule (made by the Precise Throughput Timer) is maintained?
I need to save the resource ID returned from the POST request (if the POST request is successful) to a variable to a list and later in the Teardown Thread Group I can loop through these IDs. I could not find yet any list type variable in JMeter that allows me to do that. Is there a way to do that?
Unfortunately can't use variables for transmission between threads.
Need use property:
Set property props.put("resourceID", "qwerty");
Get property ${__property(resourceID)}
Related
In my Jmeter script request which contains the 'LongPolling' transport method and it takes a high load time or response time
Also, the response message content value is used for the next consecutive request. How can I handle that scenario?
I don't want this my wait time for the server response
JMeter thread model assumes that a thread (virtual user) always waits for the previous sampler to fully complete before starting the new one.
The easiest solution is moving your "long-polling" requests into a separate thread group and if you need to pass data between thread groups either use __setProperty() and __P() functions combination or go for Inter-Thread Communication Plugin
If you need to have everything within the single Thread Group - you can consider using Parallel Controller, however it might not be fully suitable for your needs as it is still a Sampler hence it waits for all its children completion prior to proceeding
Depending on your use case you can find jmeter-asynchronous-http plugin useful, see How to Load Test Async Requests with JMeter article for more details if needed.
In JMeter, I can load test many pages using a random variable:
/path/item/${random_var}
I would like to hit each page X number of times (or until a condition is met). I would also like to wait (e.g. 1 second) in between requests for a specific page (it's fine to have concurrent requests for /path/item/1 and /path/item/2).
Any guidance on setup for that is much appreciated. I can answer clarifying questions if needed.
Add a Constant Timer as a child of this request and set Thread Delay to 1000.
Timer will be fired before each request therefore you will get a 1 second delay between next call. Sleep time will not be added to sampler's response time (unless you are using Transaction Controller configured to do so)
See A Comprehensive Guide to Using JMeter Timers for more information on above and other Timers and their use cases.
I need to send multiple post requests simultaneously. And the problem is that transaction id in url should always be unique.
I added Synchronizing timer to send requests at once and added BeanShell PostProcessor to increment transaction id after request is sent.
But this works only if requests are executed one by one. How to increment transaction id if I need to run requests all at once?
Just use __counter() function in "global" mode like ${__counter(FALSE,)} instead of manually incrementing the "txnId" variable:
Demo:
See How to Use a Counter in a JMeter Test article for more information on generating incremented numeric values in JMeter.
Going forward remember that you need to implement some form of inter-thread communication to ensure that the same variable is not updated by 2 threads at the same time.
I have a http request with a BSF postprocessor script where I try to collect some data from the request. I have 10 users who call this request. I want to add a small delay between each request and I tried using a constant timer. The problem I have is, sometimes 2 or 3 HTTP requests are executed at the same time and that causes some logic disturbances in my postprocessor script. I tried using a constant throughput timer and still I end up with the same result. What is the correct way to send requests at constant time intervals?
A timer is specific to each thread so what you are tring to do will not work.
If you want to ensure your query is only executed by 1 user then use Critical Section Controller:
https://m.youtube.com/watch?v=HVVyTvoTmdc
http://jmeter.apache.org/usermanual/component_reference.html#Critical_Section_Controller
Thanks for the responses. I was finally able to achieve it just by increasing the ramp-up time. Thanks Mario for your quick response.
I am trying to understand jmeter's core behavior.
Say I am executing a HTTP request (single user and single sampler but different variable values) in infinite loop.
In the above case does jmeter send a request and waits for the response before sending the next request OR it sends the requests without waiting for response?
Jmeter uses a thread-based model where each thread will wait for a response before sending another request. In other words it will only drive the load as fast as application can take it.
In JMeter you specify a number of threads in a ThreadGroup which equate to virtual users, and the threads attempt to execute the script as many times as possible.
If you want to maintain a constant rate, you can use multiple threads and use a Constant Throughput Timer to set the request rate: if there are enough threads, it should be possible to maintain the rate even though some threads are waiting for a response. Here belongs also custom Throughput Shaping Timer which is more flexible.
Another possibility seems to be to use e.g. either Ultimate Thread Group or Stepping Thread Group from jmeter plugins.
In this context you can also look onto the Response Timeout field available for any jmeter's sampler - number of milliseconds to wait for a response.