How can jmeter controller executes after 9 requests - jmeter

How can i execute my j meter controller to run after 9 requests. i tried to run controller every after 9 requests to get token. token expires after 9 requests.
what controller i need to use, do i need to put any conditions.

You can put your request(s) under the Loop Controller in order to execute it(them) specified number of times.
The request for getting the token can be placed under If Controller where you can use i.e. __jexl3() function so the token request will be executed only one of 9 times
Example setup:

Related

How to chain HTTP request requests in Jmeter Simple Controller?

I have multiple Simple Controllers under Thread group. All controllers have 1 HTTP request. Only one controller have 3 requests. How can I chain 3 requests in one simple controller to run sequentially.
Test Plan
The screenshot above is my test plan. In v4/bootstrap call I have 3 HTTP requests. Result of these 3 requests is token which I extract from get_v4/restart and then this token used for all other requests. For correct token generation 3 requests from v4/bootstrap call should run sequently. On summary report shown that amount of run 3 requests is different.
Each JMeter thread (virtual user) executes Samplers upside down. The same applies to Simple Controllers.
So you don't need to do literally anything, each thread will execute samplers sequentially as they appear in the Test Plan.
If you have more than 1 virtual user in the Thread Group you might be confused by the "wrong" order of sample results:
However each user is still executing samplers upside down, you can check it by adding __threadNum() function to show the current virtual user's number and __groovy() function calling vars.getIteration() method
You will see that each user executes samplers sequentially and starts over when the last sampler ends and there are iterations still:

How to run both request/sampler successfully

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.

JMeter - running a login request once and looping other requests

I have a test plan that consists of three requests: login, get current bingo round and save bingo ticket. The login request has a JSON Extractor that extracts an access token variable that is sent in bingo saving request header.
I want to run the login request only once and then loop other 2 requests for one hour. Ultimate thread group has the following settings: 150 threads, initial delay of 1 sec, 10 sec startup time and hold load for 3600 secs.
The first loop controller only contains the login request and should loop once. The second loop controller is set to loop forever and contains the other 2 requests and a throughput shaping timer that I set to 15 requests per second and has duration of 3600 seconds.
This is the test plan structure:
The problem is that the login request keeps looping and doesnt execute only once when I view results in Results tree and the result I want to achieve is that test plan logins only once and then loops other requests for 1 hour.
What exactly is wrong in my test plan structure?
Add If Controller to the beginning of your script
Use the following condition in the If controller (assumes __jexl3() function):
${__jexl3(${__jm__jp#gc - Ultimate Thread Group__idx}==1,)}
Put your Login Request as a child of the If Controller
This way the Login Request will be executed only once per thread

How can I send the second set of loop after getting response of the first set of loop in Jmeter

My application is calling ajax in every 5 seconds. I am testing with a load of 3500 users. That means 3500 users are calling ajax in every 5 seconds
Application setup- ajax is called in an interval of 5 seconds only after getting a response from the first ajax. Mean first ajax is called the request is processed by server and give response and then 5 seconds and then next ajax is called.
My jmeter setup- Am using loop controller and constant timer(5 seconds) inside the loop controller. So the request is being send my jmeter constanly in every 5 seconds irrespective of the response. So every 5 seconds 3500 users is being called with or without getting response.
My expectation: I want to call ajax request only once I gets the response from each threads of 3500 users. How can I do that in Jmeter.
One possible way is to use a "IF Controller" in Jmeter to check the response of the previous request and control the rest of the flow accordingly.
For example, use ${JMeterThread.last_sample_ok} function as the condition of the controller, which checks if the previous request was successful before executing the next request.
More information can be found under "Tip #5 - Use the ${JMeterThread.last_sample_ok} to Check Transactional Requests" in [1]
[1] https://www.blazemeter.com/blog/six-tips-for-jmeter-if-controller-usage
Hope this helps.
Thanks for the prompt reply. This actually worked. But, I found out much simple method. Added a beanshell postprocessor as a child of the ajax request and added a script Thread.sleep(5000);. Which did the same behavior I explained above

Using reg exp extractor value from a request in one throughput controller to a request in another throughput controller

I have a test which does following
I have a GET request in one throughput controller. For this request I am using regular expression extractor to get value for a request attribute.
I have second throughput controller which has another GET request. To run this request I need use value of regular expression extractor from a GET request in first throughput controller.
I am able to do this if I have both requests in one throughput controller. But the same is not working if I have 2 requests in 2 different throughput controllers.
Can someone help on this?
There's no limitation for passing values from request under one controller to request under the other, provided they are in the same thread group. However, depending on your Throughput Controller settings, the first GET request may not run always run at the same time as the second GET request from second throughput controller. In other words, both Throughput controllers are making their decisions independently, and do not always make the same decision on whether to run the sampler under them or not.
To resolve this, you need to either introduce a dependency, so that second GET only runs if first got executed, or have 2nd GET to have a default value in case it's not available from the 1st request.
Here's one way to introduce a dependency, as example (many other ways are possible as well):
Throughput Controller 1
GET 1
If Controller <-- check if GET 1 was executed
Throughput Controller 2 <-- runs only if GET 1 was executed
GET 2

Resources