How do I make a test stop after X iterations?
Normally, Loadster bots will run your script repeatedly for as long as there is time remaining in your load test. When the time runs out, bots that are still in the middle of an iteration (still playing a script) are allowed to finish that iteration of the script and then exit. Because of this, the total number of iterations of your script that end up running in a load test mostly just depends on how much time you allow for the test.
If you have a requirement to run an exact number of iterations and then stop, relying on the test duration alone won’t do the trick.
For example, maybe you are testing a shipping application, and you just want to process 10,000 shipments in as little time as possible. Or you might have a dataset with 5000 unique usernames and passwords, and you want to use all of those and no more.
In these cases, you can set an exact iteration limit for your bots. Once the iteration limit has been reached the bots will exit, even if there is time remaining in the test.
Types of iteration limits
A load test scenario supports two different types of iteration limits. You can limit total iterations or you can limit iterations per bot.
Limiting the total iterations means that the bot group in your load test won’t run any more iterations than the limit between all bots, but it does not guarantee how many iterations each bot runs. For example, if you set a total iteration limit of 500 and you have 500 bots, it’s possible that some bots will end up running 2 iterations and others might run 0, if the earlier bots finish their first iteration before the later bots even start. Still, limiting total iterations guarantees the number of iterations between all bots does not exceed that number.
Limiting iterations per bot means simply that each bot is allowed to run up to that many iterations before exiting. For example, if you run 500 bots and limit each bot to 1 iteration, it guarantees that each bot runs the script exactly once.
Keep in mind that if the test is too short, your bots may still exit before the number of iterations has been reached. They exit after the iteration limit has been reached or the time runs out, whichever happens first.
Setting iteration limits
To set an iteration limit, go to your test scenario and click the gear menu for the bot group you want to set a limit on. This expands additional options, including Limit total iterations and Limit iterations per bot.
Selecting either (or both) of these allows you to set an iteration limit.
Read more about this and other advanced configuration options in Running Load Tests.