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.
Related
I am trying to run http samplers sequentially for multiple requests. Where the output of 1 API response is the input of next API request. My concern is when I run with 5 users (for. e.g), then at given point of time it first executes 1st API with 5 users then second API with 5 users, in this process the API where input is required gets lost. Please help me on this.Actually I have used transaction controller also but here not sequentially api run,so getting file not found exception bcause of first api output response parameter is not passed to second api as a input parameter
I need a solution, where all the samplers are first executed for first user, then for second thread all the samplers are executed and so on.
Each JMeter Thread (virtual user) executes Samplers upside down, if you have 2 samplers each user will always run 1st sampler then it will run 2nd sampler.
You can use __threadNum() function and ${__jm__Thread Group__idx} pre-defined variable in order to verify that the execution order is sequential.
If you want all the users to execute first sampler then all users to execute the second sampler - go for Synchronizing Timer
If you want to get to the reason of the failure try saving the responses using i.e. Simple Data Writer as it might be the case your "first" API fails silently and hence your correlation doesn't extract the value.
I am working on setting up a way to do a performance test for the rest API's using Jmeter which includes token expiry for every three minutes.
1.)Currently, I created two thread groups one for making a call to get "access_token" and setting into the property using Bean shell assertion setProperty, to be used in other thread Groups.
2.)I could see Second thread group can access the value set in the first step.
But my goal is to execute the first thread group every 2min 30 seconds continuously so that the second thread group can get the new token every 2 min 30 seconds.
I tried a constant timer, but didn't seem to work is there any way to do this or any other timer to use to achieve this token refresh?
Thanks in advance
The Constant Timer should work, but be aware that it creates a delay before each Sampler it it's scope so it might be the case your setting it up wrong, you can use i.e. a Dummy Sampler and put the Constant Timer as a child of the Dummy Sampler, this way your HTTP Request to get token will be executed, followed by the delay defined in the Constant Timer, followed by the Dummy Sampler, et.c
Example setup:
You might find Flow Control Action sampler easier to use
Also be aware that starting from JMeter 3.1 you're supposed to be using JSR223 Test Elements and Groovy language for scripting. Moreover it's not required to write any code, you can go either for __setProperty() and __P() functions combination or for Inter-Thread Communication Plugin
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.
I'm trying to load test our web app server side with JMeter, everything works so far except one thing.
I have a heartbeat loop the app client side that pings the server every x seconds.
I tried the while processor but then the thread is just "stuck" there (as expected).
Is there a way to execute a request every x seconds while the other requests are still executing?
I also would need access to the variables of my thread since the heartbeat sends a unique id, so another thread group won't work as far as i understand.
The id is read from one of the first request responses into a variable so the heartbeat requests should only start when this variable becomes available.
Another separate Thread Group to send heartbeat requests is the easiest way to achieve, if you need to pass a value from the "main" thread group you can do it in 2 ways:
Use __setProperty() function in the "main" thread group to convert the variable into a property and use __P() function in 2nd Thread Group to read the value. If you have more than 1 thread it makes sense to add __threadNum() function to make the value thread-specific.
Use Inter-Thread Communication Plugin if you don't mind using JMeter Plugins
Need some help on Jmeter for the following scenario please I need to simulate these steps in order to load our application.
a) make a request to a web-service.(done)
b) verify the response for some variables and extract a URL address from the response.(done)
c) Now using the extracted URL need to make another request.(extraction done)
d) in response a media file will be sent.
My Plan consists of "stepping thread group-->(Sampler 1)HTTP Request +couple of listeners for data gathering--> (Sampler 2)HTTP Request +couple of listeners for data gathering. the issue is that when i ran the plan the first sampler generated 4 requests but the second one generated only 2 can you tell me why is it so.
In general how can i simulate all 4 steps in one go for a single thread. I hope that i have cleared myself.
In JMeter each thread runs requests sequentially already.
So in order to do what you expect you'll need to use:
Post Processors called extractors to extract data into variables
Variables to inject in the requests
Read:
https://jmeter.apache.org/usermanual/test_plan.html#postprocessors
https://jmeter.apache.org/usermanual/functions.html#functions