How to add different time delays between page requests in JMeter? - random

I've a JMeter Script that does the following:
User registers to the site filling out a form with personal information
Reads through Terms, Condition and agrees to the Agreement
Reads through the instructions and answers practice questions before taking the test (next step)
Takes a timed test of multiple choices for 10 minutes and submits answers.
As you can imagine, they require different delays. Users take 1-2 minutes to fill-out the form. Usually goes really quick through the terms and conditions (less than 30 seconds) and hits 'I Agree' button. Then spends 4-5 minutes in reading the instructions and taking the practice tests (I measured, takes approximately 4-5 minutes) and finally takes the 10 minute timed test.
Now, question is: how do I insert these different time delays between different page requests? I saw some posts that shows how to insert variable time delays to 'ALL' pages. But for me that doesn't help. Please see attached image of what I ideally intend to do.
Can anyone please help? Thanks in advance!
--Ishti

I think I got the answer. It's actually in the Manual itself at:
http://jmeter.apache.org/usermanual/component_reference.html#timers
Note that timers are processed before each sampler in the scope in which they are found; if there are several timers in the same scope, all the timers will be processed before each sampler.
Timers are only processed in conjunction with a sampler. A timer which is not in the same scope as a sampler will not be processed at all.
To apply a timer to a single sampler, add the timer as a child element of the sampler. The timer will be applied before the sampler is executed. To apply a timer after a sampler, either add it to the next sampler, or add it as the child of a Test Action Sampler.

Related

Does the Constant Timer added in my HTTP Request affect the results in the Summary Report?

I have a HTTP Request in my Thread Grpup that takes around 20 to 30 seconds to complete with a single user, so when I added 50 users I get a 500/Internal Server Error or 503/Server has been shutdown sometimes.
I want to add a Constant Timer with 40 seconds (in miliseconds) under the HTTP Request so maybe the application will have some time to process it. I am going to the rigth way?
If I add the Constant Timer will it be calculate as well in the Summary Report?
I need that the Jmeter give the time to the API (My aplication) complete the process (need at least 30 seconds) and it may be or not affetct my Summary Report
PreProcessors, Post-Processors and Timers are not counted in the Elapsed time. so response time will not be impacted.
However Throughout (the number of requests for the test duration) will be lower.
See JMeter Glossary for more information on the above metrics.
With regards to "right way" - real users don't "hammer" application non-stop, they need some time to "think" between operations so if you're simulating a real user you should have non-zero think time, however 40 seconds it kind of too much for me. Take a look at How to make JMeter behave more like a real browser article for more tips on properly configuring your JMeter test.

How to generate number of requests per second for one user

I am trying to configure a test for signup-login with invalid credentials imitating bruttforce attack. However, I want to make requests as a single user.
So the scenario is the next:
Request to sign up with valid params;
Attempt to log in with invalid params in a loop.
I am adding throughput timer but then I need to set up a high number of threads to generate for example 1 request per second.
How can I set exactly one user and run only one request per second in a loop?
UPDATE - SOLUTION
Everything was rather simple but still strange for me.
Maybe someone will face the same problem.
To get a number of requests per one user throughput timer should be placed not inside the controller but inside the thread itself.
To achieve Target Request Per Second use Throughout Shaping Timer : How to use Throughput Shaping Timer
JMeter Plugin link : Download from here
Few Important Notes:
JMeter threads of Thread Groups in scope of the Element will be
stopped when RPS schedule finishes.
Provide enough working threads for your RPS, JMeter timers can only delay threads (and limit RPS). You may pair this plugin with Concurrency Thread Group using Schedule Feedback Function to dynamically maintain thread count required to achieve target RPS.
If you're using versions of JMeter lower than 3.3 and if you have RPS that lower at the end of test, make threads to lower also. Оtherwise you'll have a spike in last second.
Avoid using zero RPS value as start of test, this produce spike also
Avoid zero RPS during the test, this may lead to nasty effects
Now, practical example showing 1 RPS for 1 User:
You might want to reconsider the location of the timer, it obeys JMeter Scoping Rules so it gets applied to all Samplers which are in your Thread Group.
If you want to apply it to only one - make it a child of the relevant sampler.
Also be aware that Constant Throughput Timer is precise enough on minute level so you might want to switch to the Precise Throughput Timer

