How to alternate between two HTTP Requests in JMeter - jmeter

Is there an easy way to get JMeter to alternate between two HTTP Requests in my test plan?
What's happening now is I have 8 threads (users) in my test. I want to have 4 users hit HTTP A and 4 to hit HTTP B. I put the HTTP Reqs in an Interleave Controller but that doesn't seem to do what I want. It's only hitting HTTP A. It only hits HTTP B when I set loop count = 2 and it goes thru iteratively, meaning loop = 1, all 8 threads hit HTTP A. Loop = 2, all 8 threads hit HTTP B. It doesn't alternate like I want.
I also looked at the Switch Controller but I don't know how to change the value or tell the controller which HTTP request to hit.
Can someone give me a hint on what I should do? I have a simple test plan created so if someone needs me to post something, I can do it. Just let me know. Thanks in advance for your help.

I think you are looking for something like this!
Use If Controller.
For my below setup - HTTP Request A would be called by the first 4 threads, Threads 5,6,7 & 8 would call HTTP Request B
EDIT:
Parameterize the total no of users for the test.
Then your If condition will change like this.

There is one way out which may be if you can run two instances of Jmeter for Http request A and B respectively.Also check if code can reach B by just running Http Request B.

Related

How to set think times between HTTP requests in bzm -Parallel Controller

I am trying to set think times inside a "bzm-Parallel Controller" between HTTP-Requests, but unfortunately without success.
In my attached test plan I tried to test the parallel controller with 3 requests, but all 3 requests will be started at the same time.
enter image description here
I want to set think times of 100-200 ms between each request.
Is there a possibility to configure the "bzm-Parallel Controller" in this way or is it only possible between "normal" requests without a parallel controller?
bzm-Parallel Controller is something that is executing its children in parallel, to wit all 3 MetadataX requests will be started at exactly the same moment.
If you want a delay between these requests - move them outside of the bzm-Parallel Controller
More information on the concept:
Parallel Sampling for JMeter
How to Use the Parallel Controller in JMeter

Jmeter for loop http request - parallel

I am using JMeter for image load testing.
I have an array of the image name and looping over that array, I am getting all the image via HTTP request.
-> loop_over_image - for loop controller
-> http_request sampler
for now, it will loop and fetch images via HTTP sampler one by one.
It is possible to make these request parallel.
I am looping over 300 images - means 300 HTTP request, it is taking more than 5 minutes, but in chrome, it is taking 30 seconds because chrome API requests are ASYNC - means kind of parallel.
Is there any way to make these 300 request parallel. I don't think it is possible, because the loop will go to each image one by one.
I am looking for the same solution.
I am extracting from an HTTP response a list of urls and assigning them into a variable (as array).
Parallel controller will not work in this case, since it does not accept an array as an input.
I think that there is not simple way to do it (possible using Java and JSR223Sampler).
JMeter dev community should add this feature to JMeter.
I've opened an enhancement request https://bz.apache.org/bugzilla/show_bug.cgi?id=63526
Please vote up on it, so it will be implemented.
Try with parallel controller or sampler.
Kindly check the below link:-
https://github.com/Blazemeter/jmeter-bzm-plugins/blob/master/parallel/Parallel.md
Hope this helps.

How to make Jmeter to make the same request twice

I encountered a problem in Jmeter.
I have a scenario that I need to check, and it is to send the exactly the same http requests multiple times.
the request will not get any answer.
the problem is that Jmeter do it only once, it not even try to perform it in the second time.
I put it in a loop and still only once,
is their any solution? how can I make jmeter to perform multiple http requests.
for manual solution I use postman and send the same requests over and over again manually.
Is their any solution? I put the test plan, junk 1 + 2 + 3 are just the same call without any change, and the response is just 200, why Jmeter not run the http more than once?
[][test plan junk 2 + 3 not do]
[][loop controller set to forever]
[][all the junks are the same]
[][response of junk is 200ok nothing more]
[][no junk loop or 2 + 3 calls performed ]
[][logs]
Came across this while debugging the same issue - our problem was the "Use Cache-Control" option was ticked under "HTTP Cache Manager". This stops subsequent GET requests being processed, without an obvious warning or message.
Looking into red 1 near the yellow exclamation sign there is an error presumably connected with junk2, check out jmeter.log file for details, you should be able to identify the reason from there.
Also check your Thread Group settings, especially Action to be taken after a Sampler error parameter, if it is set to Stop Test or Stop Test Now might be a good explanation.
Normally people go for While Controller in order to repeat certain step(s), it allows to define condition(s) to exit the loop.

How to run jmeter samplers sequentially for multiple requests

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. 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.
Dzizu is correct, threads are independent so you are going to run into problems with this approach.
Since you are using 5 users across the test, it would be better to have one thread group with 5 users, and then have Simple controllers (or Transaction controllers) that hold the HTTP samplers and whatever else you are using. This will ensure that the samplers are executed concurrently, but they can still share data if required.
Simple example below:
Threads usually are independent. The easiest way in my opinion is to put full process in one thread and then multiply threads in thread groups.
Eventually I tried to solve this by using loop count option. For example if I want to simulate 5 users in 1 second, I set values as loop count=5,threads=1,ramp-up=.2.
This worked for me so give it a try.
Use the Transaction Controller or Simple Controller to group your samplers together and run them in sequence without worrying about the number of threads. For me, it is working as expected :).

how to run two requests sequentially in jmeter

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

Resources