I am not an expert in JMeter but hope you can help.
How does one execute a test plan where based on a CSV input of users, I want 50% of them to go down 1 flow (for each user - do stuff) and the other 50% to do another flow of logic?
I'm not fussed about if it's at random (That would be good) of users in the file or sequentially going through it and splitting at the 50% mark - but do want to know how to do this type of process within a test plan?
I am trying to create an even (or almost even) type of distribution "load" - some go one path, some go another path. Simple.
Let me give you a walk through:
we have students.
students have different tests.
half of them I want each student to do ALL tests
half of them I want each student to do 1 test (based on some JSON that has been parsed which gives us the list of tests from the web end)
Also, is it possible where if I have a jmx file that contains, say, 10 controllers (these would be tests), I can pick one at random and then return back to the parent? Maybe in here a decision can be made to do next test or not and if next test then... cycle to the next one
Thoughts?
I am using JMeter 5.3 if it helps!
You can use Throughput Controller(s) to distribute the executions.
Set the Based on to Percent executions and set the value to 50.
Note: Set the Sharing mode in the CSV Data Set Config appropriately
You can use a Random Controller to pick a random child from the sub-controllers and samplers.
Use modulo (%) operator on the studentID (or 'number' or 'rownumber' -- whatever is handy).
If the output is odd, send a request to scenario a (first 50%), and if even, send a request for scenario b (second 50%).
// Example in PsuedoJava:
int id = myStudentIDNumber;
if(id % 2 == 0){ // Remainder is 0, so even number
fetch(mywebsite/api1);
} else { // Remainder is 1, so odd number
fetch(mywebsite/api2);
}
There are multiple ways of implementing your scenario, depending on what is your design the options are in:
Throughput Controller which controls how often its children to be executed (either in percentage of total executions or in absolute values)
Switch Controller which acts like a switch statement in programming languages - this guy seems to be the most appropriate for your use case. Moreover it can run a random child if you supply __Random() function as the input
Weighted Switch Controller - which combines above 2 approaches and provides easy way of
Related
I have a requirement to generate a random number and use it in subsequent requests. So, before using this newly generated random number in first subsequent request, i need to check if this random number generated is already exists in the application or not by comparing with newly generated response number. So for this validation i am thinking to use an extractor to get the count and eventually verify this is >1 and make it run until this condition is invalid. So in case of random number already exists, i need to generate a new random value since the previous one is already exist in the application. Any snippet i can use here?
An easier option would be going for __time() function which produces an Unix timestamp in milliseconds from 1st of Jan 1970. To be on the safe side you can add current thread number to it so even in case of concurrency you would get unique values (incrementing each millisecond):
More information on JMeter Functions concept: Apache JMeter Functions - An Introduction
I have a pretty big load test scenario for execution that I want to run with Taurus. It has more than 1000 different requests - some of them in loops because I would like them to execute several times.
Now that I have the scenario completed I'm looking for a way to randomise the requests during the execution. For example instead of the Taurus running the tests line by line from the scenario I would like Taurus to execute requests from the scenario in random order.
Any ideas how this can be achieved?
You can add to JMeter test plan Random Controller
Random Logic Controller acts similarly to the Interleave Controller, except that instead of going in order through its sub-controllers and samplers, it picks one at random at each pass.
You can even set 1 request at a time
ignore sub-controller blocks If checked, the interleave controller will treat sub-controllers like single request elements and only allow one request per controller at a time.
I have created seven thread groups which execute different scenarios in one application. I'm trying to optimize my scripts in order to be more maintainable and easy to master when someone else uses them.
The thing that i cannot figure out is how can i combine those thread groups into one or two and to still have the seven different execution paths and the possibility to control them, by control i mean to set how many users to execute scenario 1, how many to execute scenario 2 etc. till 7.
Currently the test plan looks like this
If you don't want several thread groups for some reason the alternative options are in:
Throughput Controller - with different global executions or execution percentages
Switch Controller - which provides random weighted values (in some cases Throughput Controller doesn't guarantee that samplers in scope will ever be executed)
See Running JMeter Samplers with Defined Percentage Probability guide for more information on configuration and implementation.
Well i just figured out how to do that i have added a Loop controller a Random Order Controller as child of the loop controller. And i have put seven throughput controllers as child of the Random Order Controller so now everything looks fine
I have a JMeter Test Plan with many copies of almost exactly the same test. In each case there is a variable that is slightly different.
Here is the configuration:
There are two sets of user variables. There is a top level user variable list, that contains maximum_runs and there are Test Fragment level user variable lists with the User Defined Variable add_users, which goes up by 10 for each test case. users is a static 10.
I set maximum_runs to 100 and disable all but one Test Fragment. This gives me a number of samples = 100 for each Fragment. I enable a second Test Fragment and I still get 100 samples. But as soon as I enable the third Test Fragment my number of samples drops to 90. 4th, 80. But on the 5th one it goes right back up to 100 and the cycle starts over again. I don't see anything wrong with my math so I believe it to be something about how JMeter uses jexl2 or maybe variables are being changed due to the number of Fragments running? I really need to be able to run this with the same number of samples no matter how many Fragments are running. Ah, note, I have Run Thread Groups consecutively (i.e. run groups one at a time) in Test Plan checked.
I had a similar issue with one application. 1 out of 4 test components just would not go up more, than 50 percent of required users.
The problem was that component was a memory eater and when it reached the maximum heap it did not let the other threads in that component to ramp-up. But just a long shot.
I am trying to use the interleave controller inside another controller (ForEach OR Loop OR any other) such that each of the sampler (which is HTTP request) under Interleave controller is executed once and the test exits the "outer" controller once the last sampler is done.
My test plan looks somewhat like show below
test plan
--Loop controller ( with loop count = num of requests in Interleave Controller)
----Some test elements
----Interleave Controller
--------HTTP requests (count = n, with some differences)
----Some More test elements
The test plan is to test multiple test scenarios of a lot of REST services (having some changes in the request data etc) so some services might have 2 scenarios some might have 10.
Thus is there any way of getting the number of samplers under the interleave controller ? OR a better design to my test plan.
Thanks
Have a look at the interleave documentation as it explains nicely how it works and how one sampler, going from top to bottom, is executed per iteration. If you want only one sampler executed randomly (per iteration) you can use the random controller.
Note: Those controllers don't stop by them selves if all children have been executed. They start all over again. If you want to stop you have to add different logic to make that happen.