JMeter - how to simulate polling with multiple URLs

In JMeter, I can load test many pages using a random variable:
/path/item/${random_var}
I would like to hit each page X number of times (or until a condition is met). I would also like to wait (e.g. 1 second) in between requests for a specific page (it's fine to have concurrent requests for /path/item/1 and /path/item/2).
Any guidance on setup for that is much appreciated. I can answer clarifying questions if needed.
Add a Constant Timer as a child of this request and set Thread Delay to 1000.
Timer will be fired before each request therefore you will get a 1 second delay between next call. Sleep time will not be added to sampler's response time (unless you are using Transaction Controller configured to do so)
See A Comprehensive Guide to Using JMeter Timers for more information on above and other Timers and their use cases.

Confusion in choosing delay between Iterations

My goal is to give exact 5000 milliseconds delay between Iterations.
Below are 2 approaches I have followed.
Approach #:1 :ThreadGroup>Add TestAction>Add JSR223 Timer (see the below screenshot).
I am very clear on approach #1 and i can see the below lines in the jmeter.log(5000-Prev gettime)from this i got confirmation delay between Iterations working.
2017-08-21 16:23:08,260 INFO o.a.j.t.JSR223Timer: 4831
2017-08-21 16:42:37,871 INFO o.a.j.t.JSR223Timer: 4835
Approach #:2 : ThreadGroup>Add TestAction (see the below screenshot).
After I executed the test in the jmeter.log, i couldn't find any number indicating delay between Iterations.
My Questions:
1.For the 5000 milliseconds delay between the iterations which approach should i follow Approach #:1 or Approach # 2.
2.If i use Approach #:2 as is how can and where can i cross check 5000 milliseconds are applying for each Iterations.
3.Is Approach #:2 correct i mean to say am i missing anything?
Please advise me! I am soo confused.
Thanks,
Raj
Your Approach #1 is flaky as
Delay between requests will always be less than 5 seconds
Assuming this JSR223 Timer position the delay is applied to all samplers, if you want all threads to sleep for 5 seconds at the iteration start you need to add it as a child of the first sampler. References:
Scoping Rules
A Comprehensive Guide to Using JMeter Timers
Your Approach #2 is fine.
Where do you expect to see evidences of the delays? JMeter log won't contain any lines indicating the sleep happened and .jtl results file will neither show Test Action sampler result(s) nor JSR223 Timer (unless you put your sampler under a Transaction Controller in "parent sample" mode configured to store duration of pre/post processors and timers).
The only way to see the "sleep" works is running your test 2 times: with and without "sleeps" (better with 1 virtual user), the total duration of the test with "sleeps" enabled should be 5 seconds longer.

Is it possible to have threads execute independently of each other in a JMeter test script?

I've got a pretty basic test plan in JMeter consisting of a Thread Group and a bunch of HTTP Requests separated by Timers and a Summary Report. I notice when I watch the report that all 10 of my threads make the first request, then pause for some time, then all make the second request.
Is it possible to have each thread execute the full script independently of the others so that (given a Ramp-up delay) you have overlapping workload, i.e. some threads executing the first step while others are on the 3rd or 4th etc?
Threads DO execute independently in JMeter.
Make sure you are you using any Ramp-up period in the thread group definition.
Another reason for what you're seeing is probably due to using a constant timer which ends up in requests looking they they are synchronized. If you simply change it to one of the Random timers you'll get more randomness in the delay between requests.
Here are two good sources about timers:
http://performancetestersdiary.wordpress.com/2013/03/06/jmeter-timers-in-pictures/
http://www.softwaretestingclass.com/timers-in-jmeter-tutorial-series-6/
Yes, Threads DO execute independently in JMeter, but,if you start at the same time and do the same things, all the requests will be issued at the same time (specially if you are using a constant throughput timer).
I use two way of approaching this problem:
use a uniform random timer under a "once Only controller", at the beginning of the thread.
The value of the timer should be close equal or close to the time it takes to execute the service.
use rampup time (same value as above). It is deterministic and simpler to use (which can be bad or good, according to your needs.
Click on your "Test Plan"
Check/Select the Property: Run Threads consecutively (i.e. Run Groups one at a time)
Hope this will help.

Resources