could anyone suggest a good approach for controlling requests flow in JMeter. Here is the problem statement:
Test Plan:
Transaction Controller 'Homepage'
request 1
request 2
request 3
Transaction Controller 'News'
request 1
request 2
Transaction Controller 'Results'
request 1
request 2
What I need is to create controller, that will do following:
1) after 'Homepage' is done 50% users will end test, 20% will go to 'News' and 30% will go to 'Results'.
2) after 'News' is done 80% will go to 'Results' and 20% will go to 'News' again.
the possible solution, as for me, is to create complecated 'If controllers' that check something like:
random_value >= 50%
and run needed controller
but that seems to be a bit tricky, may be there is a plugin/step that was designed for such things? Or may be I could use some script for flow controlling, like:
if(random_value >= 50%) {
runner.runController("News")
} else {
runner.runController("Results")
}
?
It sounds like you need the throughput controller: http://jmeter.apache.org/usermanual/component_reference.html#Throughput_Controller
To end a test, you can use a test action sampler.
I also would start using Throughput Controller.
The following structure should go very close to the behaviour you need.
Transaction Ctrl 'Homepage'
Throughput Ctrl 'Results (weight 30)
Module Controller 'Results'
Throughput Ctrl 'Otherwise' (weight 20)
simple controller
Module Controller 'News'
Throughput Ctrl 'News2' (weight 20)
Module Controller 'News'
Throughput Ctrl 'Results2' (weight 80)
Module Controller 'Results'
Transaction Ctrl exit
Please note that this structure allows some user to flow through each leave of the tree, because each Throughput controller is evaluated independently from the other.
Obviously I did not tried it, but I think it is a good approximation with a reasonable effort.
Related
For my scenario I want to combine few samples into one to show output as login ( instead of showing all 4,5 samples involved in login). My test plan has Onceonly controllers for login and logout users. Once the users are logged in, we want to loop through different data (iterations) Once all the iterations are done users should logout.
My overall testplan is like this.
Testplan
--ThreadGroup
OnlyOnceController
--LoginTransactionController
LoginSample1
LoginSample2
LoginSample3
Loop Controller
--Action1transactionController
Action1sample1
Action1sample2
Action1sample3
--Action2transactionController
Action2sample1
Action2sample2
--Action3trasactitonController
Action3sample1
Action3sample2
OnlyOnceController
--LogoutTransactionController
Logoutsample1
logoutsample2
I used transactioncontrollers inside loop controller.
When I trigger run with say 30 users (threadcount) and loop count =10, then in view result tree I am noticing that that all users finish one transaction controller and then move to other transaction controller together and then going to next loop.Is this because I used transaction controllers inside a loop controller?
But I want once the user login it should move on to next next samples without waiting for others. Is it right way to use transaction controller for my requirement?
Is there any other way to achieve this?
LoginTransactionController
LoginTransactionController
LoginTransactionController
.
.
Action1transactionController
Action1transactionController
Action1transactionController
.
.
.
30times
Action2transactionController
Action2transactionController
Action2transactionController
.
.
.
30times
Action3trasactitonController
Action3trasactitonController
Action3trasactitonController
.
.
.
30times
Then it is going to second iteration.
JMeter threads (virtual users) are absolutely independent, a virtual user will not "wait" for the others (unless you use Inter-Thread Communication Plugin)
JMeter virtual users execute Samplers upside down as fast as they can. Transaction Controller is nothing more than a "virtual sampler" which simply sums the response time of its children, it doesn't have any impact on the execution order
You can temporarily add a __threadNum() function and ${__jm__Loop Controller__idx} pre-defined variable, this way you will see which virtual user is doing at every moment of your test
Please refer the attachment where i have mentioned the anticipated volume for each requests.
Had i not have Action 2 , I would have easily derived the load distribution.
I'm stuck when i have one more transaction inside the throughput controller Action 1 . Can anyone please suggest what need to be the throughput controller value(%) when i still need to derive the load from that to the child request.
If i have addition of Throughput Controller Search Action1 and Throughput Controller Action 2 i end up having more volume for Action 1.
Hope my requirement is clear.Please can anyone suggest me how can i achieve the anticipated load for all the 4 requests.
You can go for something like:
If you need to execute these 15 times samplers after 32 times you can use Inter-Thread Communication Plugin in order to pause them until the data will be available.
You can install Inter-Thread Communication plugin using JMeter Plugins Manager:
In case you need to execute 32 Action 1 with 15 (or 18, or 19) of them followed by Action 2 - you have to put not one, but two Throughput controllers under under "Search action 32 of 210":
first takes 19 "Action 1"s followed by "Action 1" out of 32
second takes remaining 13 "Action 1" alone (not followed by "Action 2")
Is that what you are aiming for?
Here Goes my Answer to my own question:
Like i said ,below is my Throughput shaping timer.
Virtual user is 3 because to perform 0.35 rps considering response time+think time as 10 sec (0.35RPS*10sec)
Below is the work load model :
As launch and login is pretty clear , below is my explanation of action1 and action 2.
Since Out of 210 requests 51 requests(action 1 and action 2) should fall under one flow i need to have one thru controller as a parent which should make sure that out of 210 requests 51 should be from its child requests.Not over yet.
Now I cant let action 1 to take all 51 load because my req is 32. Hence i ll take 32 out of 51 requests for action 1.(32/52=62% of parent load)
Now for action 2 parent is action 1's load. so i need to make sure that when control comes (32 times) to action 1 i should let only 19 of them to proceed. hence 19/32 =59%.
Thus i achieved the desired load by making parent throughput controller to take responsibility of not letting other thoughput controller to take more than told load(launch and login) .
I have used Gaussian random timer value as 8 sec(2 sec deviation) when testing the actual application.
Well I was using codeception to test on an ajax page, in which I click the button and some kind of text is shown after an AJAX request is performed.
$I->amOnPage('/clickbutton.html');
$I->click('Get my ID');
$I->see('Your user id is 1', '.divbox');
As you see, the test is supposed to work in a way that 'Your user id is {$id}' is returned(in this case the id is 1), and updates a div box with the text. However, it doesnt work at all, instead the test says the div box is blank. What did I do wrong? How can I use codeception to test an AJAX request?
You can also use this:
$I->click('#something');
$I->waitForText('Something that appears a bit later', 20, '#my_element');
20 = timeout (in seconds), give it some sane value.
It's a bit more flexible instead of hammering down things like $I->wait(X);, because they are usually a lot faster than waiting for them in seconds. So, for example, if you've got many elements that you need to "wait" for, let's say 15-20, then your test will spend 15-20 seconds "waiting" while actual operations finish in maybe 1-2s total. Across many tests this can increase build times significantly, which is... not good :)
Are you sure your request has finished by the time you check the div? Try adding a little wait after sending the request:
$I->amOnPage('/clickbutton.html');
$I->click('Get my ID');
$I->wait(1); //add this
$I->see('Your user id is 1', '.divbox');
I am trying to do the load testing of the pages which can be access after login only.
As I am using Once Only Controller for login request ,when I changed Number of thread- 5 or more,login executes 5 times.
as Once Only Controller works for loopcount so I used loopcount but it slowdown my process and it executes the whole testplan.
My test-plan is:
login thread A- one time execution - how to do it?
http request B- multiple times(by using Number of threads)
http request C- multiple times(by using Number of threads)
What should I use for one time login execution and other successor requests needs to be executed multiple times without using Once Only Controller?
Kindly follow these steps:-
In Thread Group put number of threads:5 , Ramp-up:0 , Loop count: 1
Put your Login part in Once only controller
Right click on Your thread group > add > logic controller > loop controller
Now put your http request part in loop controller and set loop count of loop controller how many times you want to run
Then run the test you will get whatever you want
The Loop count in "Thread Group" is your full script Loop count not for your Transactions, for your transactions you have to put separate loop count before transaction starts.
Please do below
Your thread group setting should be below:
A.Number of threads :1
B:Ramp up period : 0 or as per application response.
C:Loop Count :5
Put your login request under Only once controller.
Request B and Request C should be at thread group Level.ie one step above it.
Run the request.
please find Sample Jmxsample Jmx for your reference Plse try. Hope it resolves your issue.
I need to regulate how often a Mechanize instance connects with an API (once every 2 seconds, so limit connections to that or more)
So this:
instance.pre_connect_hooks << Proc.new { sleep 2 }
I had thought this would work, and it sort of does BUT now every method in that class sleeps for 2 seconds, as if the mechanize instance is touched and told to hold 2 seconds. I'm going to try a post connect hook, but it is obvious I need something a bit more elaborate, but what I don't know what at this point.
Code is more explanation so if you are interested following along: https://github.com/blueblank/reddit_modbot, otherwise my question concerns how to efficiently and effectively rate limit a Mechanize instance to within a specific time frame specified by an API (where overstepping that limit results in dropped requests and bans). Also, I'm guessing I need to better integrate a mechanize instance to my class as well, any pointers on that appreciated as well.
Pre and post connect hooks are called on every connect, so if there is some redirection it could trigger many times for one request. Try history_added which only gets called once:
instance.history_added = Proc.new {sleep 2}
I use SlowWeb to rate limit calls to a specific URL.
require 'slowweb'
SlowWeb.limit('example.com', 10, 60)
In this case calls to example.com domain are limited to 10 requests every 60 seconds.